babylon.module.d.ts 6.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696
  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. /**
  36431. * Information about the current host
  36432. */
  36433. export interface HostInformation {
  36434. /**
  36435. * Defines if the current host is a mobile
  36436. */
  36437. isMobile: boolean;
  36438. }
  36439. /** Interface defining initialization parameters for Engine class */
  36440. export interface EngineOptions extends WebGLContextAttributes {
  36441. /**
  36442. * Defines if the engine should no exceed a specified device ratio
  36443. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36444. */
  36445. limitDeviceRatio?: number;
  36446. /**
  36447. * Defines if webvr should be enabled automatically
  36448. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36449. */
  36450. autoEnableWebVR?: boolean;
  36451. /**
  36452. * Defines if webgl2 should be turned off even if supported
  36453. * @see https://doc.babylonjs.com/features/webgl2
  36454. */
  36455. disableWebGL2Support?: boolean;
  36456. /**
  36457. * Defines if webaudio should be initialized as well
  36458. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36459. */
  36460. audioEngine?: boolean;
  36461. /**
  36462. * Defines if animations should run using a deterministic lock step
  36463. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36464. */
  36465. deterministicLockstep?: boolean;
  36466. /** Defines the maximum steps to use with deterministic lock step mode */
  36467. lockstepMaxSteps?: number;
  36468. /** Defines the seconds between each deterministic lock step */
  36469. timeStep?: number;
  36470. /**
  36471. * Defines that engine should ignore context lost events
  36472. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36473. */
  36474. doNotHandleContextLost?: boolean;
  36475. /**
  36476. * Defines that engine should ignore modifying touch action attribute and style
  36477. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36478. */
  36479. doNotHandleTouchAction?: boolean;
  36480. /**
  36481. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36482. */
  36483. useHighPrecisionFloats?: boolean;
  36484. /**
  36485. * Make the canvas XR Compatible for XR sessions
  36486. */
  36487. xrCompatible?: boolean;
  36488. /**
  36489. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36490. */
  36491. useHighPrecisionMatrix?: boolean;
  36492. }
  36493. /**
  36494. * The base engine class (root of all engines)
  36495. */
  36496. export class ThinEngine {
  36497. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36498. static ExceptionList: ({
  36499. key: string;
  36500. capture: string;
  36501. captureConstraint: number;
  36502. targets: string[];
  36503. } | {
  36504. key: string;
  36505. capture: null;
  36506. captureConstraint: null;
  36507. targets: string[];
  36508. })[];
  36509. /** @hidden */
  36510. static _TextureLoaders: IInternalTextureLoader[];
  36511. /**
  36512. * Returns the current npm package of the sdk
  36513. */
  36514. static get NpmPackage(): string;
  36515. /**
  36516. * Returns the current version of the framework
  36517. */
  36518. static get Version(): string;
  36519. /**
  36520. * Returns a string describing the current engine
  36521. */
  36522. get description(): string;
  36523. /**
  36524. * Gets or sets the epsilon value used by collision engine
  36525. */
  36526. static CollisionsEpsilon: number;
  36527. /**
  36528. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36529. */
  36530. static get ShadersRepository(): string;
  36531. static set ShadersRepository(value: string);
  36532. /** @hidden */
  36533. _shaderProcessor: IShaderProcessor;
  36534. /**
  36535. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36536. */
  36537. forcePOTTextures: boolean;
  36538. /**
  36539. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36540. */
  36541. isFullscreen: boolean;
  36542. /**
  36543. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36544. */
  36545. cullBackFaces: boolean;
  36546. /**
  36547. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36548. */
  36549. renderEvenInBackground: boolean;
  36550. /**
  36551. * Gets or sets a boolean indicating that cache can be kept between frames
  36552. */
  36553. preventCacheWipeBetweenFrames: boolean;
  36554. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36555. validateShaderPrograms: boolean;
  36556. /**
  36557. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36558. * This can provide greater z depth for distant objects.
  36559. */
  36560. useReverseDepthBuffer: boolean;
  36561. /**
  36562. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36563. */
  36564. disableUniformBuffers: boolean;
  36565. /** @hidden */
  36566. _uniformBuffers: UniformBuffer[];
  36567. /**
  36568. * Gets a boolean indicating that the engine supports uniform buffers
  36569. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36570. */
  36571. get supportsUniformBuffers(): boolean;
  36572. /** @hidden */
  36573. _gl: WebGLRenderingContext;
  36574. /** @hidden */
  36575. _webGLVersion: number;
  36576. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36577. protected _windowIsBackground: boolean;
  36578. protected _creationOptions: EngineOptions;
  36579. protected _highPrecisionShadersAllowed: boolean;
  36580. /** @hidden */
  36581. get _shouldUseHighPrecisionShader(): boolean;
  36582. /**
  36583. * Gets a boolean indicating that only power of 2 textures are supported
  36584. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36585. */
  36586. get needPOTTextures(): boolean;
  36587. /** @hidden */
  36588. _badOS: boolean;
  36589. /** @hidden */
  36590. _badDesktopOS: boolean;
  36591. private _hardwareScalingLevel;
  36592. /** @hidden */
  36593. _caps: EngineCapabilities;
  36594. private _isStencilEnable;
  36595. private _glVersion;
  36596. private _glRenderer;
  36597. private _glVendor;
  36598. /** @hidden */
  36599. _videoTextureSupported: boolean;
  36600. protected _renderingQueueLaunched: boolean;
  36601. protected _activeRenderLoops: (() => void)[];
  36602. /**
  36603. * Observable signaled when a context lost event is raised
  36604. */
  36605. onContextLostObservable: Observable<ThinEngine>;
  36606. /**
  36607. * Observable signaled when a context restored event is raised
  36608. */
  36609. onContextRestoredObservable: Observable<ThinEngine>;
  36610. private _onContextLost;
  36611. private _onContextRestored;
  36612. protected _contextWasLost: boolean;
  36613. /** @hidden */
  36614. _doNotHandleContextLost: boolean;
  36615. /**
  36616. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36617. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36618. */
  36619. get doNotHandleContextLost(): boolean;
  36620. set doNotHandleContextLost(value: boolean);
  36621. /**
  36622. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36623. */
  36624. disableVertexArrayObjects: boolean;
  36625. /** @hidden */
  36626. protected _colorWrite: boolean;
  36627. /** @hidden */
  36628. protected _colorWriteChanged: boolean;
  36629. /** @hidden */
  36630. protected _depthCullingState: DepthCullingState;
  36631. /** @hidden */
  36632. protected _stencilState: StencilState;
  36633. /** @hidden */
  36634. _alphaState: AlphaState;
  36635. /** @hidden */
  36636. _alphaMode: number;
  36637. /** @hidden */
  36638. _alphaEquation: number;
  36639. /** @hidden */
  36640. _internalTexturesCache: InternalTexture[];
  36641. /** @hidden */
  36642. protected _activeChannel: number;
  36643. private _currentTextureChannel;
  36644. /** @hidden */
  36645. protected _boundTexturesCache: {
  36646. [key: string]: Nullable<InternalTexture>;
  36647. };
  36648. /** @hidden */
  36649. protected _currentEffect: Nullable<Effect>;
  36650. /** @hidden */
  36651. protected _currentProgram: Nullable<WebGLProgram>;
  36652. private _compiledEffects;
  36653. private _vertexAttribArraysEnabled;
  36654. /** @hidden */
  36655. protected _cachedViewport: Nullable<IViewportLike>;
  36656. private _cachedVertexArrayObject;
  36657. /** @hidden */
  36658. protected _cachedVertexBuffers: any;
  36659. /** @hidden */
  36660. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36661. /** @hidden */
  36662. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36663. /** @hidden */
  36664. _currentRenderTarget: Nullable<InternalTexture>;
  36665. private _uintIndicesCurrentlySet;
  36666. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36667. /** @hidden */
  36668. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36669. /** @hidden */
  36670. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36671. private _currentBufferPointers;
  36672. private _currentInstanceLocations;
  36673. private _currentInstanceBuffers;
  36674. private _textureUnits;
  36675. /** @hidden */
  36676. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36677. /** @hidden */
  36678. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36679. /** @hidden */
  36680. _boundRenderFunction: any;
  36681. private _vaoRecordInProgress;
  36682. private _mustWipeVertexAttributes;
  36683. private _emptyTexture;
  36684. private _emptyCubeTexture;
  36685. private _emptyTexture3D;
  36686. private _emptyTexture2DArray;
  36687. /** @hidden */
  36688. _frameHandler: number;
  36689. private _nextFreeTextureSlots;
  36690. private _maxSimultaneousTextures;
  36691. private _activeRequests;
  36692. /** @hidden */
  36693. _transformTextureUrl: Nullable<(url: string) => string>;
  36694. /**
  36695. * Gets information about the current host
  36696. */
  36697. hostInformation: HostInformation;
  36698. protected get _supportsHardwareTextureRescaling(): boolean;
  36699. private _framebufferDimensionsObject;
  36700. /**
  36701. * sets the object from which width and height will be taken from when getting render width and height
  36702. * Will fallback to the gl object
  36703. * @param dimensions the framebuffer width and height that will be used.
  36704. */
  36705. set framebufferDimensionsObject(dimensions: Nullable<{
  36706. framebufferWidth: number;
  36707. framebufferHeight: number;
  36708. }>);
  36709. /**
  36710. * Gets the current viewport
  36711. */
  36712. get currentViewport(): Nullable<IViewportLike>;
  36713. /**
  36714. * Gets the default empty texture
  36715. */
  36716. get emptyTexture(): InternalTexture;
  36717. /**
  36718. * Gets the default empty 3D texture
  36719. */
  36720. get emptyTexture3D(): InternalTexture;
  36721. /**
  36722. * Gets the default empty 2D array texture
  36723. */
  36724. get emptyTexture2DArray(): InternalTexture;
  36725. /**
  36726. * Gets the default empty cube texture
  36727. */
  36728. get emptyCubeTexture(): InternalTexture;
  36729. /**
  36730. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36731. */
  36732. readonly premultipliedAlpha: boolean;
  36733. /**
  36734. * Observable event triggered before each texture is initialized
  36735. */
  36736. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36737. /**
  36738. * Creates a new engine
  36739. * @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
  36740. * @param antialias defines enable antialiasing (default: false)
  36741. * @param options defines further options to be sent to the getContext() function
  36742. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36743. */
  36744. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36745. private _rebuildInternalTextures;
  36746. private _rebuildEffects;
  36747. /**
  36748. * Gets a boolean indicating if all created effects are ready
  36749. * @returns true if all effects are ready
  36750. */
  36751. areAllEffectsReady(): boolean;
  36752. protected _rebuildBuffers(): void;
  36753. protected _initGLContext(): void;
  36754. /**
  36755. * Gets version of the current webGL context
  36756. */
  36757. get webGLVersion(): number;
  36758. /**
  36759. * Gets a string identifying the name of the class
  36760. * @returns "Engine" string
  36761. */
  36762. getClassName(): string;
  36763. /**
  36764. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36765. */
  36766. get isStencilEnable(): boolean;
  36767. /** @hidden */
  36768. _prepareWorkingCanvas(): void;
  36769. /**
  36770. * Reset the texture cache to empty state
  36771. */
  36772. resetTextureCache(): void;
  36773. /**
  36774. * Gets an object containing information about the current webGL context
  36775. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36776. */
  36777. getGlInfo(): {
  36778. vendor: string;
  36779. renderer: string;
  36780. version: string;
  36781. };
  36782. /**
  36783. * Defines the hardware scaling level.
  36784. * By default the hardware scaling level is computed from the window device ratio.
  36785. * 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.
  36786. * @param level defines the level to use
  36787. */
  36788. setHardwareScalingLevel(level: number): void;
  36789. /**
  36790. * Gets the current hardware scaling level.
  36791. * By default the hardware scaling level is computed from the window device ratio.
  36792. * 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.
  36793. * @returns a number indicating the current hardware scaling level
  36794. */
  36795. getHardwareScalingLevel(): number;
  36796. /**
  36797. * Gets the list of loaded textures
  36798. * @returns an array containing all loaded textures
  36799. */
  36800. getLoadedTexturesCache(): InternalTexture[];
  36801. /**
  36802. * Gets the object containing all engine capabilities
  36803. * @returns the EngineCapabilities object
  36804. */
  36805. getCaps(): EngineCapabilities;
  36806. /**
  36807. * stop executing a render loop function and remove it from the execution array
  36808. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36809. */
  36810. stopRenderLoop(renderFunction?: () => void): void;
  36811. /** @hidden */
  36812. _renderLoop(): void;
  36813. /**
  36814. * Gets the HTML canvas attached with the current webGL context
  36815. * @returns a HTML canvas
  36816. */
  36817. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36818. /**
  36819. * Gets host window
  36820. * @returns the host window object
  36821. */
  36822. getHostWindow(): Nullable<Window>;
  36823. /**
  36824. * Gets the current render width
  36825. * @param useScreen defines if screen size must be used (or the current render target if any)
  36826. * @returns a number defining the current render width
  36827. */
  36828. getRenderWidth(useScreen?: boolean): number;
  36829. /**
  36830. * Gets the current render height
  36831. * @param useScreen defines if screen size must be used (or the current render target if any)
  36832. * @returns a number defining the current render height
  36833. */
  36834. getRenderHeight(useScreen?: boolean): number;
  36835. /**
  36836. * Can be used to override the current requestAnimationFrame requester.
  36837. * @hidden
  36838. */
  36839. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36840. /**
  36841. * Register and execute a render loop. The engine can have more than one render function
  36842. * @param renderFunction defines the function to continuously execute
  36843. */
  36844. runRenderLoop(renderFunction: () => void): void;
  36845. /**
  36846. * Clear the current render buffer or the current render target (if any is set up)
  36847. * @param color defines the color to use
  36848. * @param backBuffer defines if the back buffer must be cleared
  36849. * @param depth defines if the depth buffer must be cleared
  36850. * @param stencil defines if the stencil buffer must be cleared
  36851. */
  36852. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36853. private _viewportCached;
  36854. /** @hidden */
  36855. _viewport(x: number, y: number, width: number, height: number): void;
  36856. /**
  36857. * Set the WebGL's viewport
  36858. * @param viewport defines the viewport element to be used
  36859. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36860. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36861. */
  36862. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36863. /**
  36864. * Begin a new frame
  36865. */
  36866. beginFrame(): void;
  36867. /**
  36868. * Enf the current frame
  36869. */
  36870. endFrame(): void;
  36871. /**
  36872. * Resize the view according to the canvas' size
  36873. */
  36874. resize(): void;
  36875. /**
  36876. * Force a specific size of the canvas
  36877. * @param width defines the new canvas' width
  36878. * @param height defines the new canvas' height
  36879. * @returns true if the size was changed
  36880. */
  36881. setSize(width: number, height: number): boolean;
  36882. /**
  36883. * Binds the frame buffer to the specified texture.
  36884. * @param texture The texture to render to or null for the default canvas
  36885. * @param faceIndex The face of the texture to render to in case of cube texture
  36886. * @param requiredWidth The width of the target to render to
  36887. * @param requiredHeight The height of the target to render to
  36888. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  36889. * @param lodLevel defines the lod level to bind to the frame buffer
  36890. * @param layer defines the 2d array index to bind to frame buffer to
  36891. */
  36892. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  36893. /** @hidden */
  36894. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  36895. /**
  36896. * Unbind the current render target texture from the webGL context
  36897. * @param texture defines the render target texture to unbind
  36898. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  36899. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  36900. */
  36901. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  36902. /**
  36903. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  36904. */
  36905. flushFramebuffer(): void;
  36906. /**
  36907. * Unbind the current render target and bind the default framebuffer
  36908. */
  36909. restoreDefaultFramebuffer(): void;
  36910. /** @hidden */
  36911. protected _resetVertexBufferBinding(): void;
  36912. /**
  36913. * Creates a vertex buffer
  36914. * @param data the data for the vertex buffer
  36915. * @returns the new WebGL static buffer
  36916. */
  36917. createVertexBuffer(data: DataArray): DataBuffer;
  36918. private _createVertexBuffer;
  36919. /**
  36920. * Creates a dynamic vertex buffer
  36921. * @param data the data for the dynamic vertex buffer
  36922. * @returns the new WebGL dynamic buffer
  36923. */
  36924. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  36925. protected _resetIndexBufferBinding(): void;
  36926. /**
  36927. * Creates a new index buffer
  36928. * @param indices defines the content of the index buffer
  36929. * @param updatable defines if the index buffer must be updatable
  36930. * @returns a new webGL buffer
  36931. */
  36932. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  36933. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  36934. /**
  36935. * Bind a webGL buffer to the webGL context
  36936. * @param buffer defines the buffer to bind
  36937. */
  36938. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  36939. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  36940. private bindBuffer;
  36941. /**
  36942. * update the bound buffer with the given data
  36943. * @param data defines the data to update
  36944. */
  36945. updateArrayBuffer(data: Float32Array): void;
  36946. private _vertexAttribPointer;
  36947. /** @hidden */
  36948. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  36949. private _bindVertexBuffersAttributes;
  36950. /**
  36951. * Records a vertex array object
  36952. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36953. * @param vertexBuffers defines the list of vertex buffers to store
  36954. * @param indexBuffer defines the index buffer to store
  36955. * @param effect defines the effect to store
  36956. * @returns the new vertex array object
  36957. */
  36958. recordVertexArrayObject(vertexBuffers: {
  36959. [key: string]: VertexBuffer;
  36960. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  36961. /**
  36962. * Bind a specific vertex array object
  36963. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36964. * @param vertexArrayObject defines the vertex array object to bind
  36965. * @param indexBuffer defines the index buffer to bind
  36966. */
  36967. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  36968. /**
  36969. * Bind webGl buffers directly to the webGL context
  36970. * @param vertexBuffer defines the vertex buffer to bind
  36971. * @param indexBuffer defines the index buffer to bind
  36972. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  36973. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  36974. * @param effect defines the effect associated with the vertex buffer
  36975. */
  36976. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  36977. private _unbindVertexArrayObject;
  36978. /**
  36979. * Bind a list of vertex buffers to the webGL context
  36980. * @param vertexBuffers defines the list of vertex buffers to bind
  36981. * @param indexBuffer defines the index buffer to bind
  36982. * @param effect defines the effect associated with the vertex buffers
  36983. */
  36984. bindBuffers(vertexBuffers: {
  36985. [key: string]: Nullable<VertexBuffer>;
  36986. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  36987. /**
  36988. * Unbind all instance attributes
  36989. */
  36990. unbindInstanceAttributes(): void;
  36991. /**
  36992. * Release and free the memory of a vertex array object
  36993. * @param vao defines the vertex array object to delete
  36994. */
  36995. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  36996. /** @hidden */
  36997. _releaseBuffer(buffer: DataBuffer): boolean;
  36998. protected _deleteBuffer(buffer: DataBuffer): void;
  36999. /**
  37000. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  37001. * @param instancesBuffer defines the webGL buffer to update and bind
  37002. * @param data defines the data to store in the buffer
  37003. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  37004. */
  37005. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  37006. /**
  37007. * Bind the content of a webGL buffer used with instantiation
  37008. * @param instancesBuffer defines the webGL buffer to bind
  37009. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  37010. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  37011. */
  37012. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  37013. /**
  37014. * Disable the instance attribute corresponding to the name in parameter
  37015. * @param name defines the name of the attribute to disable
  37016. */
  37017. disableInstanceAttributeByName(name: string): void;
  37018. /**
  37019. * Disable the instance attribute corresponding to the location in parameter
  37020. * @param attributeLocation defines the attribute location of the attribute to disable
  37021. */
  37022. disableInstanceAttribute(attributeLocation: number): void;
  37023. /**
  37024. * Disable the attribute corresponding to the location in parameter
  37025. * @param attributeLocation defines the attribute location of the attribute to disable
  37026. */
  37027. disableAttributeByIndex(attributeLocation: number): void;
  37028. /**
  37029. * Send a draw order
  37030. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37031. * @param indexStart defines the starting index
  37032. * @param indexCount defines the number of index to draw
  37033. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37034. */
  37035. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37036. /**
  37037. * Draw a list of points
  37038. * @param verticesStart defines the index of first vertex to draw
  37039. * @param verticesCount defines the count of vertices to draw
  37040. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37041. */
  37042. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37043. /**
  37044. * Draw a list of unindexed primitives
  37045. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37046. * @param verticesStart defines the index of first vertex to draw
  37047. * @param verticesCount defines the count of vertices to draw
  37048. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37049. */
  37050. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37051. /**
  37052. * Draw a list of indexed primitives
  37053. * @param fillMode defines the primitive to use
  37054. * @param indexStart defines the starting index
  37055. * @param indexCount defines the number of index to draw
  37056. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37057. */
  37058. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37059. /**
  37060. * Draw a list of unindexed primitives
  37061. * @param fillMode defines the primitive to use
  37062. * @param verticesStart defines the index of first vertex to draw
  37063. * @param verticesCount defines the count of vertices to draw
  37064. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37065. */
  37066. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37067. private _drawMode;
  37068. /** @hidden */
  37069. protected _reportDrawCall(): void;
  37070. /** @hidden */
  37071. _releaseEffect(effect: Effect): void;
  37072. /** @hidden */
  37073. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37074. /**
  37075. * Create a new effect (used to store vertex/fragment shaders)
  37076. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37077. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37078. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37079. * @param samplers defines an array of string used to represent textures
  37080. * @param defines defines the string containing the defines to use to compile the shaders
  37081. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37082. * @param onCompiled defines a function to call when the effect creation is successful
  37083. * @param onError defines a function to call when the effect creation has failed
  37084. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37085. * @returns the new Effect
  37086. */
  37087. 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;
  37088. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37089. private _compileShader;
  37090. private _compileRawShader;
  37091. /** @hidden */
  37092. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37093. /**
  37094. * Directly creates a webGL program
  37095. * @param pipelineContext defines the pipeline context to attach to
  37096. * @param vertexCode defines the vertex shader code to use
  37097. * @param fragmentCode defines the fragment shader code to use
  37098. * @param context defines the webGL context to use (if not set, the current one will be used)
  37099. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37100. * @returns the new webGL program
  37101. */
  37102. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37103. /**
  37104. * Creates a webGL program
  37105. * @param pipelineContext defines the pipeline context to attach to
  37106. * @param vertexCode defines the vertex shader code to use
  37107. * @param fragmentCode defines the fragment shader code to use
  37108. * @param defines defines the string containing the defines to use to compile the shaders
  37109. * @param context defines the webGL context to use (if not set, the current one will be used)
  37110. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37111. * @returns the new webGL program
  37112. */
  37113. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37114. /**
  37115. * Creates a new pipeline context
  37116. * @returns the new pipeline
  37117. */
  37118. createPipelineContext(): IPipelineContext;
  37119. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37120. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37121. /** @hidden */
  37122. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37123. /** @hidden */
  37124. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37125. /** @hidden */
  37126. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37127. /**
  37128. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37129. * @param pipelineContext defines the pipeline context to use
  37130. * @param uniformsNames defines the list of uniform names
  37131. * @returns an array of webGL uniform locations
  37132. */
  37133. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37134. /**
  37135. * Gets the lsit of active attributes for a given webGL program
  37136. * @param pipelineContext defines the pipeline context to use
  37137. * @param attributesNames defines the list of attribute names to get
  37138. * @returns an array of indices indicating the offset of each attribute
  37139. */
  37140. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37141. /**
  37142. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37143. * @param effect defines the effect to activate
  37144. */
  37145. enableEffect(effect: Nullable<Effect>): void;
  37146. /**
  37147. * Set the value of an uniform to a number (int)
  37148. * @param uniform defines the webGL uniform location where to store the value
  37149. * @param value defines the int number to store
  37150. */
  37151. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37152. /**
  37153. * Set the value of an uniform to an array of int32
  37154. * @param uniform defines the webGL uniform location where to store the value
  37155. * @param array defines the array of int32 to store
  37156. */
  37157. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37158. /**
  37159. * Set the value of an uniform to an array of int32 (stored as vec2)
  37160. * @param uniform defines the webGL uniform location where to store the value
  37161. * @param array defines the array of int32 to store
  37162. */
  37163. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37164. /**
  37165. * Set the value of an uniform to an array of int32 (stored as vec3)
  37166. * @param uniform defines the webGL uniform location where to store the value
  37167. * @param array defines the array of int32 to store
  37168. */
  37169. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37170. /**
  37171. * Set the value of an uniform to an array of int32 (stored as vec4)
  37172. * @param uniform defines the webGL uniform location where to store the value
  37173. * @param array defines the array of int32 to store
  37174. */
  37175. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37176. /**
  37177. * Set the value of an uniform to an array of number
  37178. * @param uniform defines the webGL uniform location where to store the value
  37179. * @param array defines the array of number to store
  37180. */
  37181. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37182. /**
  37183. * Set the value of an uniform to an array of number (stored as vec2)
  37184. * @param uniform defines the webGL uniform location where to store the value
  37185. * @param array defines the array of number to store
  37186. */
  37187. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37188. /**
  37189. * Set the value of an uniform to an array of number (stored as vec3)
  37190. * @param uniform defines the webGL uniform location where to store the value
  37191. * @param array defines the array of number to store
  37192. */
  37193. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37194. /**
  37195. * Set the value of an uniform to an array of number (stored as vec4)
  37196. * @param uniform defines the webGL uniform location where to store the value
  37197. * @param array defines the array of number to store
  37198. */
  37199. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37200. /**
  37201. * Set the value of an uniform to an array of float32 (stored as matrices)
  37202. * @param uniform defines the webGL uniform location where to store the value
  37203. * @param matrices defines the array of float32 to store
  37204. */
  37205. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  37206. /**
  37207. * Set the value of an uniform to a matrix (3x3)
  37208. * @param uniform defines the webGL uniform location where to store the value
  37209. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37210. */
  37211. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37212. /**
  37213. * Set the value of an uniform to a matrix (2x2)
  37214. * @param uniform defines the webGL uniform location where to store the value
  37215. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37216. */
  37217. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37218. /**
  37219. * Set the value of an uniform to a number (float)
  37220. * @param uniform defines the webGL uniform location where to store the value
  37221. * @param value defines the float number to store
  37222. */
  37223. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37224. /**
  37225. * Set the value of an uniform to a vec2
  37226. * @param uniform defines the webGL uniform location where to store the value
  37227. * @param x defines the 1st component of the value
  37228. * @param y defines the 2nd component of the value
  37229. */
  37230. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  37231. /**
  37232. * Set the value of an uniform to a vec3
  37233. * @param uniform defines the webGL uniform location where to store the value
  37234. * @param x defines the 1st component of the value
  37235. * @param y defines the 2nd component of the value
  37236. * @param z defines the 3rd component of the value
  37237. */
  37238. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  37239. /**
  37240. * Set the value of an uniform to a vec4
  37241. * @param uniform defines the webGL uniform location where to store the value
  37242. * @param x defines the 1st component of the value
  37243. * @param y defines the 2nd component of the value
  37244. * @param z defines the 3rd component of the value
  37245. * @param w defines the 4th component of the value
  37246. */
  37247. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  37248. /**
  37249. * Apply all cached states (depth, culling, stencil and alpha)
  37250. */
  37251. applyStates(): void;
  37252. /**
  37253. * Enable or disable color writing
  37254. * @param enable defines the state to set
  37255. */
  37256. setColorWrite(enable: boolean): void;
  37257. /**
  37258. * Gets a boolean indicating if color writing is enabled
  37259. * @returns the current color writing state
  37260. */
  37261. getColorWrite(): boolean;
  37262. /**
  37263. * Gets the depth culling state manager
  37264. */
  37265. get depthCullingState(): DepthCullingState;
  37266. /**
  37267. * Gets the alpha state manager
  37268. */
  37269. get alphaState(): AlphaState;
  37270. /**
  37271. * Gets the stencil state manager
  37272. */
  37273. get stencilState(): StencilState;
  37274. /**
  37275. * Clears the list of texture accessible through engine.
  37276. * This can help preventing texture load conflict due to name collision.
  37277. */
  37278. clearInternalTexturesCache(): void;
  37279. /**
  37280. * Force the entire cache to be cleared
  37281. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37282. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37283. */
  37284. wipeCaches(bruteForce?: boolean): void;
  37285. /** @hidden */
  37286. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37287. min: number;
  37288. mag: number;
  37289. };
  37290. /** @hidden */
  37291. _createTexture(): WebGLTexture;
  37292. /**
  37293. * Usually called from Texture.ts.
  37294. * Passed information to create a WebGLTexture
  37295. * @param url defines a value which contains one of the following:
  37296. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37297. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37298. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37299. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37300. * @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)
  37301. * @param scene needed for loading to the correct scene
  37302. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37303. * @param onLoad optional callback to be called upon successful completion
  37304. * @param onError optional callback to be called upon failure
  37305. * @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
  37306. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37307. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37308. * @param forcedExtension defines the extension to use to pick the right loader
  37309. * @param mimeType defines an optional mime type
  37310. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37311. */
  37312. 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;
  37313. /**
  37314. * Loads an image as an HTMLImageElement.
  37315. * @param input url string, ArrayBuffer, or Blob to load
  37316. * @param onLoad callback called when the image successfully loads
  37317. * @param onError callback called when the image fails to load
  37318. * @param offlineProvider offline provider for caching
  37319. * @param mimeType optional mime type
  37320. * @returns the HTMLImageElement of the loaded image
  37321. * @hidden
  37322. */
  37323. 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>;
  37324. /**
  37325. * @hidden
  37326. */
  37327. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37328. private _unpackFlipYCached;
  37329. /**
  37330. * In case you are sharing the context with other applications, it might
  37331. * be interested to not cache the unpack flip y state to ensure a consistent
  37332. * value would be set.
  37333. */
  37334. enableUnpackFlipYCached: boolean;
  37335. /** @hidden */
  37336. _unpackFlipY(value: boolean): void;
  37337. /** @hidden */
  37338. _getUnpackAlignement(): number;
  37339. private _getTextureTarget;
  37340. /**
  37341. * Update the sampling mode of a given texture
  37342. * @param samplingMode defines the required sampling mode
  37343. * @param texture defines the texture to update
  37344. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37345. */
  37346. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37347. /**
  37348. * Update the sampling mode of a given texture
  37349. * @param texture defines the texture to update
  37350. * @param wrapU defines the texture wrap mode of the u coordinates
  37351. * @param wrapV defines the texture wrap mode of the v coordinates
  37352. * @param wrapR defines the texture wrap mode of the r coordinates
  37353. */
  37354. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37355. /** @hidden */
  37356. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37357. width: number;
  37358. height: number;
  37359. layers?: number;
  37360. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37361. /** @hidden */
  37362. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37363. /** @hidden */
  37364. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37365. /**
  37366. * Update a portion of an internal texture
  37367. * @param texture defines the texture to update
  37368. * @param imageData defines the data to store into the texture
  37369. * @param xOffset defines the x coordinates of the update rectangle
  37370. * @param yOffset defines the y coordinates of the update rectangle
  37371. * @param width defines the width of the update rectangle
  37372. * @param height defines the height of the update rectangle
  37373. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37374. * @param lod defines the lod level to update (0 by default)
  37375. */
  37376. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37377. /** @hidden */
  37378. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37379. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37380. private _prepareWebGLTexture;
  37381. /** @hidden */
  37382. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37383. private _getDepthStencilBuffer;
  37384. /** @hidden */
  37385. _releaseFramebufferObjects(texture: InternalTexture): void;
  37386. /** @hidden */
  37387. _releaseTexture(texture: InternalTexture): void;
  37388. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37389. protected _setProgram(program: WebGLProgram): void;
  37390. protected _boundUniforms: {
  37391. [key: number]: WebGLUniformLocation;
  37392. };
  37393. /**
  37394. * Binds an effect to the webGL context
  37395. * @param effect defines the effect to bind
  37396. */
  37397. bindSamplers(effect: Effect): void;
  37398. private _activateCurrentTexture;
  37399. /** @hidden */
  37400. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37401. /** @hidden */
  37402. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37403. /**
  37404. * Unbind all textures from the webGL context
  37405. */
  37406. unbindAllTextures(): void;
  37407. /**
  37408. * Sets a texture to the according uniform.
  37409. * @param channel The texture channel
  37410. * @param uniform The uniform to set
  37411. * @param texture The texture to apply
  37412. */
  37413. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37414. private _bindSamplerUniformToChannel;
  37415. private _getTextureWrapMode;
  37416. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37417. /**
  37418. * Sets an array of texture to the webGL context
  37419. * @param channel defines the channel where the texture array must be set
  37420. * @param uniform defines the associated uniform location
  37421. * @param textures defines the array of textures to bind
  37422. */
  37423. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37424. /** @hidden */
  37425. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37426. private _setTextureParameterFloat;
  37427. private _setTextureParameterInteger;
  37428. /**
  37429. * Unbind all vertex attributes from the webGL context
  37430. */
  37431. unbindAllAttributes(): void;
  37432. /**
  37433. * 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
  37434. */
  37435. releaseEffects(): void;
  37436. /**
  37437. * Dispose and release all associated resources
  37438. */
  37439. dispose(): void;
  37440. /**
  37441. * Attach a new callback raised when context lost event is fired
  37442. * @param callback defines the callback to call
  37443. */
  37444. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37445. /**
  37446. * Attach a new callback raised when context restored event is fired
  37447. * @param callback defines the callback to call
  37448. */
  37449. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37450. /**
  37451. * Get the current error code of the webGL context
  37452. * @returns the error code
  37453. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37454. */
  37455. getError(): number;
  37456. private _canRenderToFloatFramebuffer;
  37457. private _canRenderToHalfFloatFramebuffer;
  37458. private _canRenderToFramebuffer;
  37459. /** @hidden */
  37460. _getWebGLTextureType(type: number): number;
  37461. /** @hidden */
  37462. _getInternalFormat(format: number): number;
  37463. /** @hidden */
  37464. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37465. /** @hidden */
  37466. _getRGBAMultiSampleBufferFormat(type: number): number;
  37467. /** @hidden */
  37468. _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;
  37469. /**
  37470. * Loads a file from a url
  37471. * @param url url to load
  37472. * @param onSuccess callback called when the file successfully loads
  37473. * @param onProgress callback called while file is loading (if the server supports this mode)
  37474. * @param offlineProvider defines the offline provider for caching
  37475. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37476. * @param onError callback called when the file fails to load
  37477. * @returns a file request object
  37478. * @hidden
  37479. */
  37480. 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;
  37481. /**
  37482. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37483. * @param x defines the x coordinate of the rectangle where pixels must be read
  37484. * @param y defines the y coordinate of the rectangle where pixels must be read
  37485. * @param width defines the width of the rectangle where pixels must be read
  37486. * @param height defines the height of the rectangle where pixels must be read
  37487. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37488. * @returns a Uint8Array containing RGBA colors
  37489. */
  37490. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37491. private static _isSupported;
  37492. /**
  37493. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37494. * @returns true if the engine can be created
  37495. * @ignorenaming
  37496. */
  37497. static isSupported(): boolean;
  37498. /**
  37499. * Find the next highest power of two.
  37500. * @param x Number to start search from.
  37501. * @return Next highest power of two.
  37502. */
  37503. static CeilingPOT(x: number): number;
  37504. /**
  37505. * Find the next lowest power of two.
  37506. * @param x Number to start search from.
  37507. * @return Next lowest power of two.
  37508. */
  37509. static FloorPOT(x: number): number;
  37510. /**
  37511. * Find the nearest power of two.
  37512. * @param x Number to start search from.
  37513. * @return Next nearest power of two.
  37514. */
  37515. static NearestPOT(x: number): number;
  37516. /**
  37517. * Get the closest exponent of two
  37518. * @param value defines the value to approximate
  37519. * @param max defines the maximum value to return
  37520. * @param mode defines how to define the closest value
  37521. * @returns closest exponent of two of the given value
  37522. */
  37523. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37524. /**
  37525. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37526. * @param func - the function to be called
  37527. * @param requester - the object that will request the next frame. Falls back to window.
  37528. * @returns frame number
  37529. */
  37530. static QueueNewFrame(func: () => void, requester?: any): number;
  37531. /**
  37532. * Gets host document
  37533. * @returns the host document object
  37534. */
  37535. getHostDocument(): Nullable<Document>;
  37536. }
  37537. }
  37538. declare module "babylonjs/Maths/sphericalPolynomial" {
  37539. import { Vector3 } from "babylonjs/Maths/math.vector";
  37540. import { Color3 } from "babylonjs/Maths/math.color";
  37541. /**
  37542. * Class representing spherical harmonics coefficients to the 3rd degree
  37543. */
  37544. export class SphericalHarmonics {
  37545. /**
  37546. * Defines whether or not the harmonics have been prescaled for rendering.
  37547. */
  37548. preScaled: boolean;
  37549. /**
  37550. * The l0,0 coefficients of the spherical harmonics
  37551. */
  37552. l00: Vector3;
  37553. /**
  37554. * The l1,-1 coefficients of the spherical harmonics
  37555. */
  37556. l1_1: Vector3;
  37557. /**
  37558. * The l1,0 coefficients of the spherical harmonics
  37559. */
  37560. l10: Vector3;
  37561. /**
  37562. * The l1,1 coefficients of the spherical harmonics
  37563. */
  37564. l11: Vector3;
  37565. /**
  37566. * The l2,-2 coefficients of the spherical harmonics
  37567. */
  37568. l2_2: Vector3;
  37569. /**
  37570. * The l2,-1 coefficients of the spherical harmonics
  37571. */
  37572. l2_1: Vector3;
  37573. /**
  37574. * The l2,0 coefficients of the spherical harmonics
  37575. */
  37576. l20: Vector3;
  37577. /**
  37578. * The l2,1 coefficients of the spherical harmonics
  37579. */
  37580. l21: Vector3;
  37581. /**
  37582. * The l2,2 coefficients of the spherical harmonics
  37583. */
  37584. l22: Vector3;
  37585. /**
  37586. * Adds a light to the spherical harmonics
  37587. * @param direction the direction of the light
  37588. * @param color the color of the light
  37589. * @param deltaSolidAngle the delta solid angle of the light
  37590. */
  37591. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37592. /**
  37593. * Scales the spherical harmonics by the given amount
  37594. * @param scale the amount to scale
  37595. */
  37596. scaleInPlace(scale: number): void;
  37597. /**
  37598. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37599. *
  37600. * ```
  37601. * E_lm = A_l * L_lm
  37602. * ```
  37603. *
  37604. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37605. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37606. * the scaling factors are given in equation 9.
  37607. */
  37608. convertIncidentRadianceToIrradiance(): void;
  37609. /**
  37610. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37611. *
  37612. * ```
  37613. * L = (1/pi) * E * rho
  37614. * ```
  37615. *
  37616. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37617. */
  37618. convertIrradianceToLambertianRadiance(): void;
  37619. /**
  37620. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37621. * required operations at run time.
  37622. *
  37623. * This is simply done by scaling back the SH with Ylm constants parameter.
  37624. * The trigonometric part being applied by the shader at run time.
  37625. */
  37626. preScaleForRendering(): void;
  37627. /**
  37628. * Constructs a spherical harmonics from an array.
  37629. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37630. * @returns the spherical harmonics
  37631. */
  37632. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37633. /**
  37634. * Gets the spherical harmonics from polynomial
  37635. * @param polynomial the spherical polynomial
  37636. * @returns the spherical harmonics
  37637. */
  37638. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37639. }
  37640. /**
  37641. * Class representing spherical polynomial coefficients to the 3rd degree
  37642. */
  37643. export class SphericalPolynomial {
  37644. private _harmonics;
  37645. /**
  37646. * The spherical harmonics used to create the polynomials.
  37647. */
  37648. get preScaledHarmonics(): SphericalHarmonics;
  37649. /**
  37650. * The x coefficients of the spherical polynomial
  37651. */
  37652. x: Vector3;
  37653. /**
  37654. * The y coefficients of the spherical polynomial
  37655. */
  37656. y: Vector3;
  37657. /**
  37658. * The z coefficients of the spherical polynomial
  37659. */
  37660. z: Vector3;
  37661. /**
  37662. * The xx coefficients of the spherical polynomial
  37663. */
  37664. xx: Vector3;
  37665. /**
  37666. * The yy coefficients of the spherical polynomial
  37667. */
  37668. yy: Vector3;
  37669. /**
  37670. * The zz coefficients of the spherical polynomial
  37671. */
  37672. zz: Vector3;
  37673. /**
  37674. * The xy coefficients of the spherical polynomial
  37675. */
  37676. xy: Vector3;
  37677. /**
  37678. * The yz coefficients of the spherical polynomial
  37679. */
  37680. yz: Vector3;
  37681. /**
  37682. * The zx coefficients of the spherical polynomial
  37683. */
  37684. zx: Vector3;
  37685. /**
  37686. * Adds an ambient color to the spherical polynomial
  37687. * @param color the color to add
  37688. */
  37689. addAmbient(color: Color3): void;
  37690. /**
  37691. * Scales the spherical polynomial by the given amount
  37692. * @param scale the amount to scale
  37693. */
  37694. scaleInPlace(scale: number): void;
  37695. /**
  37696. * Gets the spherical polynomial from harmonics
  37697. * @param harmonics the spherical harmonics
  37698. * @returns the spherical polynomial
  37699. */
  37700. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37701. /**
  37702. * Constructs a spherical polynomial from an array.
  37703. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37704. * @returns the spherical polynomial
  37705. */
  37706. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37707. }
  37708. }
  37709. declare module "babylonjs/Materials/Textures/internalTexture" {
  37710. import { Observable } from "babylonjs/Misc/observable";
  37711. import { Nullable, int } from "babylonjs/types";
  37712. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37713. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37714. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37715. /**
  37716. * Defines the source of the internal texture
  37717. */
  37718. export enum InternalTextureSource {
  37719. /**
  37720. * The source of the texture data is unknown
  37721. */
  37722. Unknown = 0,
  37723. /**
  37724. * Texture data comes from an URL
  37725. */
  37726. Url = 1,
  37727. /**
  37728. * Texture data is only used for temporary storage
  37729. */
  37730. Temp = 2,
  37731. /**
  37732. * Texture data comes from raw data (ArrayBuffer)
  37733. */
  37734. Raw = 3,
  37735. /**
  37736. * Texture content is dynamic (video or dynamic texture)
  37737. */
  37738. Dynamic = 4,
  37739. /**
  37740. * Texture content is generated by rendering to it
  37741. */
  37742. RenderTarget = 5,
  37743. /**
  37744. * Texture content is part of a multi render target process
  37745. */
  37746. MultiRenderTarget = 6,
  37747. /**
  37748. * Texture data comes from a cube data file
  37749. */
  37750. Cube = 7,
  37751. /**
  37752. * Texture data comes from a raw cube data
  37753. */
  37754. CubeRaw = 8,
  37755. /**
  37756. * Texture data come from a prefiltered cube data file
  37757. */
  37758. CubePrefiltered = 9,
  37759. /**
  37760. * Texture content is raw 3D data
  37761. */
  37762. Raw3D = 10,
  37763. /**
  37764. * Texture content is raw 2D array data
  37765. */
  37766. Raw2DArray = 11,
  37767. /**
  37768. * Texture content is a depth texture
  37769. */
  37770. Depth = 12,
  37771. /**
  37772. * Texture data comes from a raw cube data encoded with RGBD
  37773. */
  37774. CubeRawRGBD = 13
  37775. }
  37776. /**
  37777. * Class used to store data associated with WebGL texture data for the engine
  37778. * This class should not be used directly
  37779. */
  37780. export class InternalTexture {
  37781. /** @hidden */
  37782. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37783. /**
  37784. * Defines if the texture is ready
  37785. */
  37786. isReady: boolean;
  37787. /**
  37788. * Defines if the texture is a cube texture
  37789. */
  37790. isCube: boolean;
  37791. /**
  37792. * Defines if the texture contains 3D data
  37793. */
  37794. is3D: boolean;
  37795. /**
  37796. * Defines if the texture contains 2D array data
  37797. */
  37798. is2DArray: boolean;
  37799. /**
  37800. * Defines if the texture contains multiview data
  37801. */
  37802. isMultiview: boolean;
  37803. /**
  37804. * Gets the URL used to load this texture
  37805. */
  37806. url: string;
  37807. /**
  37808. * Gets the sampling mode of the texture
  37809. */
  37810. samplingMode: number;
  37811. /**
  37812. * Gets a boolean indicating if the texture needs mipmaps generation
  37813. */
  37814. generateMipMaps: boolean;
  37815. /**
  37816. * Gets the number of samples used by the texture (WebGL2+ only)
  37817. */
  37818. samples: number;
  37819. /**
  37820. * Gets the type of the texture (int, float...)
  37821. */
  37822. type: number;
  37823. /**
  37824. * Gets the format of the texture (RGB, RGBA...)
  37825. */
  37826. format: number;
  37827. /**
  37828. * Observable called when the texture is loaded
  37829. */
  37830. onLoadedObservable: Observable<InternalTexture>;
  37831. /**
  37832. * Gets the width of the texture
  37833. */
  37834. width: number;
  37835. /**
  37836. * Gets the height of the texture
  37837. */
  37838. height: number;
  37839. /**
  37840. * Gets the depth of the texture
  37841. */
  37842. depth: number;
  37843. /**
  37844. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37845. */
  37846. baseWidth: number;
  37847. /**
  37848. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37849. */
  37850. baseHeight: number;
  37851. /**
  37852. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37853. */
  37854. baseDepth: number;
  37855. /**
  37856. * Gets a boolean indicating if the texture is inverted on Y axis
  37857. */
  37858. invertY: boolean;
  37859. /** @hidden */
  37860. _invertVScale: boolean;
  37861. /** @hidden */
  37862. _associatedChannel: number;
  37863. /** @hidden */
  37864. _source: InternalTextureSource;
  37865. /** @hidden */
  37866. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  37867. /** @hidden */
  37868. _bufferView: Nullable<ArrayBufferView>;
  37869. /** @hidden */
  37870. _bufferViewArray: Nullable<ArrayBufferView[]>;
  37871. /** @hidden */
  37872. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  37873. /** @hidden */
  37874. _size: number;
  37875. /** @hidden */
  37876. _extension: string;
  37877. /** @hidden */
  37878. _files: Nullable<string[]>;
  37879. /** @hidden */
  37880. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  37881. /** @hidden */
  37882. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  37883. /** @hidden */
  37884. _framebuffer: Nullable<WebGLFramebuffer>;
  37885. /** @hidden */
  37886. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  37887. /** @hidden */
  37888. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  37889. /** @hidden */
  37890. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  37891. /** @hidden */
  37892. _attachments: Nullable<number[]>;
  37893. /** @hidden */
  37894. _textureArray: Nullable<InternalTexture[]>;
  37895. /** @hidden */
  37896. _cachedCoordinatesMode: Nullable<number>;
  37897. /** @hidden */
  37898. _cachedWrapU: Nullable<number>;
  37899. /** @hidden */
  37900. _cachedWrapV: Nullable<number>;
  37901. /** @hidden */
  37902. _cachedWrapR: Nullable<number>;
  37903. /** @hidden */
  37904. _cachedAnisotropicFilteringLevel: Nullable<number>;
  37905. /** @hidden */
  37906. _isDisabled: boolean;
  37907. /** @hidden */
  37908. _compression: Nullable<string>;
  37909. /** @hidden */
  37910. _generateStencilBuffer: boolean;
  37911. /** @hidden */
  37912. _generateDepthBuffer: boolean;
  37913. /** @hidden */
  37914. _comparisonFunction: number;
  37915. /** @hidden */
  37916. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  37917. /** @hidden */
  37918. _lodGenerationScale: number;
  37919. /** @hidden */
  37920. _lodGenerationOffset: number;
  37921. /** @hidden */
  37922. _depthStencilTexture: Nullable<InternalTexture>;
  37923. /** @hidden */
  37924. _colorTextureArray: Nullable<WebGLTexture>;
  37925. /** @hidden */
  37926. _depthStencilTextureArray: Nullable<WebGLTexture>;
  37927. /** @hidden */
  37928. _lodTextureHigh: Nullable<BaseTexture>;
  37929. /** @hidden */
  37930. _lodTextureMid: Nullable<BaseTexture>;
  37931. /** @hidden */
  37932. _lodTextureLow: Nullable<BaseTexture>;
  37933. /** @hidden */
  37934. _isRGBD: boolean;
  37935. /** @hidden */
  37936. _linearSpecularLOD: boolean;
  37937. /** @hidden */
  37938. _irradianceTexture: Nullable<BaseTexture>;
  37939. /** @hidden */
  37940. _webGLTexture: Nullable<WebGLTexture>;
  37941. /** @hidden */
  37942. _references: number;
  37943. private _engine;
  37944. /**
  37945. * Gets the Engine the texture belongs to.
  37946. * @returns The babylon engine
  37947. */
  37948. getEngine(): ThinEngine;
  37949. /**
  37950. * Gets the data source type of the texture
  37951. */
  37952. get source(): InternalTextureSource;
  37953. /**
  37954. * Creates a new InternalTexture
  37955. * @param engine defines the engine to use
  37956. * @param source defines the type of data that will be used
  37957. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37958. */
  37959. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  37960. /**
  37961. * Increments the number of references (ie. the number of Texture that point to it)
  37962. */
  37963. incrementReferences(): void;
  37964. /**
  37965. * Change the size of the texture (not the size of the content)
  37966. * @param width defines the new width
  37967. * @param height defines the new height
  37968. * @param depth defines the new depth (1 by default)
  37969. */
  37970. updateSize(width: int, height: int, depth?: int): void;
  37971. /** @hidden */
  37972. _rebuild(): void;
  37973. /** @hidden */
  37974. _swapAndDie(target: InternalTexture): void;
  37975. /**
  37976. * Dispose the current allocated resources
  37977. */
  37978. dispose(): void;
  37979. }
  37980. }
  37981. declare module "babylonjs/Audio/analyser" {
  37982. import { Scene } from "babylonjs/scene";
  37983. /**
  37984. * Class used to work with sound analyzer using fast fourier transform (FFT)
  37985. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37986. */
  37987. export class Analyser {
  37988. /**
  37989. * Gets or sets the smoothing
  37990. * @ignorenaming
  37991. */
  37992. SMOOTHING: number;
  37993. /**
  37994. * Gets or sets the FFT table size
  37995. * @ignorenaming
  37996. */
  37997. FFT_SIZE: number;
  37998. /**
  37999. * Gets or sets the bar graph amplitude
  38000. * @ignorenaming
  38001. */
  38002. BARGRAPHAMPLITUDE: number;
  38003. /**
  38004. * Gets or sets the position of the debug canvas
  38005. * @ignorenaming
  38006. */
  38007. DEBUGCANVASPOS: {
  38008. x: number;
  38009. y: number;
  38010. };
  38011. /**
  38012. * Gets or sets the debug canvas size
  38013. * @ignorenaming
  38014. */
  38015. DEBUGCANVASSIZE: {
  38016. width: number;
  38017. height: number;
  38018. };
  38019. private _byteFreqs;
  38020. private _byteTime;
  38021. private _floatFreqs;
  38022. private _webAudioAnalyser;
  38023. private _debugCanvas;
  38024. private _debugCanvasContext;
  38025. private _scene;
  38026. private _registerFunc;
  38027. private _audioEngine;
  38028. /**
  38029. * Creates a new analyser
  38030. * @param scene defines hosting scene
  38031. */
  38032. constructor(scene: Scene);
  38033. /**
  38034. * Get the number of data values you will have to play with for the visualization
  38035. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38036. * @returns a number
  38037. */
  38038. getFrequencyBinCount(): number;
  38039. /**
  38040. * Gets the current frequency data as a byte array
  38041. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38042. * @returns a Uint8Array
  38043. */
  38044. getByteFrequencyData(): Uint8Array;
  38045. /**
  38046. * Gets the current waveform as a byte array
  38047. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38048. * @returns a Uint8Array
  38049. */
  38050. getByteTimeDomainData(): Uint8Array;
  38051. /**
  38052. * Gets the current frequency data as a float array
  38053. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38054. * @returns a Float32Array
  38055. */
  38056. getFloatFrequencyData(): Float32Array;
  38057. /**
  38058. * Renders the debug canvas
  38059. */
  38060. drawDebugCanvas(): void;
  38061. /**
  38062. * Stops rendering the debug canvas and removes it
  38063. */
  38064. stopDebugCanvas(): void;
  38065. /**
  38066. * Connects two audio nodes
  38067. * @param inputAudioNode defines first node to connect
  38068. * @param outputAudioNode defines second node to connect
  38069. */
  38070. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38071. /**
  38072. * Releases all associated resources
  38073. */
  38074. dispose(): void;
  38075. }
  38076. }
  38077. declare module "babylonjs/Audio/audioEngine" {
  38078. import { IDisposable } from "babylonjs/scene";
  38079. import { Analyser } from "babylonjs/Audio/analyser";
  38080. import { Nullable } from "babylonjs/types";
  38081. import { Observable } from "babylonjs/Misc/observable";
  38082. /**
  38083. * This represents an audio engine and it is responsible
  38084. * to play, synchronize and analyse sounds throughout the application.
  38085. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38086. */
  38087. export interface IAudioEngine extends IDisposable {
  38088. /**
  38089. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38090. */
  38091. readonly canUseWebAudio: boolean;
  38092. /**
  38093. * Gets the current AudioContext if available.
  38094. */
  38095. readonly audioContext: Nullable<AudioContext>;
  38096. /**
  38097. * The master gain node defines the global audio volume of your audio engine.
  38098. */
  38099. readonly masterGain: GainNode;
  38100. /**
  38101. * Gets whether or not mp3 are supported by your browser.
  38102. */
  38103. readonly isMP3supported: boolean;
  38104. /**
  38105. * Gets whether or not ogg are supported by your browser.
  38106. */
  38107. readonly isOGGsupported: boolean;
  38108. /**
  38109. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38110. * @ignoreNaming
  38111. */
  38112. WarnedWebAudioUnsupported: boolean;
  38113. /**
  38114. * Defines if the audio engine relies on a custom unlocked button.
  38115. * In this case, the embedded button will not be displayed.
  38116. */
  38117. useCustomUnlockedButton: boolean;
  38118. /**
  38119. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38120. */
  38121. readonly unlocked: boolean;
  38122. /**
  38123. * Event raised when audio has been unlocked on the browser.
  38124. */
  38125. onAudioUnlockedObservable: Observable<AudioEngine>;
  38126. /**
  38127. * Event raised when audio has been locked on the browser.
  38128. */
  38129. onAudioLockedObservable: Observable<AudioEngine>;
  38130. /**
  38131. * Flags the audio engine in Locked state.
  38132. * This happens due to new browser policies preventing audio to autoplay.
  38133. */
  38134. lock(): void;
  38135. /**
  38136. * Unlocks the audio engine once a user action has been done on the dom.
  38137. * This is helpful to resume play once browser policies have been satisfied.
  38138. */
  38139. unlock(): void;
  38140. /**
  38141. * Gets the global volume sets on the master gain.
  38142. * @returns the global volume if set or -1 otherwise
  38143. */
  38144. getGlobalVolume(): number;
  38145. /**
  38146. * Sets the global volume of your experience (sets on the master gain).
  38147. * @param newVolume Defines the new global volume of the application
  38148. */
  38149. setGlobalVolume(newVolume: number): void;
  38150. /**
  38151. * Connect the audio engine to an audio analyser allowing some amazing
  38152. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38153. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38154. * @param analyser The analyser to connect to the engine
  38155. */
  38156. connectToAnalyser(analyser: Analyser): void;
  38157. }
  38158. /**
  38159. * This represents the default audio engine used in babylon.
  38160. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38161. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38162. */
  38163. export class AudioEngine implements IAudioEngine {
  38164. private _audioContext;
  38165. private _audioContextInitialized;
  38166. private _muteButton;
  38167. private _hostElement;
  38168. /**
  38169. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38170. */
  38171. canUseWebAudio: boolean;
  38172. /**
  38173. * The master gain node defines the global audio volume of your audio engine.
  38174. */
  38175. masterGain: GainNode;
  38176. /**
  38177. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38178. * @ignoreNaming
  38179. */
  38180. WarnedWebAudioUnsupported: boolean;
  38181. /**
  38182. * Gets whether or not mp3 are supported by your browser.
  38183. */
  38184. isMP3supported: boolean;
  38185. /**
  38186. * Gets whether or not ogg are supported by your browser.
  38187. */
  38188. isOGGsupported: boolean;
  38189. /**
  38190. * Gets whether audio has been unlocked on the device.
  38191. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38192. * a user interaction has happened.
  38193. */
  38194. unlocked: boolean;
  38195. /**
  38196. * Defines if the audio engine relies on a custom unlocked button.
  38197. * In this case, the embedded button will not be displayed.
  38198. */
  38199. useCustomUnlockedButton: boolean;
  38200. /**
  38201. * Event raised when audio has been unlocked on the browser.
  38202. */
  38203. onAudioUnlockedObservable: Observable<AudioEngine>;
  38204. /**
  38205. * Event raised when audio has been locked on the browser.
  38206. */
  38207. onAudioLockedObservable: Observable<AudioEngine>;
  38208. /**
  38209. * Gets the current AudioContext if available.
  38210. */
  38211. get audioContext(): Nullable<AudioContext>;
  38212. private _connectedAnalyser;
  38213. /**
  38214. * Instantiates a new audio engine.
  38215. *
  38216. * There should be only one per page as some browsers restrict the number
  38217. * of audio contexts you can create.
  38218. * @param hostElement defines the host element where to display the mute icon if necessary
  38219. */
  38220. constructor(hostElement?: Nullable<HTMLElement>);
  38221. /**
  38222. * Flags the audio engine in Locked state.
  38223. * This happens due to new browser policies preventing audio to autoplay.
  38224. */
  38225. lock(): void;
  38226. /**
  38227. * Unlocks the audio engine once a user action has been done on the dom.
  38228. * This is helpful to resume play once browser policies have been satisfied.
  38229. */
  38230. unlock(): void;
  38231. private _resumeAudioContext;
  38232. private _initializeAudioContext;
  38233. private _tryToRun;
  38234. private _triggerRunningState;
  38235. private _triggerSuspendedState;
  38236. private _displayMuteButton;
  38237. private _moveButtonToTopLeft;
  38238. private _onResize;
  38239. private _hideMuteButton;
  38240. /**
  38241. * Destroy and release the resources associated with the audio ccontext.
  38242. */
  38243. dispose(): void;
  38244. /**
  38245. * Gets the global volume sets on the master gain.
  38246. * @returns the global volume if set or -1 otherwise
  38247. */
  38248. getGlobalVolume(): number;
  38249. /**
  38250. * Sets the global volume of your experience (sets on the master gain).
  38251. * @param newVolume Defines the new global volume of the application
  38252. */
  38253. setGlobalVolume(newVolume: number): void;
  38254. /**
  38255. * Connect the audio engine to an audio analyser allowing some amazing
  38256. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38257. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38258. * @param analyser The analyser to connect to the engine
  38259. */
  38260. connectToAnalyser(analyser: Analyser): void;
  38261. }
  38262. }
  38263. declare module "babylonjs/Loading/loadingScreen" {
  38264. /**
  38265. * Interface used to present a loading screen while loading a scene
  38266. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38267. */
  38268. export interface ILoadingScreen {
  38269. /**
  38270. * Function called to display the loading screen
  38271. */
  38272. displayLoadingUI: () => void;
  38273. /**
  38274. * Function called to hide the loading screen
  38275. */
  38276. hideLoadingUI: () => void;
  38277. /**
  38278. * Gets or sets the color to use for the background
  38279. */
  38280. loadingUIBackgroundColor: string;
  38281. /**
  38282. * Gets or sets the text to display while loading
  38283. */
  38284. loadingUIText: string;
  38285. }
  38286. /**
  38287. * Class used for the default loading screen
  38288. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38289. */
  38290. export class DefaultLoadingScreen implements ILoadingScreen {
  38291. private _renderingCanvas;
  38292. private _loadingText;
  38293. private _loadingDivBackgroundColor;
  38294. private _loadingDiv;
  38295. private _loadingTextDiv;
  38296. /** Gets or sets the logo url to use for the default loading screen */
  38297. static DefaultLogoUrl: string;
  38298. /** Gets or sets the spinner url to use for the default loading screen */
  38299. static DefaultSpinnerUrl: string;
  38300. /**
  38301. * Creates a new default loading screen
  38302. * @param _renderingCanvas defines the canvas used to render the scene
  38303. * @param _loadingText defines the default text to display
  38304. * @param _loadingDivBackgroundColor defines the default background color
  38305. */
  38306. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38307. /**
  38308. * Function called to display the loading screen
  38309. */
  38310. displayLoadingUI(): void;
  38311. /**
  38312. * Function called to hide the loading screen
  38313. */
  38314. hideLoadingUI(): void;
  38315. /**
  38316. * Gets or sets the text to display while loading
  38317. */
  38318. set loadingUIText(text: string);
  38319. get loadingUIText(): string;
  38320. /**
  38321. * Gets or sets the color to use for the background
  38322. */
  38323. get loadingUIBackgroundColor(): string;
  38324. set loadingUIBackgroundColor(color: string);
  38325. private _resizeLoadingUI;
  38326. }
  38327. }
  38328. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38329. /**
  38330. * Interface for any object that can request an animation frame
  38331. */
  38332. export interface ICustomAnimationFrameRequester {
  38333. /**
  38334. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38335. */
  38336. renderFunction?: Function;
  38337. /**
  38338. * Called to request the next frame to render to
  38339. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38340. */
  38341. requestAnimationFrame: Function;
  38342. /**
  38343. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38344. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38345. */
  38346. requestID?: number;
  38347. }
  38348. }
  38349. declare module "babylonjs/Misc/performanceMonitor" {
  38350. /**
  38351. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38352. */
  38353. export class PerformanceMonitor {
  38354. private _enabled;
  38355. private _rollingFrameTime;
  38356. private _lastFrameTimeMs;
  38357. /**
  38358. * constructor
  38359. * @param frameSampleSize The number of samples required to saturate the sliding window
  38360. */
  38361. constructor(frameSampleSize?: number);
  38362. /**
  38363. * Samples current frame
  38364. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38365. */
  38366. sampleFrame(timeMs?: number): void;
  38367. /**
  38368. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38369. */
  38370. get averageFrameTime(): number;
  38371. /**
  38372. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38373. */
  38374. get averageFrameTimeVariance(): number;
  38375. /**
  38376. * Returns the frame time of the most recent frame
  38377. */
  38378. get instantaneousFrameTime(): number;
  38379. /**
  38380. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38381. */
  38382. get averageFPS(): number;
  38383. /**
  38384. * Returns the average framerate in frames per second using the most recent frame time
  38385. */
  38386. get instantaneousFPS(): number;
  38387. /**
  38388. * Returns true if enough samples have been taken to completely fill the sliding window
  38389. */
  38390. get isSaturated(): boolean;
  38391. /**
  38392. * Enables contributions to the sliding window sample set
  38393. */
  38394. enable(): void;
  38395. /**
  38396. * Disables contributions to the sliding window sample set
  38397. * Samples will not be interpolated over the disabled period
  38398. */
  38399. disable(): void;
  38400. /**
  38401. * Returns true if sampling is enabled
  38402. */
  38403. get isEnabled(): boolean;
  38404. /**
  38405. * Resets performance monitor
  38406. */
  38407. reset(): void;
  38408. }
  38409. /**
  38410. * RollingAverage
  38411. *
  38412. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38413. */
  38414. export class RollingAverage {
  38415. /**
  38416. * Current average
  38417. */
  38418. average: number;
  38419. /**
  38420. * Current variance
  38421. */
  38422. variance: number;
  38423. protected _samples: Array<number>;
  38424. protected _sampleCount: number;
  38425. protected _pos: number;
  38426. protected _m2: number;
  38427. /**
  38428. * constructor
  38429. * @param length The number of samples required to saturate the sliding window
  38430. */
  38431. constructor(length: number);
  38432. /**
  38433. * Adds a sample to the sample set
  38434. * @param v The sample value
  38435. */
  38436. add(v: number): void;
  38437. /**
  38438. * Returns previously added values or null if outside of history or outside the sliding window domain
  38439. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38440. * @return Value previously recorded with add() or null if outside of range
  38441. */
  38442. history(i: number): number;
  38443. /**
  38444. * Returns true if enough samples have been taken to completely fill the sliding window
  38445. * @return true if sample-set saturated
  38446. */
  38447. isSaturated(): boolean;
  38448. /**
  38449. * Resets the rolling average (equivalent to 0 samples taken so far)
  38450. */
  38451. reset(): void;
  38452. /**
  38453. * Wraps a value around the sample range boundaries
  38454. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38455. * @return Wrapped position in sample range
  38456. */
  38457. protected _wrapPosition(i: number): number;
  38458. }
  38459. }
  38460. declare module "babylonjs/Misc/perfCounter" {
  38461. /**
  38462. * This class is used to track a performance counter which is number based.
  38463. * The user has access to many properties which give statistics of different nature.
  38464. *
  38465. * The implementer can track two kinds of Performance Counter: time and count.
  38466. * 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.
  38467. * 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.
  38468. */
  38469. export class PerfCounter {
  38470. /**
  38471. * Gets or sets a global boolean to turn on and off all the counters
  38472. */
  38473. static Enabled: boolean;
  38474. /**
  38475. * Returns the smallest value ever
  38476. */
  38477. get min(): number;
  38478. /**
  38479. * Returns the biggest value ever
  38480. */
  38481. get max(): number;
  38482. /**
  38483. * Returns the average value since the performance counter is running
  38484. */
  38485. get average(): number;
  38486. /**
  38487. * Returns the average value of the last second the counter was monitored
  38488. */
  38489. get lastSecAverage(): number;
  38490. /**
  38491. * Returns the current value
  38492. */
  38493. get current(): number;
  38494. /**
  38495. * Gets the accumulated total
  38496. */
  38497. get total(): number;
  38498. /**
  38499. * Gets the total value count
  38500. */
  38501. get count(): number;
  38502. /**
  38503. * Creates a new counter
  38504. */
  38505. constructor();
  38506. /**
  38507. * Call this method to start monitoring a new frame.
  38508. * 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.
  38509. */
  38510. fetchNewFrame(): void;
  38511. /**
  38512. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38513. * @param newCount the count value to add to the monitored count
  38514. * @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.
  38515. */
  38516. addCount(newCount: number, fetchResult: boolean): void;
  38517. /**
  38518. * Start monitoring this performance counter
  38519. */
  38520. beginMonitoring(): void;
  38521. /**
  38522. * Compute the time lapsed since the previous beginMonitoring() call.
  38523. * @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
  38524. */
  38525. endMonitoring(newFrame?: boolean): void;
  38526. private _fetchResult;
  38527. private _startMonitoringTime;
  38528. private _min;
  38529. private _max;
  38530. private _average;
  38531. private _current;
  38532. private _totalValueCount;
  38533. private _totalAccumulated;
  38534. private _lastSecAverage;
  38535. private _lastSecAccumulated;
  38536. private _lastSecTime;
  38537. private _lastSecValueCount;
  38538. }
  38539. }
  38540. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38541. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38542. import { Nullable } from "babylonjs/types";
  38543. module "babylonjs/Engines/thinEngine" {
  38544. interface ThinEngine {
  38545. /** @hidden */
  38546. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38547. }
  38548. }
  38549. }
  38550. declare module "babylonjs/Engines/engine" {
  38551. import { Observable } from "babylonjs/Misc/observable";
  38552. import { Nullable } from "babylonjs/types";
  38553. import { Scene } from "babylonjs/scene";
  38554. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38555. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38556. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38557. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38558. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38559. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38560. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38561. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38562. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38563. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38564. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38565. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38566. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38567. import "babylonjs/Engines/Extensions/engine.alpha";
  38568. import "babylonjs/Engines/Extensions/engine.readTexture";
  38569. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38570. import { Material } from "babylonjs/Materials/material";
  38571. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38572. /**
  38573. * Defines the interface used by display changed events
  38574. */
  38575. export interface IDisplayChangedEventArgs {
  38576. /** Gets the vrDisplay object (if any) */
  38577. vrDisplay: Nullable<any>;
  38578. /** Gets a boolean indicating if webVR is supported */
  38579. vrSupported: boolean;
  38580. }
  38581. /**
  38582. * Defines the interface used by objects containing a viewport (like a camera)
  38583. */
  38584. interface IViewportOwnerLike {
  38585. /**
  38586. * Gets or sets the viewport
  38587. */
  38588. viewport: IViewportLike;
  38589. }
  38590. /**
  38591. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38592. */
  38593. export class Engine extends ThinEngine {
  38594. /** Defines that alpha blending is disabled */
  38595. static readonly ALPHA_DISABLE: number;
  38596. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38597. static readonly ALPHA_ADD: number;
  38598. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38599. static readonly ALPHA_COMBINE: number;
  38600. /** Defines that alpha blending to DEST - SRC * DEST */
  38601. static readonly ALPHA_SUBTRACT: number;
  38602. /** Defines that alpha blending to SRC * DEST */
  38603. static readonly ALPHA_MULTIPLY: number;
  38604. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38605. static readonly ALPHA_MAXIMIZED: number;
  38606. /** Defines that alpha blending to SRC + DEST */
  38607. static readonly ALPHA_ONEONE: number;
  38608. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38609. static readonly ALPHA_PREMULTIPLIED: number;
  38610. /**
  38611. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38612. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38613. */
  38614. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38615. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38616. static readonly ALPHA_INTERPOLATE: number;
  38617. /**
  38618. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38619. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38620. */
  38621. static readonly ALPHA_SCREENMODE: number;
  38622. /** Defines that the ressource is not delayed*/
  38623. static readonly DELAYLOADSTATE_NONE: number;
  38624. /** Defines that the ressource was successfully delay loaded */
  38625. static readonly DELAYLOADSTATE_LOADED: number;
  38626. /** Defines that the ressource is currently delay loading */
  38627. static readonly DELAYLOADSTATE_LOADING: number;
  38628. /** Defines that the ressource is delayed and has not started loading */
  38629. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38630. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38631. static readonly NEVER: number;
  38632. /** 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 */
  38633. static readonly ALWAYS: number;
  38634. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38635. static readonly LESS: number;
  38636. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38637. static readonly EQUAL: number;
  38638. /** 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 */
  38639. static readonly LEQUAL: number;
  38640. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38641. static readonly GREATER: number;
  38642. /** 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 */
  38643. static readonly GEQUAL: number;
  38644. /** 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 */
  38645. static readonly NOTEQUAL: number;
  38646. /** Passed to stencilOperation to specify that stencil value must be kept */
  38647. static readonly KEEP: number;
  38648. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38649. static readonly REPLACE: number;
  38650. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38651. static readonly INCR: number;
  38652. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38653. static readonly DECR: number;
  38654. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38655. static readonly INVERT: number;
  38656. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38657. static readonly INCR_WRAP: number;
  38658. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38659. static readonly DECR_WRAP: number;
  38660. /** Texture is not repeating outside of 0..1 UVs */
  38661. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38662. /** Texture is repeating outside of 0..1 UVs */
  38663. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38664. /** Texture is repeating and mirrored */
  38665. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38666. /** ALPHA */
  38667. static readonly TEXTUREFORMAT_ALPHA: number;
  38668. /** LUMINANCE */
  38669. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38670. /** LUMINANCE_ALPHA */
  38671. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38672. /** RGB */
  38673. static readonly TEXTUREFORMAT_RGB: number;
  38674. /** RGBA */
  38675. static readonly TEXTUREFORMAT_RGBA: number;
  38676. /** RED */
  38677. static readonly TEXTUREFORMAT_RED: number;
  38678. /** RED (2nd reference) */
  38679. static readonly TEXTUREFORMAT_R: number;
  38680. /** RG */
  38681. static readonly TEXTUREFORMAT_RG: number;
  38682. /** RED_INTEGER */
  38683. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38684. /** RED_INTEGER (2nd reference) */
  38685. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38686. /** RG_INTEGER */
  38687. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38688. /** RGB_INTEGER */
  38689. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38690. /** RGBA_INTEGER */
  38691. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38692. /** UNSIGNED_BYTE */
  38693. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38694. /** UNSIGNED_BYTE (2nd reference) */
  38695. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38696. /** FLOAT */
  38697. static readonly TEXTURETYPE_FLOAT: number;
  38698. /** HALF_FLOAT */
  38699. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38700. /** BYTE */
  38701. static readonly TEXTURETYPE_BYTE: number;
  38702. /** SHORT */
  38703. static readonly TEXTURETYPE_SHORT: number;
  38704. /** UNSIGNED_SHORT */
  38705. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38706. /** INT */
  38707. static readonly TEXTURETYPE_INT: number;
  38708. /** UNSIGNED_INT */
  38709. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38710. /** UNSIGNED_SHORT_4_4_4_4 */
  38711. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38712. /** UNSIGNED_SHORT_5_5_5_1 */
  38713. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38714. /** UNSIGNED_SHORT_5_6_5 */
  38715. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38716. /** UNSIGNED_INT_2_10_10_10_REV */
  38717. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38718. /** UNSIGNED_INT_24_8 */
  38719. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38720. /** UNSIGNED_INT_10F_11F_11F_REV */
  38721. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38722. /** UNSIGNED_INT_5_9_9_9_REV */
  38723. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38724. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38725. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38726. /** nearest is mag = nearest and min = nearest and mip = linear */
  38727. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38728. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38729. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38730. /** Trilinear is mag = linear and min = linear and mip = linear */
  38731. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38732. /** nearest is mag = nearest and min = nearest and mip = linear */
  38733. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38734. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38735. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38736. /** Trilinear is mag = linear and min = linear and mip = linear */
  38737. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38738. /** mag = nearest and min = nearest and mip = nearest */
  38739. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38740. /** mag = nearest and min = linear and mip = nearest */
  38741. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38742. /** mag = nearest and min = linear and mip = linear */
  38743. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38744. /** mag = nearest and min = linear and mip = none */
  38745. static readonly TEXTURE_NEAREST_LINEAR: number;
  38746. /** mag = nearest and min = nearest and mip = none */
  38747. static readonly TEXTURE_NEAREST_NEAREST: number;
  38748. /** mag = linear and min = nearest and mip = nearest */
  38749. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38750. /** mag = linear and min = nearest and mip = linear */
  38751. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38752. /** mag = linear and min = linear and mip = none */
  38753. static readonly TEXTURE_LINEAR_LINEAR: number;
  38754. /** mag = linear and min = nearest and mip = none */
  38755. static readonly TEXTURE_LINEAR_NEAREST: number;
  38756. /** Explicit coordinates mode */
  38757. static readonly TEXTURE_EXPLICIT_MODE: number;
  38758. /** Spherical coordinates mode */
  38759. static readonly TEXTURE_SPHERICAL_MODE: number;
  38760. /** Planar coordinates mode */
  38761. static readonly TEXTURE_PLANAR_MODE: number;
  38762. /** Cubic coordinates mode */
  38763. static readonly TEXTURE_CUBIC_MODE: number;
  38764. /** Projection coordinates mode */
  38765. static readonly TEXTURE_PROJECTION_MODE: number;
  38766. /** Skybox coordinates mode */
  38767. static readonly TEXTURE_SKYBOX_MODE: number;
  38768. /** Inverse Cubic coordinates mode */
  38769. static readonly TEXTURE_INVCUBIC_MODE: number;
  38770. /** Equirectangular coordinates mode */
  38771. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38772. /** Equirectangular Fixed coordinates mode */
  38773. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38774. /** Equirectangular Fixed Mirrored coordinates mode */
  38775. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38776. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38777. static readonly SCALEMODE_FLOOR: number;
  38778. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38779. static readonly SCALEMODE_NEAREST: number;
  38780. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38781. static readonly SCALEMODE_CEILING: number;
  38782. /**
  38783. * Returns the current npm package of the sdk
  38784. */
  38785. static get NpmPackage(): string;
  38786. /**
  38787. * Returns the current version of the framework
  38788. */
  38789. static get Version(): string;
  38790. /** Gets the list of created engines */
  38791. static get Instances(): Engine[];
  38792. /**
  38793. * Gets the latest created engine
  38794. */
  38795. static get LastCreatedEngine(): Nullable<Engine>;
  38796. /**
  38797. * Gets the latest created scene
  38798. */
  38799. static get LastCreatedScene(): Nullable<Scene>;
  38800. /**
  38801. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38802. * @param flag defines which part of the materials must be marked as dirty
  38803. * @param predicate defines a predicate used to filter which materials should be affected
  38804. */
  38805. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38806. /**
  38807. * Method called to create the default loading screen.
  38808. * This can be overriden in your own app.
  38809. * @param canvas The rendering canvas element
  38810. * @returns The loading screen
  38811. */
  38812. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38813. /**
  38814. * Method called to create the default rescale post process on each engine.
  38815. */
  38816. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38817. /**
  38818. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38819. **/
  38820. enableOfflineSupport: boolean;
  38821. /**
  38822. * 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)
  38823. **/
  38824. disableManifestCheck: boolean;
  38825. /**
  38826. * Gets the list of created scenes
  38827. */
  38828. scenes: Scene[];
  38829. /**
  38830. * Event raised when a new scene is created
  38831. */
  38832. onNewSceneAddedObservable: Observable<Scene>;
  38833. /**
  38834. * Gets the list of created postprocesses
  38835. */
  38836. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38837. /**
  38838. * Gets a boolean indicating if the pointer is currently locked
  38839. */
  38840. isPointerLock: boolean;
  38841. /**
  38842. * Observable event triggered each time the rendering canvas is resized
  38843. */
  38844. onResizeObservable: Observable<Engine>;
  38845. /**
  38846. * Observable event triggered each time the canvas loses focus
  38847. */
  38848. onCanvasBlurObservable: Observable<Engine>;
  38849. /**
  38850. * Observable event triggered each time the canvas gains focus
  38851. */
  38852. onCanvasFocusObservable: Observable<Engine>;
  38853. /**
  38854. * Observable event triggered each time the canvas receives pointerout event
  38855. */
  38856. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38857. /**
  38858. * Observable raised when the engine begins a new frame
  38859. */
  38860. onBeginFrameObservable: Observable<Engine>;
  38861. /**
  38862. * If set, will be used to request the next animation frame for the render loop
  38863. */
  38864. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  38865. /**
  38866. * Observable raised when the engine ends the current frame
  38867. */
  38868. onEndFrameObservable: Observable<Engine>;
  38869. /**
  38870. * Observable raised when the engine is about to compile a shader
  38871. */
  38872. onBeforeShaderCompilationObservable: Observable<Engine>;
  38873. /**
  38874. * Observable raised when the engine has jsut compiled a shader
  38875. */
  38876. onAfterShaderCompilationObservable: Observable<Engine>;
  38877. /**
  38878. * Gets the audio engine
  38879. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38880. * @ignorenaming
  38881. */
  38882. static audioEngine: IAudioEngine;
  38883. /**
  38884. * Default AudioEngine factory responsible of creating the Audio Engine.
  38885. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  38886. */
  38887. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  38888. /**
  38889. * Default offline support factory responsible of creating a tool used to store data locally.
  38890. * By default, this will create a Database object if the workload has been embedded.
  38891. */
  38892. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  38893. private _loadingScreen;
  38894. private _pointerLockRequested;
  38895. private _rescalePostProcess;
  38896. private _deterministicLockstep;
  38897. private _lockstepMaxSteps;
  38898. private _timeStep;
  38899. protected get _supportsHardwareTextureRescaling(): boolean;
  38900. private _fps;
  38901. private _deltaTime;
  38902. /** @hidden */
  38903. _drawCalls: PerfCounter;
  38904. /** 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 */
  38905. canvasTabIndex: number;
  38906. /**
  38907. * Turn this value on if you want to pause FPS computation when in background
  38908. */
  38909. disablePerformanceMonitorInBackground: boolean;
  38910. private _performanceMonitor;
  38911. /**
  38912. * Gets the performance monitor attached to this engine
  38913. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  38914. */
  38915. get performanceMonitor(): PerformanceMonitor;
  38916. private _onFocus;
  38917. private _onBlur;
  38918. private _onCanvasPointerOut;
  38919. private _onCanvasBlur;
  38920. private _onCanvasFocus;
  38921. private _onFullscreenChange;
  38922. private _onPointerLockChange;
  38923. /**
  38924. * Gets the HTML element used to attach event listeners
  38925. * @returns a HTML element
  38926. */
  38927. getInputElement(): Nullable<HTMLElement>;
  38928. /**
  38929. * Creates a new engine
  38930. * @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
  38931. * @param antialias defines enable antialiasing (default: false)
  38932. * @param options defines further options to be sent to the getContext() function
  38933. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38934. */
  38935. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38936. /**
  38937. * Gets current aspect ratio
  38938. * @param viewportOwner defines the camera to use to get the aspect ratio
  38939. * @param useScreen defines if screen size must be used (or the current render target if any)
  38940. * @returns a number defining the aspect ratio
  38941. */
  38942. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  38943. /**
  38944. * Gets current screen aspect ratio
  38945. * @returns a number defining the aspect ratio
  38946. */
  38947. getScreenAspectRatio(): number;
  38948. /**
  38949. * Gets the client rect of the HTML canvas attached with the current webGL context
  38950. * @returns a client rectanglee
  38951. */
  38952. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  38953. /**
  38954. * Gets the client rect of the HTML element used for events
  38955. * @returns a client rectanglee
  38956. */
  38957. getInputElementClientRect(): Nullable<ClientRect>;
  38958. /**
  38959. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  38960. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38961. * @returns true if engine is in deterministic lock step mode
  38962. */
  38963. isDeterministicLockStep(): boolean;
  38964. /**
  38965. * Gets the max steps when engine is running in deterministic lock step
  38966. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38967. * @returns the max steps
  38968. */
  38969. getLockstepMaxSteps(): number;
  38970. /**
  38971. * Returns the time in ms between steps when using deterministic lock step.
  38972. * @returns time step in (ms)
  38973. */
  38974. getTimeStep(): number;
  38975. /**
  38976. * Force the mipmap generation for the given render target texture
  38977. * @param texture defines the render target texture to use
  38978. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  38979. */
  38980. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  38981. /** States */
  38982. /**
  38983. * Set various states to the webGL context
  38984. * @param culling defines backface culling state
  38985. * @param zOffset defines the value to apply to zOffset (0 by default)
  38986. * @param force defines if states must be applied even if cache is up to date
  38987. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  38988. */
  38989. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  38990. /**
  38991. * Set the z offset to apply to current rendering
  38992. * @param value defines the offset to apply
  38993. */
  38994. setZOffset(value: number): void;
  38995. /**
  38996. * Gets the current value of the zOffset
  38997. * @returns the current zOffset state
  38998. */
  38999. getZOffset(): number;
  39000. /**
  39001. * Enable or disable depth buffering
  39002. * @param enable defines the state to set
  39003. */
  39004. setDepthBuffer(enable: boolean): void;
  39005. /**
  39006. * Gets a boolean indicating if depth writing is enabled
  39007. * @returns the current depth writing state
  39008. */
  39009. getDepthWrite(): boolean;
  39010. /**
  39011. * Enable or disable depth writing
  39012. * @param enable defines the state to set
  39013. */
  39014. setDepthWrite(enable: boolean): void;
  39015. /**
  39016. * Gets a boolean indicating if stencil buffer is enabled
  39017. * @returns the current stencil buffer state
  39018. */
  39019. getStencilBuffer(): boolean;
  39020. /**
  39021. * Enable or disable the stencil buffer
  39022. * @param enable defines if the stencil buffer must be enabled or disabled
  39023. */
  39024. setStencilBuffer(enable: boolean): void;
  39025. /**
  39026. * Gets the current stencil mask
  39027. * @returns a number defining the new stencil mask to use
  39028. */
  39029. getStencilMask(): number;
  39030. /**
  39031. * Sets the current stencil mask
  39032. * @param mask defines the new stencil mask to use
  39033. */
  39034. setStencilMask(mask: number): void;
  39035. /**
  39036. * Gets the current stencil function
  39037. * @returns a number defining the stencil function to use
  39038. */
  39039. getStencilFunction(): number;
  39040. /**
  39041. * Gets the current stencil reference value
  39042. * @returns a number defining the stencil reference value to use
  39043. */
  39044. getStencilFunctionReference(): number;
  39045. /**
  39046. * Gets the current stencil mask
  39047. * @returns a number defining the stencil mask to use
  39048. */
  39049. getStencilFunctionMask(): number;
  39050. /**
  39051. * Sets the current stencil function
  39052. * @param stencilFunc defines the new stencil function to use
  39053. */
  39054. setStencilFunction(stencilFunc: number): void;
  39055. /**
  39056. * Sets the current stencil reference
  39057. * @param reference defines the new stencil reference to use
  39058. */
  39059. setStencilFunctionReference(reference: number): void;
  39060. /**
  39061. * Sets the current stencil mask
  39062. * @param mask defines the new stencil mask to use
  39063. */
  39064. setStencilFunctionMask(mask: number): void;
  39065. /**
  39066. * Gets the current stencil operation when stencil fails
  39067. * @returns a number defining stencil operation to use when stencil fails
  39068. */
  39069. getStencilOperationFail(): number;
  39070. /**
  39071. * Gets the current stencil operation when depth fails
  39072. * @returns a number defining stencil operation to use when depth fails
  39073. */
  39074. getStencilOperationDepthFail(): number;
  39075. /**
  39076. * Gets the current stencil operation when stencil passes
  39077. * @returns a number defining stencil operation to use when stencil passes
  39078. */
  39079. getStencilOperationPass(): number;
  39080. /**
  39081. * Sets the stencil operation to use when stencil fails
  39082. * @param operation defines the stencil operation to use when stencil fails
  39083. */
  39084. setStencilOperationFail(operation: number): void;
  39085. /**
  39086. * Sets the stencil operation to use when depth fails
  39087. * @param operation defines the stencil operation to use when depth fails
  39088. */
  39089. setStencilOperationDepthFail(operation: number): void;
  39090. /**
  39091. * Sets the stencil operation to use when stencil passes
  39092. * @param operation defines the stencil operation to use when stencil passes
  39093. */
  39094. setStencilOperationPass(operation: number): void;
  39095. /**
  39096. * Sets a boolean indicating if the dithering state is enabled or disabled
  39097. * @param value defines the dithering state
  39098. */
  39099. setDitheringState(value: boolean): void;
  39100. /**
  39101. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39102. * @param value defines the rasterizer state
  39103. */
  39104. setRasterizerState(value: boolean): void;
  39105. /**
  39106. * Gets the current depth function
  39107. * @returns a number defining the depth function
  39108. */
  39109. getDepthFunction(): Nullable<number>;
  39110. /**
  39111. * Sets the current depth function
  39112. * @param depthFunc defines the function to use
  39113. */
  39114. setDepthFunction(depthFunc: number): void;
  39115. /**
  39116. * Sets the current depth function to GREATER
  39117. */
  39118. setDepthFunctionToGreater(): void;
  39119. /**
  39120. * Sets the current depth function to GEQUAL
  39121. */
  39122. setDepthFunctionToGreaterOrEqual(): void;
  39123. /**
  39124. * Sets the current depth function to LESS
  39125. */
  39126. setDepthFunctionToLess(): void;
  39127. /**
  39128. * Sets the current depth function to LEQUAL
  39129. */
  39130. setDepthFunctionToLessOrEqual(): void;
  39131. private _cachedStencilBuffer;
  39132. private _cachedStencilFunction;
  39133. private _cachedStencilMask;
  39134. private _cachedStencilOperationPass;
  39135. private _cachedStencilOperationFail;
  39136. private _cachedStencilOperationDepthFail;
  39137. private _cachedStencilReference;
  39138. /**
  39139. * Caches the the state of the stencil buffer
  39140. */
  39141. cacheStencilState(): void;
  39142. /**
  39143. * Restores the state of the stencil buffer
  39144. */
  39145. restoreStencilState(): void;
  39146. /**
  39147. * Directly set the WebGL Viewport
  39148. * @param x defines the x coordinate of the viewport (in screen space)
  39149. * @param y defines the y coordinate of the viewport (in screen space)
  39150. * @param width defines the width of the viewport (in screen space)
  39151. * @param height defines the height of the viewport (in screen space)
  39152. * @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
  39153. */
  39154. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39155. /**
  39156. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39157. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39158. * @param y defines the y-coordinate of the corner of the clear rectangle
  39159. * @param width defines the width of the clear rectangle
  39160. * @param height defines the height of the clear rectangle
  39161. * @param clearColor defines the clear color
  39162. */
  39163. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39164. /**
  39165. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39166. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39167. * @param y defines the y-coordinate of the corner of the clear rectangle
  39168. * @param width defines the width of the clear rectangle
  39169. * @param height defines the height of the clear rectangle
  39170. */
  39171. enableScissor(x: number, y: number, width: number, height: number): void;
  39172. /**
  39173. * Disable previously set scissor test rectangle
  39174. */
  39175. disableScissor(): void;
  39176. protected _reportDrawCall(): void;
  39177. /**
  39178. * Initializes a webVR display and starts listening to display change events
  39179. * The onVRDisplayChangedObservable will be notified upon these changes
  39180. * @returns The onVRDisplayChangedObservable
  39181. */
  39182. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39183. /** @hidden */
  39184. _prepareVRComponent(): void;
  39185. /** @hidden */
  39186. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39187. /** @hidden */
  39188. _submitVRFrame(): void;
  39189. /**
  39190. * Call this function to leave webVR mode
  39191. * Will do nothing if webVR is not supported or if there is no webVR device
  39192. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39193. */
  39194. disableVR(): void;
  39195. /**
  39196. * Gets a boolean indicating that the system is in VR mode and is presenting
  39197. * @returns true if VR mode is engaged
  39198. */
  39199. isVRPresenting(): boolean;
  39200. /** @hidden */
  39201. _requestVRFrame(): void;
  39202. /** @hidden */
  39203. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39204. /**
  39205. * Gets the source code of the vertex shader associated with a specific webGL program
  39206. * @param program defines the program to use
  39207. * @returns a string containing the source code of the vertex shader associated with the program
  39208. */
  39209. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39210. /**
  39211. * Gets the source code of the fragment shader associated with a specific webGL program
  39212. * @param program defines the program to use
  39213. * @returns a string containing the source code of the fragment shader associated with the program
  39214. */
  39215. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39216. /**
  39217. * Sets a depth stencil texture from a render target to the according uniform.
  39218. * @param channel The texture channel
  39219. * @param uniform The uniform to set
  39220. * @param texture The render target texture containing the depth stencil texture to apply
  39221. */
  39222. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39223. /**
  39224. * Sets a texture to the webGL context from a postprocess
  39225. * @param channel defines the channel to use
  39226. * @param postProcess defines the source postprocess
  39227. */
  39228. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39229. /**
  39230. * Binds the output of the passed in post process to the texture channel specified
  39231. * @param channel The channel the texture should be bound to
  39232. * @param postProcess The post process which's output should be bound
  39233. */
  39234. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39235. protected _rebuildBuffers(): void;
  39236. /** @hidden */
  39237. _renderFrame(): void;
  39238. _renderLoop(): void;
  39239. /** @hidden */
  39240. _renderViews(): boolean;
  39241. /**
  39242. * Toggle full screen mode
  39243. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39244. */
  39245. switchFullscreen(requestPointerLock: boolean): void;
  39246. /**
  39247. * Enters full screen mode
  39248. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39249. */
  39250. enterFullscreen(requestPointerLock: boolean): void;
  39251. /**
  39252. * Exits full screen mode
  39253. */
  39254. exitFullscreen(): void;
  39255. /**
  39256. * Enters Pointerlock mode
  39257. */
  39258. enterPointerlock(): void;
  39259. /**
  39260. * Exits Pointerlock mode
  39261. */
  39262. exitPointerlock(): void;
  39263. /**
  39264. * Begin a new frame
  39265. */
  39266. beginFrame(): void;
  39267. /**
  39268. * Enf the current frame
  39269. */
  39270. endFrame(): void;
  39271. resize(): void;
  39272. /**
  39273. * Force a specific size of the canvas
  39274. * @param width defines the new canvas' width
  39275. * @param height defines the new canvas' height
  39276. * @returns true if the size was changed
  39277. */
  39278. setSize(width: number, height: number): boolean;
  39279. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39280. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39281. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39282. _releaseTexture(texture: InternalTexture): void;
  39283. /**
  39284. * @hidden
  39285. * Rescales a texture
  39286. * @param source input texutre
  39287. * @param destination destination texture
  39288. * @param scene scene to use to render the resize
  39289. * @param internalFormat format to use when resizing
  39290. * @param onComplete callback to be called when resize has completed
  39291. */
  39292. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39293. /**
  39294. * Gets the current framerate
  39295. * @returns a number representing the framerate
  39296. */
  39297. getFps(): number;
  39298. /**
  39299. * Gets the time spent between current and previous frame
  39300. * @returns a number representing the delta time in ms
  39301. */
  39302. getDeltaTime(): number;
  39303. private _measureFps;
  39304. /** @hidden */
  39305. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39306. /**
  39307. * Updates the sample count of a render target texture
  39308. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39309. * @param texture defines the texture to update
  39310. * @param samples defines the sample count to set
  39311. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39312. */
  39313. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39314. /**
  39315. * Updates a depth texture Comparison Mode and Function.
  39316. * If the comparison Function is equal to 0, the mode will be set to none.
  39317. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39318. * @param texture The texture to set the comparison function for
  39319. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39320. */
  39321. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39322. /**
  39323. * Creates a webGL buffer to use with instanciation
  39324. * @param capacity defines the size of the buffer
  39325. * @returns the webGL buffer
  39326. */
  39327. createInstancesBuffer(capacity: number): DataBuffer;
  39328. /**
  39329. * Delete a webGL buffer used with instanciation
  39330. * @param buffer defines the webGL buffer to delete
  39331. */
  39332. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39333. private _clientWaitAsync;
  39334. /** @hidden */
  39335. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39336. dispose(): void;
  39337. private _disableTouchAction;
  39338. /**
  39339. * Display the loading screen
  39340. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39341. */
  39342. displayLoadingUI(): void;
  39343. /**
  39344. * Hide the loading screen
  39345. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39346. */
  39347. hideLoadingUI(): void;
  39348. /**
  39349. * Gets the current loading screen object
  39350. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39351. */
  39352. get loadingScreen(): ILoadingScreen;
  39353. /**
  39354. * Sets the current loading screen object
  39355. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39356. */
  39357. set loadingScreen(loadingScreen: ILoadingScreen);
  39358. /**
  39359. * Sets the current loading screen text
  39360. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39361. */
  39362. set loadingUIText(text: string);
  39363. /**
  39364. * Sets the current loading screen background color
  39365. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39366. */
  39367. set loadingUIBackgroundColor(color: string);
  39368. /** Pointerlock and fullscreen */
  39369. /**
  39370. * Ask the browser to promote the current element to pointerlock mode
  39371. * @param element defines the DOM element to promote
  39372. */
  39373. static _RequestPointerlock(element: HTMLElement): void;
  39374. /**
  39375. * Asks the browser to exit pointerlock mode
  39376. */
  39377. static _ExitPointerlock(): void;
  39378. /**
  39379. * Ask the browser to promote the current element to fullscreen rendering mode
  39380. * @param element defines the DOM element to promote
  39381. */
  39382. static _RequestFullscreen(element: HTMLElement): void;
  39383. /**
  39384. * Asks the browser to exit fullscreen mode
  39385. */
  39386. static _ExitFullscreen(): void;
  39387. }
  39388. }
  39389. declare module "babylonjs/Engines/engineStore" {
  39390. import { Nullable } from "babylonjs/types";
  39391. import { Engine } from "babylonjs/Engines/engine";
  39392. import { Scene } from "babylonjs/scene";
  39393. /**
  39394. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39395. * during the life time of the application.
  39396. */
  39397. export class EngineStore {
  39398. /** Gets the list of created engines */
  39399. static Instances: import("babylonjs/Engines/engine").Engine[];
  39400. /** @hidden */
  39401. static _LastCreatedScene: Nullable<Scene>;
  39402. /**
  39403. * Gets the latest created engine
  39404. */
  39405. static get LastCreatedEngine(): Nullable<Engine>;
  39406. /**
  39407. * Gets the latest created scene
  39408. */
  39409. static get LastCreatedScene(): Nullable<Scene>;
  39410. /**
  39411. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39412. * @ignorenaming
  39413. */
  39414. static UseFallbackTexture: boolean;
  39415. /**
  39416. * Texture content used if a texture cannot loaded
  39417. * @ignorenaming
  39418. */
  39419. static FallbackTexture: string;
  39420. }
  39421. }
  39422. declare module "babylonjs/Misc/promise" {
  39423. /**
  39424. * Helper class that provides a small promise polyfill
  39425. */
  39426. export class PromisePolyfill {
  39427. /**
  39428. * Static function used to check if the polyfill is required
  39429. * If this is the case then the function will inject the polyfill to window.Promise
  39430. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39431. */
  39432. static Apply(force?: boolean): void;
  39433. }
  39434. }
  39435. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39436. /**
  39437. * Interface for screenshot methods with describe argument called `size` as object with options
  39438. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39439. */
  39440. export interface IScreenshotSize {
  39441. /**
  39442. * number in pixels for canvas height
  39443. */
  39444. height?: number;
  39445. /**
  39446. * multiplier allowing render at a higher or lower resolution
  39447. * If value is defined then height and width will be ignored and taken from camera
  39448. */
  39449. precision?: number;
  39450. /**
  39451. * number in pixels for canvas width
  39452. */
  39453. width?: number;
  39454. }
  39455. }
  39456. declare module "babylonjs/Misc/tools" {
  39457. import { Nullable, float } from "babylonjs/types";
  39458. import { DomManagement } from "babylonjs/Misc/domManagement";
  39459. import { WebRequest } from "babylonjs/Misc/webRequest";
  39460. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39461. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39462. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39463. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39464. import { Camera } from "babylonjs/Cameras/camera";
  39465. import { Engine } from "babylonjs/Engines/engine";
  39466. interface IColor4Like {
  39467. r: float;
  39468. g: float;
  39469. b: float;
  39470. a: float;
  39471. }
  39472. /**
  39473. * Class containing a set of static utilities functions
  39474. */
  39475. export class Tools {
  39476. /**
  39477. * Gets or sets the base URL to use to load assets
  39478. */
  39479. static get BaseUrl(): string;
  39480. static set BaseUrl(value: string);
  39481. /**
  39482. * Enable/Disable Custom HTTP Request Headers globally.
  39483. * default = false
  39484. * @see CustomRequestHeaders
  39485. */
  39486. static UseCustomRequestHeaders: boolean;
  39487. /**
  39488. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39489. * i.e. when loading files, where the server/service expects an Authorization header
  39490. */
  39491. static CustomRequestHeaders: {
  39492. [key: string]: string;
  39493. };
  39494. /**
  39495. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39496. */
  39497. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39498. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39499. /**
  39500. * Default behaviour for cors in the application.
  39501. * It can be a string if the expected behavior is identical in the entire app.
  39502. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39503. */
  39504. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39505. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39506. /**
  39507. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39508. * @ignorenaming
  39509. */
  39510. static get UseFallbackTexture(): boolean;
  39511. static set UseFallbackTexture(value: boolean);
  39512. /**
  39513. * Use this object to register external classes like custom textures or material
  39514. * to allow the laoders to instantiate them
  39515. */
  39516. static get RegisteredExternalClasses(): {
  39517. [key: string]: Object;
  39518. };
  39519. static set RegisteredExternalClasses(classes: {
  39520. [key: string]: Object;
  39521. });
  39522. /**
  39523. * Texture content used if a texture cannot loaded
  39524. * @ignorenaming
  39525. */
  39526. static get fallbackTexture(): string;
  39527. static set fallbackTexture(value: string);
  39528. /**
  39529. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39530. * @param u defines the coordinate on X axis
  39531. * @param v defines the coordinate on Y axis
  39532. * @param width defines the width of the source data
  39533. * @param height defines the height of the source data
  39534. * @param pixels defines the source byte array
  39535. * @param color defines the output color
  39536. */
  39537. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39538. /**
  39539. * Interpolates between a and b via alpha
  39540. * @param a The lower value (returned when alpha = 0)
  39541. * @param b The upper value (returned when alpha = 1)
  39542. * @param alpha The interpolation-factor
  39543. * @return The mixed value
  39544. */
  39545. static Mix(a: number, b: number, alpha: number): number;
  39546. /**
  39547. * Tries to instantiate a new object from a given class name
  39548. * @param className defines the class name to instantiate
  39549. * @returns the new object or null if the system was not able to do the instantiation
  39550. */
  39551. static Instantiate(className: string): any;
  39552. /**
  39553. * Provides a slice function that will work even on IE
  39554. * @param data defines the array to slice
  39555. * @param start defines the start of the data (optional)
  39556. * @param end defines the end of the data (optional)
  39557. * @returns the new sliced array
  39558. */
  39559. static Slice<T>(data: T, start?: number, end?: number): T;
  39560. /**
  39561. * Polyfill for setImmediate
  39562. * @param action defines the action to execute after the current execution block
  39563. */
  39564. static SetImmediate(action: () => void): void;
  39565. /**
  39566. * Function indicating if a number is an exponent of 2
  39567. * @param value defines the value to test
  39568. * @returns true if the value is an exponent of 2
  39569. */
  39570. static IsExponentOfTwo(value: number): boolean;
  39571. private static _tmpFloatArray;
  39572. /**
  39573. * Returns the nearest 32-bit single precision float representation of a Number
  39574. * @param value A Number. If the parameter is of a different type, it will get converted
  39575. * to a number or to NaN if it cannot be converted
  39576. * @returns number
  39577. */
  39578. static FloatRound(value: number): number;
  39579. /**
  39580. * Extracts the filename from a path
  39581. * @param path defines the path to use
  39582. * @returns the filename
  39583. */
  39584. static GetFilename(path: string): string;
  39585. /**
  39586. * Extracts the "folder" part of a path (everything before the filename).
  39587. * @param uri The URI to extract the info from
  39588. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39589. * @returns The "folder" part of the path
  39590. */
  39591. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39592. /**
  39593. * Extracts text content from a DOM element hierarchy
  39594. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39595. */
  39596. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39597. /**
  39598. * Convert an angle in radians to degrees
  39599. * @param angle defines the angle to convert
  39600. * @returns the angle in degrees
  39601. */
  39602. static ToDegrees(angle: number): number;
  39603. /**
  39604. * Convert an angle in degrees to radians
  39605. * @param angle defines the angle to convert
  39606. * @returns the angle in radians
  39607. */
  39608. static ToRadians(angle: number): number;
  39609. /**
  39610. * Returns an array if obj is not an array
  39611. * @param obj defines the object to evaluate as an array
  39612. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39613. * @returns either obj directly if obj is an array or a new array containing obj
  39614. */
  39615. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39616. /**
  39617. * Gets the pointer prefix to use
  39618. * @param engine defines the engine we are finding the prefix for
  39619. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39620. */
  39621. static GetPointerPrefix(engine: Engine): string;
  39622. /**
  39623. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39624. * @param url define the url we are trying
  39625. * @param element define the dom element where to configure the cors policy
  39626. */
  39627. static SetCorsBehavior(url: string | string[], element: {
  39628. crossOrigin: string | null;
  39629. }): void;
  39630. /**
  39631. * Removes unwanted characters from an url
  39632. * @param url defines the url to clean
  39633. * @returns the cleaned url
  39634. */
  39635. static CleanUrl(url: string): string;
  39636. /**
  39637. * Gets or sets a function used to pre-process url before using them to load assets
  39638. */
  39639. static get PreprocessUrl(): (url: string) => string;
  39640. static set PreprocessUrl(processor: (url: string) => string);
  39641. /**
  39642. * Loads an image as an HTMLImageElement.
  39643. * @param input url string, ArrayBuffer, or Blob to load
  39644. * @param onLoad callback called when the image successfully loads
  39645. * @param onError callback called when the image fails to load
  39646. * @param offlineProvider offline provider for caching
  39647. * @param mimeType optional mime type
  39648. * @returns the HTMLImageElement of the loaded image
  39649. */
  39650. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39651. /**
  39652. * Loads a file from a url
  39653. * @param url url string, ArrayBuffer, or Blob to load
  39654. * @param onSuccess callback called when the file successfully loads
  39655. * @param onProgress callback called while file is loading (if the server supports this mode)
  39656. * @param offlineProvider defines the offline provider for caching
  39657. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39658. * @param onError callback called when the file fails to load
  39659. * @returns a file request object
  39660. */
  39661. 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;
  39662. /**
  39663. * Loads a file from a url
  39664. * @param url the file url to load
  39665. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39666. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39667. */
  39668. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39669. /**
  39670. * Load a script (identified by an url). When the url returns, the
  39671. * content of this file is added into a new script element, attached to the DOM (body element)
  39672. * @param scriptUrl defines the url of the script to laod
  39673. * @param onSuccess defines the callback called when the script is loaded
  39674. * @param onError defines the callback to call if an error occurs
  39675. * @param scriptId defines the id of the script element
  39676. */
  39677. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39678. /**
  39679. * Load an asynchronous script (identified by an url). When the url returns, the
  39680. * content of this file is added into a new script element, attached to the DOM (body element)
  39681. * @param scriptUrl defines the url of the script to laod
  39682. * @param scriptId defines the id of the script element
  39683. * @returns a promise request object
  39684. */
  39685. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39686. /**
  39687. * Loads a file from a blob
  39688. * @param fileToLoad defines the blob to use
  39689. * @param callback defines the callback to call when data is loaded
  39690. * @param progressCallback defines the callback to call during loading process
  39691. * @returns a file request object
  39692. */
  39693. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39694. /**
  39695. * Reads a file from a File object
  39696. * @param file defines the file to load
  39697. * @param onSuccess defines the callback to call when data is loaded
  39698. * @param onProgress defines the callback to call during loading process
  39699. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39700. * @param onError defines the callback to call when an error occurs
  39701. * @returns a file request object
  39702. */
  39703. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39704. /**
  39705. * Creates a data url from a given string content
  39706. * @param content defines the content to convert
  39707. * @returns the new data url link
  39708. */
  39709. static FileAsURL(content: string): string;
  39710. /**
  39711. * Format the given number to a specific decimal format
  39712. * @param value defines the number to format
  39713. * @param decimals defines the number of decimals to use
  39714. * @returns the formatted string
  39715. */
  39716. static Format(value: number, decimals?: number): string;
  39717. /**
  39718. * Tries to copy an object by duplicating every property
  39719. * @param source defines the source object
  39720. * @param destination defines the target object
  39721. * @param doNotCopyList defines a list of properties to avoid
  39722. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39723. */
  39724. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39725. /**
  39726. * Gets a boolean indicating if the given object has no own property
  39727. * @param obj defines the object to test
  39728. * @returns true if object has no own property
  39729. */
  39730. static IsEmpty(obj: any): boolean;
  39731. /**
  39732. * Function used to register events at window level
  39733. * @param windowElement defines the Window object to use
  39734. * @param events defines the events to register
  39735. */
  39736. static RegisterTopRootEvents(windowElement: Window, events: {
  39737. name: string;
  39738. handler: Nullable<(e: FocusEvent) => any>;
  39739. }[]): void;
  39740. /**
  39741. * Function used to unregister events from window level
  39742. * @param windowElement defines the Window object to use
  39743. * @param events defines the events to unregister
  39744. */
  39745. static UnregisterTopRootEvents(windowElement: Window, events: {
  39746. name: string;
  39747. handler: Nullable<(e: FocusEvent) => any>;
  39748. }[]): void;
  39749. /**
  39750. * @ignore
  39751. */
  39752. static _ScreenshotCanvas: HTMLCanvasElement;
  39753. /**
  39754. * Dumps the current bound framebuffer
  39755. * @param width defines the rendering width
  39756. * @param height defines the rendering height
  39757. * @param engine defines the hosting engine
  39758. * @param successCallback defines the callback triggered once the data are available
  39759. * @param mimeType defines the mime type of the result
  39760. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39761. */
  39762. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39763. /**
  39764. * Converts the canvas data to blob.
  39765. * This acts as a polyfill for browsers not supporting the to blob function.
  39766. * @param canvas Defines the canvas to extract the data from
  39767. * @param successCallback Defines the callback triggered once the data are available
  39768. * @param mimeType Defines the mime type of the result
  39769. */
  39770. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39771. /**
  39772. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39773. * @param successCallback defines the callback triggered once the data are available
  39774. * @param mimeType defines the mime type of the result
  39775. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39776. */
  39777. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39778. /**
  39779. * Downloads a blob in the browser
  39780. * @param blob defines the blob to download
  39781. * @param fileName defines the name of the downloaded file
  39782. */
  39783. static Download(blob: Blob, fileName: string): void;
  39784. /**
  39785. * Captures a screenshot of the current rendering
  39786. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39787. * @param engine defines the rendering engine
  39788. * @param camera defines the source camera
  39789. * @param size This parameter can be set to a single number or to an object with the
  39790. * following (optional) properties: precision, width, height. If a single number is passed,
  39791. * it will be used for both width and height. If an object is passed, the screenshot size
  39792. * will be derived from the parameters. The precision property is a multiplier allowing
  39793. * rendering at a higher or lower resolution
  39794. * @param successCallback defines the callback receives a single parameter which contains the
  39795. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39796. * src parameter of an <img> to display it
  39797. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39798. * Check your browser for supported MIME types
  39799. */
  39800. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39801. /**
  39802. * Captures a screenshot of the current rendering
  39803. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39804. * @param engine defines the rendering engine
  39805. * @param camera defines the source camera
  39806. * @param size This parameter can be set to a single number or to an object with the
  39807. * following (optional) properties: precision, width, height. If a single number is passed,
  39808. * it will be used for both width and height. If an object is passed, the screenshot size
  39809. * will be derived from the parameters. The precision property is a multiplier allowing
  39810. * rendering at a higher or lower resolution
  39811. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39812. * Check your browser for supported MIME types
  39813. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39814. * to the src parameter of an <img> to display it
  39815. */
  39816. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39817. /**
  39818. * Generates an image screenshot from the specified camera.
  39819. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39820. * @param engine The engine to use for rendering
  39821. * @param camera The camera to use for rendering
  39822. * @param size This parameter can be set to a single number or to an object with the
  39823. * following (optional) properties: precision, width, height. If a single number is passed,
  39824. * it will be used for both width and height. If an object is passed, the screenshot size
  39825. * will be derived from the parameters. The precision property is a multiplier allowing
  39826. * rendering at a higher or lower resolution
  39827. * @param successCallback The callback receives a single parameter which contains the
  39828. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39829. * src parameter of an <img> to display it
  39830. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39831. * Check your browser for supported MIME types
  39832. * @param samples Texture samples (default: 1)
  39833. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39834. * @param fileName A name for for the downloaded file.
  39835. */
  39836. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39837. /**
  39838. * Generates an image screenshot from the specified camera.
  39839. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39840. * @param engine The engine to use for rendering
  39841. * @param camera The camera to use for rendering
  39842. * @param size This parameter can be set to a single number or to an object with the
  39843. * following (optional) properties: precision, width, height. If a single number is passed,
  39844. * it will be used for both width and height. If an object is passed, the screenshot size
  39845. * will be derived from the parameters. The precision property is a multiplier allowing
  39846. * rendering at a higher or lower resolution
  39847. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39848. * Check your browser for supported MIME types
  39849. * @param samples Texture samples (default: 1)
  39850. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39851. * @param fileName A name for for the downloaded file.
  39852. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39853. * to the src parameter of an <img> to display it
  39854. */
  39855. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39856. /**
  39857. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39858. * Be aware Math.random() could cause collisions, but:
  39859. * "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"
  39860. * @returns a pseudo random id
  39861. */
  39862. static RandomId(): string;
  39863. /**
  39864. * Test if the given uri is a base64 string
  39865. * @param uri The uri to test
  39866. * @return True if the uri is a base64 string or false otherwise
  39867. */
  39868. static IsBase64(uri: string): boolean;
  39869. /**
  39870. * Decode the given base64 uri.
  39871. * @param uri The uri to decode
  39872. * @return The decoded base64 data.
  39873. */
  39874. static DecodeBase64(uri: string): ArrayBuffer;
  39875. /**
  39876. * Gets the absolute url.
  39877. * @param url the input url
  39878. * @return the absolute url
  39879. */
  39880. static GetAbsoluteUrl(url: string): string;
  39881. /**
  39882. * No log
  39883. */
  39884. static readonly NoneLogLevel: number;
  39885. /**
  39886. * Only message logs
  39887. */
  39888. static readonly MessageLogLevel: number;
  39889. /**
  39890. * Only warning logs
  39891. */
  39892. static readonly WarningLogLevel: number;
  39893. /**
  39894. * Only error logs
  39895. */
  39896. static readonly ErrorLogLevel: number;
  39897. /**
  39898. * All logs
  39899. */
  39900. static readonly AllLogLevel: number;
  39901. /**
  39902. * Gets a value indicating the number of loading errors
  39903. * @ignorenaming
  39904. */
  39905. static get errorsCount(): number;
  39906. /**
  39907. * Callback called when a new log is added
  39908. */
  39909. static OnNewCacheEntry: (entry: string) => void;
  39910. /**
  39911. * Log a message to the console
  39912. * @param message defines the message to log
  39913. */
  39914. static Log(message: string): void;
  39915. /**
  39916. * Write a warning message to the console
  39917. * @param message defines the message to log
  39918. */
  39919. static Warn(message: string): void;
  39920. /**
  39921. * Write an error message to the console
  39922. * @param message defines the message to log
  39923. */
  39924. static Error(message: string): void;
  39925. /**
  39926. * Gets current log cache (list of logs)
  39927. */
  39928. static get LogCache(): string;
  39929. /**
  39930. * Clears the log cache
  39931. */
  39932. static ClearLogCache(): void;
  39933. /**
  39934. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39935. */
  39936. static set LogLevels(level: number);
  39937. /**
  39938. * Checks if the window object exists
  39939. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  39940. */
  39941. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  39942. /**
  39943. * No performance log
  39944. */
  39945. static readonly PerformanceNoneLogLevel: number;
  39946. /**
  39947. * Use user marks to log performance
  39948. */
  39949. static readonly PerformanceUserMarkLogLevel: number;
  39950. /**
  39951. * Log performance to the console
  39952. */
  39953. static readonly PerformanceConsoleLogLevel: number;
  39954. private static _performance;
  39955. /**
  39956. * Sets the current performance log level
  39957. */
  39958. static set PerformanceLogLevel(level: number);
  39959. private static _StartPerformanceCounterDisabled;
  39960. private static _EndPerformanceCounterDisabled;
  39961. private static _StartUserMark;
  39962. private static _EndUserMark;
  39963. private static _StartPerformanceConsole;
  39964. private static _EndPerformanceConsole;
  39965. /**
  39966. * Starts a performance counter
  39967. */
  39968. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39969. /**
  39970. * Ends a specific performance coutner
  39971. */
  39972. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39973. /**
  39974. * Gets either window.performance.now() if supported or Date.now() else
  39975. */
  39976. static get Now(): number;
  39977. /**
  39978. * This method will return the name of the class used to create the instance of the given object.
  39979. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39980. * @param object the object to get the class name from
  39981. * @param isType defines if the object is actually a type
  39982. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39983. */
  39984. static GetClassName(object: any, isType?: boolean): string;
  39985. /**
  39986. * Gets the first element of an array satisfying a given predicate
  39987. * @param array defines the array to browse
  39988. * @param predicate defines the predicate to use
  39989. * @returns null if not found or the element
  39990. */
  39991. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39992. /**
  39993. * This method will return the name of the full name of the class, including its owning module (if any).
  39994. * 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).
  39995. * @param object the object to get the class name from
  39996. * @param isType defines if the object is actually a type
  39997. * @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.
  39998. * @ignorenaming
  39999. */
  40000. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40001. /**
  40002. * Returns a promise that resolves after the given amount of time.
  40003. * @param delay Number of milliseconds to delay
  40004. * @returns Promise that resolves after the given amount of time
  40005. */
  40006. static DelayAsync(delay: number): Promise<void>;
  40007. /**
  40008. * Utility function to detect if the current user agent is Safari
  40009. * @returns whether or not the current user agent is safari
  40010. */
  40011. static IsSafari(): boolean;
  40012. }
  40013. /**
  40014. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40015. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40016. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40017. * @param name The name of the class, case should be preserved
  40018. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40019. */
  40020. export function className(name: string, module?: string): (target: Object) => void;
  40021. /**
  40022. * An implementation of a loop for asynchronous functions.
  40023. */
  40024. export class AsyncLoop {
  40025. /**
  40026. * Defines the number of iterations for the loop
  40027. */
  40028. iterations: number;
  40029. /**
  40030. * Defines the current index of the loop.
  40031. */
  40032. index: number;
  40033. private _done;
  40034. private _fn;
  40035. private _successCallback;
  40036. /**
  40037. * Constructor.
  40038. * @param iterations the number of iterations.
  40039. * @param func the function to run each iteration
  40040. * @param successCallback the callback that will be called upon succesful execution
  40041. * @param offset starting offset.
  40042. */
  40043. constructor(
  40044. /**
  40045. * Defines the number of iterations for the loop
  40046. */
  40047. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40048. /**
  40049. * Execute the next iteration. Must be called after the last iteration was finished.
  40050. */
  40051. executeNext(): void;
  40052. /**
  40053. * Break the loop and run the success callback.
  40054. */
  40055. breakLoop(): void;
  40056. /**
  40057. * Create and run an async loop.
  40058. * @param iterations the number of iterations.
  40059. * @param fn the function to run each iteration
  40060. * @param successCallback the callback that will be called upon succesful execution
  40061. * @param offset starting offset.
  40062. * @returns the created async loop object
  40063. */
  40064. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40065. /**
  40066. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40067. * @param iterations total number of iterations
  40068. * @param syncedIterations number of synchronous iterations in each async iteration.
  40069. * @param fn the function to call each iteration.
  40070. * @param callback a success call back that will be called when iterating stops.
  40071. * @param breakFunction a break condition (optional)
  40072. * @param timeout timeout settings for the setTimeout function. default - 0.
  40073. * @returns the created async loop object
  40074. */
  40075. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40076. }
  40077. }
  40078. declare module "babylonjs/Misc/stringDictionary" {
  40079. import { Nullable } from "babylonjs/types";
  40080. /**
  40081. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40082. * The underlying implementation relies on an associative array to ensure the best performances.
  40083. * The value can be anything including 'null' but except 'undefined'
  40084. */
  40085. export class StringDictionary<T> {
  40086. /**
  40087. * This will clear this dictionary and copy the content from the 'source' one.
  40088. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40089. * @param source the dictionary to take the content from and copy to this dictionary
  40090. */
  40091. copyFrom(source: StringDictionary<T>): void;
  40092. /**
  40093. * Get a value based from its key
  40094. * @param key the given key to get the matching value from
  40095. * @return the value if found, otherwise undefined is returned
  40096. */
  40097. get(key: string): T | undefined;
  40098. /**
  40099. * Get a value from its key or add it if it doesn't exist.
  40100. * This method will ensure you that a given key/data will be present in the dictionary.
  40101. * @param key the given key to get the matching value from
  40102. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40103. * The factory will only be invoked if there's no data for the given key.
  40104. * @return the value corresponding to the key.
  40105. */
  40106. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40107. /**
  40108. * Get a value from its key if present in the dictionary otherwise add it
  40109. * @param key the key to get the value from
  40110. * @param val if there's no such key/value pair in the dictionary add it with this value
  40111. * @return the value corresponding to the key
  40112. */
  40113. getOrAdd(key: string, val: T): T;
  40114. /**
  40115. * Check if there's a given key in the dictionary
  40116. * @param key the key to check for
  40117. * @return true if the key is present, false otherwise
  40118. */
  40119. contains(key: string): boolean;
  40120. /**
  40121. * Add a new key and its corresponding value
  40122. * @param key the key to add
  40123. * @param value the value corresponding to the key
  40124. * @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
  40125. */
  40126. add(key: string, value: T): boolean;
  40127. /**
  40128. * Update a specific value associated to a key
  40129. * @param key defines the key to use
  40130. * @param value defines the value to store
  40131. * @returns true if the value was updated (or false if the key was not found)
  40132. */
  40133. set(key: string, value: T): boolean;
  40134. /**
  40135. * Get the element of the given key and remove it from the dictionary
  40136. * @param key defines the key to search
  40137. * @returns the value associated with the key or null if not found
  40138. */
  40139. getAndRemove(key: string): Nullable<T>;
  40140. /**
  40141. * Remove a key/value from the dictionary.
  40142. * @param key the key to remove
  40143. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40144. */
  40145. remove(key: string): boolean;
  40146. /**
  40147. * Clear the whole content of the dictionary
  40148. */
  40149. clear(): void;
  40150. /**
  40151. * Gets the current count
  40152. */
  40153. get count(): number;
  40154. /**
  40155. * Execute a callback on each key/val of the dictionary.
  40156. * Note that you can remove any element in this dictionary in the callback implementation
  40157. * @param callback the callback to execute on a given key/value pair
  40158. */
  40159. forEach(callback: (key: string, val: T) => void): void;
  40160. /**
  40161. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40162. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40163. * Note that you can remove any element in this dictionary in the callback implementation
  40164. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40165. * @returns the first item
  40166. */
  40167. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40168. private _count;
  40169. private _data;
  40170. }
  40171. }
  40172. declare module "babylonjs/Collisions/collisionCoordinator" {
  40173. import { Nullable } from "babylonjs/types";
  40174. import { Scene } from "babylonjs/scene";
  40175. import { Vector3 } from "babylonjs/Maths/math.vector";
  40176. import { Collider } from "babylonjs/Collisions/collider";
  40177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40178. /** @hidden */
  40179. export interface ICollisionCoordinator {
  40180. createCollider(): Collider;
  40181. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40182. init(scene: Scene): void;
  40183. }
  40184. /** @hidden */
  40185. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40186. private _scene;
  40187. private _scaledPosition;
  40188. private _scaledVelocity;
  40189. private _finalPosition;
  40190. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40191. createCollider(): Collider;
  40192. init(scene: Scene): void;
  40193. private _collideWithWorld;
  40194. }
  40195. }
  40196. declare module "babylonjs/Inputs/scene.inputManager" {
  40197. import { Nullable } from "babylonjs/types";
  40198. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40199. import { Vector2 } from "babylonjs/Maths/math.vector";
  40200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40201. import { Scene } from "babylonjs/scene";
  40202. /**
  40203. * Class used to manage all inputs for the scene.
  40204. */
  40205. export class InputManager {
  40206. /** The distance in pixel that you have to move to prevent some events */
  40207. static DragMovementThreshold: number;
  40208. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40209. static LongPressDelay: number;
  40210. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40211. static DoubleClickDelay: number;
  40212. /** If you need to check double click without raising a single click at first click, enable this flag */
  40213. static ExclusiveDoubleClickMode: boolean;
  40214. /** 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. */
  40215. private _alreadyAttached;
  40216. private _wheelEventName;
  40217. private _onPointerMove;
  40218. private _onPointerDown;
  40219. private _onPointerUp;
  40220. private _initClickEvent;
  40221. private _initActionManager;
  40222. private _delayedSimpleClick;
  40223. private _delayedSimpleClickTimeout;
  40224. private _previousDelayedSimpleClickTimeout;
  40225. private _meshPickProceed;
  40226. private _previousButtonPressed;
  40227. private _currentPickResult;
  40228. private _previousPickResult;
  40229. private _totalPointersPressed;
  40230. private _doubleClickOccured;
  40231. private _pointerOverMesh;
  40232. private _pickedDownMesh;
  40233. private _pickedUpMesh;
  40234. private _pointerX;
  40235. private _pointerY;
  40236. private _unTranslatedPointerX;
  40237. private _unTranslatedPointerY;
  40238. private _startingPointerPosition;
  40239. private _previousStartingPointerPosition;
  40240. private _startingPointerTime;
  40241. private _previousStartingPointerTime;
  40242. private _pointerCaptures;
  40243. private _onKeyDown;
  40244. private _onKeyUp;
  40245. private _onCanvasFocusObserver;
  40246. private _onCanvasBlurObserver;
  40247. private _scene;
  40248. /**
  40249. * Creates a new InputManager
  40250. * @param scene defines the hosting scene
  40251. */
  40252. constructor(scene: Scene);
  40253. /**
  40254. * Gets the mesh that is currently under the pointer
  40255. */
  40256. get meshUnderPointer(): Nullable<AbstractMesh>;
  40257. /**
  40258. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40259. */
  40260. get unTranslatedPointer(): Vector2;
  40261. /**
  40262. * Gets or sets the current on-screen X position of the pointer
  40263. */
  40264. get pointerX(): number;
  40265. set pointerX(value: number);
  40266. /**
  40267. * Gets or sets the current on-screen Y position of the pointer
  40268. */
  40269. get pointerY(): number;
  40270. set pointerY(value: number);
  40271. private _updatePointerPosition;
  40272. private _processPointerMove;
  40273. private _setRayOnPointerInfo;
  40274. private _checkPrePointerObservable;
  40275. /**
  40276. * Use this method to simulate a pointer move on a mesh
  40277. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40278. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40279. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40280. */
  40281. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40282. /**
  40283. * Use this method to simulate a pointer down on a mesh
  40284. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40285. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40286. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40287. */
  40288. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40289. private _processPointerDown;
  40290. /** @hidden */
  40291. _isPointerSwiping(): boolean;
  40292. /**
  40293. * Use this method to simulate a pointer up on a mesh
  40294. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40295. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40296. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40297. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40298. */
  40299. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40300. private _processPointerUp;
  40301. /**
  40302. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40303. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40304. * @returns true if the pointer was captured
  40305. */
  40306. isPointerCaptured(pointerId?: number): boolean;
  40307. /**
  40308. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40309. * @param attachUp defines if you want to attach events to pointerup
  40310. * @param attachDown defines if you want to attach events to pointerdown
  40311. * @param attachMove defines if you want to attach events to pointermove
  40312. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40313. */
  40314. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40315. /**
  40316. * Detaches all event handlers
  40317. */
  40318. detachControl(): void;
  40319. /**
  40320. * Force the value of meshUnderPointer
  40321. * @param mesh defines the mesh to use
  40322. */
  40323. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40324. /**
  40325. * Gets the mesh under the pointer
  40326. * @returns a Mesh or null if no mesh is under the pointer
  40327. */
  40328. getPointerOverMesh(): Nullable<AbstractMesh>;
  40329. }
  40330. }
  40331. declare module "babylonjs/Animations/animationGroup" {
  40332. import { Animatable } from "babylonjs/Animations/animatable";
  40333. import { Animation } from "babylonjs/Animations/animation";
  40334. import { Scene, IDisposable } from "babylonjs/scene";
  40335. import { Observable } from "babylonjs/Misc/observable";
  40336. import { Nullable } from "babylonjs/types";
  40337. import "babylonjs/Animations/animatable";
  40338. /**
  40339. * This class defines the direct association between an animation and a target
  40340. */
  40341. export class TargetedAnimation {
  40342. /**
  40343. * Animation to perform
  40344. */
  40345. animation: Animation;
  40346. /**
  40347. * Target to animate
  40348. */
  40349. target: any;
  40350. /**
  40351. * Returns the string "TargetedAnimation"
  40352. * @returns "TargetedAnimation"
  40353. */
  40354. getClassName(): string;
  40355. /**
  40356. * Serialize the object
  40357. * @returns the JSON object representing the current entity
  40358. */
  40359. serialize(): any;
  40360. }
  40361. /**
  40362. * Use this class to create coordinated animations on multiple targets
  40363. */
  40364. export class AnimationGroup implements IDisposable {
  40365. /** The name of the animation group */
  40366. name: string;
  40367. private _scene;
  40368. private _targetedAnimations;
  40369. private _animatables;
  40370. private _from;
  40371. private _to;
  40372. private _isStarted;
  40373. private _isPaused;
  40374. private _speedRatio;
  40375. private _loopAnimation;
  40376. private _isAdditive;
  40377. /**
  40378. * Gets or sets the unique id of the node
  40379. */
  40380. uniqueId: number;
  40381. /**
  40382. * This observable will notify when one animation have ended
  40383. */
  40384. onAnimationEndObservable: Observable<TargetedAnimation>;
  40385. /**
  40386. * Observer raised when one animation loops
  40387. */
  40388. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40389. /**
  40390. * Observer raised when all animations have looped
  40391. */
  40392. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40393. /**
  40394. * This observable will notify when all animations have ended.
  40395. */
  40396. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40397. /**
  40398. * This observable will notify when all animations have paused.
  40399. */
  40400. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40401. /**
  40402. * This observable will notify when all animations are playing.
  40403. */
  40404. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40405. /**
  40406. * Gets the first frame
  40407. */
  40408. get from(): number;
  40409. /**
  40410. * Gets the last frame
  40411. */
  40412. get to(): number;
  40413. /**
  40414. * Define if the animations are started
  40415. */
  40416. get isStarted(): boolean;
  40417. /**
  40418. * Gets a value indicating that the current group is playing
  40419. */
  40420. get isPlaying(): boolean;
  40421. /**
  40422. * Gets or sets the speed ratio to use for all animations
  40423. */
  40424. get speedRatio(): number;
  40425. /**
  40426. * Gets or sets the speed ratio to use for all animations
  40427. */
  40428. set speedRatio(value: number);
  40429. /**
  40430. * Gets or sets if all animations should loop or not
  40431. */
  40432. get loopAnimation(): boolean;
  40433. set loopAnimation(value: boolean);
  40434. /**
  40435. * Gets or sets if all animations should be evaluated additively
  40436. */
  40437. get isAdditive(): boolean;
  40438. set isAdditive(value: boolean);
  40439. /**
  40440. * Gets the targeted animations for this animation group
  40441. */
  40442. get targetedAnimations(): Array<TargetedAnimation>;
  40443. /**
  40444. * returning the list of animatables controlled by this animation group.
  40445. */
  40446. get animatables(): Array<Animatable>;
  40447. /**
  40448. * Gets the list of target animations
  40449. */
  40450. get children(): TargetedAnimation[];
  40451. /**
  40452. * Instantiates a new Animation Group.
  40453. * This helps managing several animations at once.
  40454. * @see https://doc.babylonjs.com/how_to/group
  40455. * @param name Defines the name of the group
  40456. * @param scene Defines the scene the group belongs to
  40457. */
  40458. constructor(
  40459. /** The name of the animation group */
  40460. name: string, scene?: Nullable<Scene>);
  40461. /**
  40462. * Add an animation (with its target) in the group
  40463. * @param animation defines the animation we want to add
  40464. * @param target defines the target of the animation
  40465. * @returns the TargetedAnimation object
  40466. */
  40467. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40468. /**
  40469. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40470. * It can add constant keys at begin or end
  40471. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40472. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40473. * @returns the animation group
  40474. */
  40475. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40476. private _animationLoopCount;
  40477. private _animationLoopFlags;
  40478. private _processLoop;
  40479. /**
  40480. * Start all animations on given targets
  40481. * @param loop defines if animations must loop
  40482. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40483. * @param from defines the from key (optional)
  40484. * @param to defines the to key (optional)
  40485. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40486. * @returns the current animation group
  40487. */
  40488. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40489. /**
  40490. * Pause all animations
  40491. * @returns the animation group
  40492. */
  40493. pause(): AnimationGroup;
  40494. /**
  40495. * Play all animations to initial state
  40496. * This function will start() the animations if they were not started or will restart() them if they were paused
  40497. * @param loop defines if animations must loop
  40498. * @returns the animation group
  40499. */
  40500. play(loop?: boolean): AnimationGroup;
  40501. /**
  40502. * Reset all animations to initial state
  40503. * @returns the animation group
  40504. */
  40505. reset(): AnimationGroup;
  40506. /**
  40507. * Restart animations from key 0
  40508. * @returns the animation group
  40509. */
  40510. restart(): AnimationGroup;
  40511. /**
  40512. * Stop all animations
  40513. * @returns the animation group
  40514. */
  40515. stop(): AnimationGroup;
  40516. /**
  40517. * Set animation weight for all animatables
  40518. * @param weight defines the weight to use
  40519. * @return the animationGroup
  40520. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40521. */
  40522. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40523. /**
  40524. * Synchronize and normalize all animatables with a source animatable
  40525. * @param root defines the root animatable to synchronize with
  40526. * @return the animationGroup
  40527. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40528. */
  40529. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40530. /**
  40531. * Goes to a specific frame in this animation group
  40532. * @param frame the frame number to go to
  40533. * @return the animationGroup
  40534. */
  40535. goToFrame(frame: number): AnimationGroup;
  40536. /**
  40537. * Dispose all associated resources
  40538. */
  40539. dispose(): void;
  40540. private _checkAnimationGroupEnded;
  40541. /**
  40542. * Clone the current animation group and returns a copy
  40543. * @param newName defines the name of the new group
  40544. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40545. * @returns the new aniamtion group
  40546. */
  40547. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40548. /**
  40549. * Serializes the animationGroup to an object
  40550. * @returns Serialized object
  40551. */
  40552. serialize(): any;
  40553. /**
  40554. * Returns a new AnimationGroup object parsed from the source provided.
  40555. * @param parsedAnimationGroup defines the source
  40556. * @param scene defines the scene that will receive the animationGroup
  40557. * @returns a new AnimationGroup
  40558. */
  40559. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40560. /**
  40561. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40562. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40563. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40564. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40565. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40566. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40567. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40568. */
  40569. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40570. /**
  40571. * Returns the string "AnimationGroup"
  40572. * @returns "AnimationGroup"
  40573. */
  40574. getClassName(): string;
  40575. /**
  40576. * Creates a detailled string about the object
  40577. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40578. * @returns a string representing the object
  40579. */
  40580. toString(fullDetails?: boolean): string;
  40581. }
  40582. }
  40583. declare module "babylonjs/scene" {
  40584. import { Nullable } from "babylonjs/types";
  40585. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40586. import { Observable } from "babylonjs/Misc/observable";
  40587. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40588. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40589. import { Geometry } from "babylonjs/Meshes/geometry";
  40590. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40591. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40593. import { Mesh } from "babylonjs/Meshes/mesh";
  40594. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40595. import { Bone } from "babylonjs/Bones/bone";
  40596. import { Skeleton } from "babylonjs/Bones/skeleton";
  40597. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40598. import { Camera } from "babylonjs/Cameras/camera";
  40599. import { AbstractScene } from "babylonjs/abstractScene";
  40600. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40601. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40602. import { Material } from "babylonjs/Materials/material";
  40603. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40604. import { Effect } from "babylonjs/Materials/effect";
  40605. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40606. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40607. import { Light } from "babylonjs/Lights/light";
  40608. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40609. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40610. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40611. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40612. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40613. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40614. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40615. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40616. import { Engine } from "babylonjs/Engines/engine";
  40617. import { Node } from "babylonjs/node";
  40618. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40619. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40620. import { WebRequest } from "babylonjs/Misc/webRequest";
  40621. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40622. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40623. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40624. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40625. import { Plane } from "babylonjs/Maths/math.plane";
  40626. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40627. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40628. import { Ray } from "babylonjs/Culling/ray";
  40629. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40630. import { Animation } from "babylonjs/Animations/animation";
  40631. import { Animatable } from "babylonjs/Animations/animatable";
  40632. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40633. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40634. import { Collider } from "babylonjs/Collisions/collider";
  40635. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40636. /**
  40637. * Define an interface for all classes that will hold resources
  40638. */
  40639. export interface IDisposable {
  40640. /**
  40641. * Releases all held resources
  40642. */
  40643. dispose(): void;
  40644. }
  40645. /** Interface defining initialization parameters for Scene class */
  40646. export interface SceneOptions {
  40647. /**
  40648. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40649. * It will improve performance when the number of geometries becomes important.
  40650. */
  40651. useGeometryUniqueIdsMap?: boolean;
  40652. /**
  40653. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40654. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40655. */
  40656. useMaterialMeshMap?: boolean;
  40657. /**
  40658. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40659. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40660. */
  40661. useClonedMeshMap?: boolean;
  40662. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40663. virtual?: boolean;
  40664. }
  40665. /**
  40666. * Represents a scene to be rendered by the engine.
  40667. * @see https://doc.babylonjs.com/features/scene
  40668. */
  40669. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40670. /** The fog is deactivated */
  40671. static readonly FOGMODE_NONE: number;
  40672. /** The fog density is following an exponential function */
  40673. static readonly FOGMODE_EXP: number;
  40674. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40675. static readonly FOGMODE_EXP2: number;
  40676. /** The fog density is following a linear function. */
  40677. static readonly FOGMODE_LINEAR: number;
  40678. /**
  40679. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40680. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40681. */
  40682. static MinDeltaTime: number;
  40683. /**
  40684. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40685. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40686. */
  40687. static MaxDeltaTime: number;
  40688. /**
  40689. * Factory used to create the default material.
  40690. * @param name The name of the material to create
  40691. * @param scene The scene to create the material for
  40692. * @returns The default material
  40693. */
  40694. static DefaultMaterialFactory(scene: Scene): Material;
  40695. /**
  40696. * Factory used to create the a collision coordinator.
  40697. * @returns The collision coordinator
  40698. */
  40699. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40700. /** @hidden */
  40701. _inputManager: InputManager;
  40702. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40703. cameraToUseForPointers: Nullable<Camera>;
  40704. /** @hidden */
  40705. readonly _isScene: boolean;
  40706. /** @hidden */
  40707. _blockEntityCollection: boolean;
  40708. /**
  40709. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40710. */
  40711. autoClear: boolean;
  40712. /**
  40713. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40714. */
  40715. autoClearDepthAndStencil: boolean;
  40716. /**
  40717. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40718. */
  40719. clearColor: Color4;
  40720. /**
  40721. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40722. */
  40723. ambientColor: Color3;
  40724. /**
  40725. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40726. * It should only be one of the following (if not the default embedded one):
  40727. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40728. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40729. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40730. * The material properties need to be setup according to the type of texture in use.
  40731. */
  40732. environmentBRDFTexture: BaseTexture;
  40733. /** @hidden */
  40734. protected _environmentTexture: Nullable<BaseTexture>;
  40735. /**
  40736. * Texture used in all pbr material as the reflection texture.
  40737. * As in the majority of the scene they are the same (exception for multi room and so on),
  40738. * this is easier to reference from here than from all the materials.
  40739. */
  40740. get environmentTexture(): Nullable<BaseTexture>;
  40741. /**
  40742. * Texture used in all pbr material as the reflection texture.
  40743. * As in the majority of the scene they are the same (exception for multi room and so on),
  40744. * this is easier to set here than in all the materials.
  40745. */
  40746. set environmentTexture(value: Nullable<BaseTexture>);
  40747. /** @hidden */
  40748. protected _environmentIntensity: number;
  40749. /**
  40750. * Intensity of the environment in all pbr material.
  40751. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40752. * As in the majority of the scene they are the same (exception for multi room and so on),
  40753. * this is easier to reference from here than from all the materials.
  40754. */
  40755. get environmentIntensity(): number;
  40756. /**
  40757. * Intensity of the environment in all pbr material.
  40758. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40759. * As in the majority of the scene they are the same (exception for multi room and so on),
  40760. * this is easier to set here than in all the materials.
  40761. */
  40762. set environmentIntensity(value: number);
  40763. /** @hidden */
  40764. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40765. /**
  40766. * Default image processing configuration used either in the rendering
  40767. * Forward main pass or through the imageProcessingPostProcess if present.
  40768. * As in the majority of the scene they are the same (exception for multi camera),
  40769. * this is easier to reference from here than from all the materials and post process.
  40770. *
  40771. * No setter as we it is a shared configuration, you can set the values instead.
  40772. */
  40773. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40774. private _forceWireframe;
  40775. /**
  40776. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40777. */
  40778. set forceWireframe(value: boolean);
  40779. get forceWireframe(): boolean;
  40780. private _skipFrustumClipping;
  40781. /**
  40782. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40783. */
  40784. set skipFrustumClipping(value: boolean);
  40785. get skipFrustumClipping(): boolean;
  40786. private _forcePointsCloud;
  40787. /**
  40788. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40789. */
  40790. set forcePointsCloud(value: boolean);
  40791. get forcePointsCloud(): boolean;
  40792. /**
  40793. * Gets or sets the active clipplane 1
  40794. */
  40795. clipPlane: Nullable<Plane>;
  40796. /**
  40797. * Gets or sets the active clipplane 2
  40798. */
  40799. clipPlane2: Nullable<Plane>;
  40800. /**
  40801. * Gets or sets the active clipplane 3
  40802. */
  40803. clipPlane3: Nullable<Plane>;
  40804. /**
  40805. * Gets or sets the active clipplane 4
  40806. */
  40807. clipPlane4: Nullable<Plane>;
  40808. /**
  40809. * Gets or sets the active clipplane 5
  40810. */
  40811. clipPlane5: Nullable<Plane>;
  40812. /**
  40813. * Gets or sets the active clipplane 6
  40814. */
  40815. clipPlane6: Nullable<Plane>;
  40816. /**
  40817. * Gets or sets a boolean indicating if animations are enabled
  40818. */
  40819. animationsEnabled: boolean;
  40820. private _animationPropertiesOverride;
  40821. /**
  40822. * Gets or sets the animation properties override
  40823. */
  40824. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40825. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40826. /**
  40827. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40828. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40829. */
  40830. useConstantAnimationDeltaTime: boolean;
  40831. /**
  40832. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40833. * Please note that it requires to run a ray cast through the scene on every frame
  40834. */
  40835. constantlyUpdateMeshUnderPointer: boolean;
  40836. /**
  40837. * Defines the HTML cursor to use when hovering over interactive elements
  40838. */
  40839. hoverCursor: string;
  40840. /**
  40841. * Defines the HTML default cursor to use (empty by default)
  40842. */
  40843. defaultCursor: string;
  40844. /**
  40845. * Defines whether cursors are handled by the scene.
  40846. */
  40847. doNotHandleCursors: boolean;
  40848. /**
  40849. * This is used to call preventDefault() on pointer down
  40850. * in order to block unwanted artifacts like system double clicks
  40851. */
  40852. preventDefaultOnPointerDown: boolean;
  40853. /**
  40854. * This is used to call preventDefault() on pointer up
  40855. * in order to block unwanted artifacts like system double clicks
  40856. */
  40857. preventDefaultOnPointerUp: boolean;
  40858. /**
  40859. * Gets or sets user defined metadata
  40860. */
  40861. metadata: any;
  40862. /**
  40863. * For internal use only. Please do not use.
  40864. */
  40865. reservedDataStore: any;
  40866. /**
  40867. * Gets the name of the plugin used to load this scene (null by default)
  40868. */
  40869. loadingPluginName: string;
  40870. /**
  40871. * Use this array to add regular expressions used to disable offline support for specific urls
  40872. */
  40873. disableOfflineSupportExceptionRules: RegExp[];
  40874. /**
  40875. * An event triggered when the scene is disposed.
  40876. */
  40877. onDisposeObservable: Observable<Scene>;
  40878. private _onDisposeObserver;
  40879. /** Sets a function to be executed when this scene is disposed. */
  40880. set onDispose(callback: () => void);
  40881. /**
  40882. * An event triggered before rendering the scene (right after animations and physics)
  40883. */
  40884. onBeforeRenderObservable: Observable<Scene>;
  40885. private _onBeforeRenderObserver;
  40886. /** Sets a function to be executed before rendering this scene */
  40887. set beforeRender(callback: Nullable<() => void>);
  40888. /**
  40889. * An event triggered after rendering the scene
  40890. */
  40891. onAfterRenderObservable: Observable<Scene>;
  40892. /**
  40893. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  40894. */
  40895. onAfterRenderCameraObservable: Observable<Camera>;
  40896. private _onAfterRenderObserver;
  40897. /** Sets a function to be executed after rendering this scene */
  40898. set afterRender(callback: Nullable<() => void>);
  40899. /**
  40900. * An event triggered before animating the scene
  40901. */
  40902. onBeforeAnimationsObservable: Observable<Scene>;
  40903. /**
  40904. * An event triggered after animations processing
  40905. */
  40906. onAfterAnimationsObservable: Observable<Scene>;
  40907. /**
  40908. * An event triggered before draw calls are ready to be sent
  40909. */
  40910. onBeforeDrawPhaseObservable: Observable<Scene>;
  40911. /**
  40912. * An event triggered after draw calls have been sent
  40913. */
  40914. onAfterDrawPhaseObservable: Observable<Scene>;
  40915. /**
  40916. * An event triggered when the scene is ready
  40917. */
  40918. onReadyObservable: Observable<Scene>;
  40919. /**
  40920. * An event triggered before rendering a camera
  40921. */
  40922. onBeforeCameraRenderObservable: Observable<Camera>;
  40923. private _onBeforeCameraRenderObserver;
  40924. /** Sets a function to be executed before rendering a camera*/
  40925. set beforeCameraRender(callback: () => void);
  40926. /**
  40927. * An event triggered after rendering a camera
  40928. */
  40929. onAfterCameraRenderObservable: Observable<Camera>;
  40930. private _onAfterCameraRenderObserver;
  40931. /** Sets a function to be executed after rendering a camera*/
  40932. set afterCameraRender(callback: () => void);
  40933. /**
  40934. * An event triggered when active meshes evaluation is about to start
  40935. */
  40936. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  40937. /**
  40938. * An event triggered when active meshes evaluation is done
  40939. */
  40940. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  40941. /**
  40942. * An event triggered when particles rendering is about to start
  40943. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40944. */
  40945. onBeforeParticlesRenderingObservable: Observable<Scene>;
  40946. /**
  40947. * An event triggered when particles rendering is done
  40948. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40949. */
  40950. onAfterParticlesRenderingObservable: Observable<Scene>;
  40951. /**
  40952. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  40953. */
  40954. onDataLoadedObservable: Observable<Scene>;
  40955. /**
  40956. * An event triggered when a camera is created
  40957. */
  40958. onNewCameraAddedObservable: Observable<Camera>;
  40959. /**
  40960. * An event triggered when a camera is removed
  40961. */
  40962. onCameraRemovedObservable: Observable<Camera>;
  40963. /**
  40964. * An event triggered when a light is created
  40965. */
  40966. onNewLightAddedObservable: Observable<Light>;
  40967. /**
  40968. * An event triggered when a light is removed
  40969. */
  40970. onLightRemovedObservable: Observable<Light>;
  40971. /**
  40972. * An event triggered when a geometry is created
  40973. */
  40974. onNewGeometryAddedObservable: Observable<Geometry>;
  40975. /**
  40976. * An event triggered when a geometry is removed
  40977. */
  40978. onGeometryRemovedObservable: Observable<Geometry>;
  40979. /**
  40980. * An event triggered when a transform node is created
  40981. */
  40982. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  40983. /**
  40984. * An event triggered when a transform node is removed
  40985. */
  40986. onTransformNodeRemovedObservable: Observable<TransformNode>;
  40987. /**
  40988. * An event triggered when a mesh is created
  40989. */
  40990. onNewMeshAddedObservable: Observable<AbstractMesh>;
  40991. /**
  40992. * An event triggered when a mesh is removed
  40993. */
  40994. onMeshRemovedObservable: Observable<AbstractMesh>;
  40995. /**
  40996. * An event triggered when a skeleton is created
  40997. */
  40998. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40999. /**
  41000. * An event triggered when a skeleton is removed
  41001. */
  41002. onSkeletonRemovedObservable: Observable<Skeleton>;
  41003. /**
  41004. * An event triggered when a material is created
  41005. */
  41006. onNewMaterialAddedObservable: Observable<Material>;
  41007. /**
  41008. * An event triggered when a material is removed
  41009. */
  41010. onMaterialRemovedObservable: Observable<Material>;
  41011. /**
  41012. * An event triggered when a texture is created
  41013. */
  41014. onNewTextureAddedObservable: Observable<BaseTexture>;
  41015. /**
  41016. * An event triggered when a texture is removed
  41017. */
  41018. onTextureRemovedObservable: Observable<BaseTexture>;
  41019. /**
  41020. * An event triggered when render targets are about to be rendered
  41021. * Can happen multiple times per frame.
  41022. */
  41023. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  41024. /**
  41025. * An event triggered when render targets were rendered.
  41026. * Can happen multiple times per frame.
  41027. */
  41028. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41029. /**
  41030. * An event triggered before calculating deterministic simulation step
  41031. */
  41032. onBeforeStepObservable: Observable<Scene>;
  41033. /**
  41034. * An event triggered after calculating deterministic simulation step
  41035. */
  41036. onAfterStepObservable: Observable<Scene>;
  41037. /**
  41038. * An event triggered when the activeCamera property is updated
  41039. */
  41040. onActiveCameraChanged: Observable<Scene>;
  41041. /**
  41042. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41043. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41044. * 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)
  41045. */
  41046. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41047. /**
  41048. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41049. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41050. * 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)
  41051. */
  41052. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41053. /**
  41054. * This Observable will when a mesh has been imported into the scene.
  41055. */
  41056. onMeshImportedObservable: Observable<AbstractMesh>;
  41057. /**
  41058. * This Observable will when an animation file has been imported into the scene.
  41059. */
  41060. onAnimationFileImportedObservable: Observable<Scene>;
  41061. /**
  41062. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41063. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41064. */
  41065. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41066. /** @hidden */
  41067. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41068. /**
  41069. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41070. */
  41071. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41072. /**
  41073. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41074. */
  41075. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41076. /**
  41077. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41078. */
  41079. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41080. /** Callback called when a pointer move is detected */
  41081. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41082. /** Callback called when a pointer down is detected */
  41083. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41084. /** Callback called when a pointer up is detected */
  41085. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41086. /** Callback called when a pointer pick is detected */
  41087. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41088. /**
  41089. * 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).
  41090. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41091. */
  41092. onPrePointerObservable: Observable<PointerInfoPre>;
  41093. /**
  41094. * Observable event triggered each time an input event is received from the rendering canvas
  41095. */
  41096. onPointerObservable: Observable<PointerInfo>;
  41097. /**
  41098. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41099. */
  41100. get unTranslatedPointer(): Vector2;
  41101. /**
  41102. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41103. */
  41104. static get DragMovementThreshold(): number;
  41105. static set DragMovementThreshold(value: number);
  41106. /**
  41107. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41108. */
  41109. static get LongPressDelay(): number;
  41110. static set LongPressDelay(value: number);
  41111. /**
  41112. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41113. */
  41114. static get DoubleClickDelay(): number;
  41115. static set DoubleClickDelay(value: number);
  41116. /** If you need to check double click without raising a single click at first click, enable this flag */
  41117. static get ExclusiveDoubleClickMode(): boolean;
  41118. static set ExclusiveDoubleClickMode(value: boolean);
  41119. /** @hidden */
  41120. _mirroredCameraPosition: Nullable<Vector3>;
  41121. /**
  41122. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41123. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41124. */
  41125. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41126. /**
  41127. * Observable event triggered each time an keyboard event is received from the hosting window
  41128. */
  41129. onKeyboardObservable: Observable<KeyboardInfo>;
  41130. private _useRightHandedSystem;
  41131. /**
  41132. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41133. */
  41134. set useRightHandedSystem(value: boolean);
  41135. get useRightHandedSystem(): boolean;
  41136. private _timeAccumulator;
  41137. private _currentStepId;
  41138. private _currentInternalStep;
  41139. /**
  41140. * Sets the step Id used by deterministic lock step
  41141. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41142. * @param newStepId defines the step Id
  41143. */
  41144. setStepId(newStepId: number): void;
  41145. /**
  41146. * Gets the step Id used by deterministic lock step
  41147. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41148. * @returns the step Id
  41149. */
  41150. getStepId(): number;
  41151. /**
  41152. * Gets the internal step used by deterministic lock step
  41153. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41154. * @returns the internal step
  41155. */
  41156. getInternalStep(): number;
  41157. private _fogEnabled;
  41158. /**
  41159. * Gets or sets a boolean indicating if fog is enabled on this scene
  41160. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41161. * (Default is true)
  41162. */
  41163. set fogEnabled(value: boolean);
  41164. get fogEnabled(): boolean;
  41165. private _fogMode;
  41166. /**
  41167. * Gets or sets the fog mode to use
  41168. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41169. * | mode | value |
  41170. * | --- | --- |
  41171. * | FOGMODE_NONE | 0 |
  41172. * | FOGMODE_EXP | 1 |
  41173. * | FOGMODE_EXP2 | 2 |
  41174. * | FOGMODE_LINEAR | 3 |
  41175. */
  41176. set fogMode(value: number);
  41177. get fogMode(): number;
  41178. /**
  41179. * Gets or sets the fog color to use
  41180. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41181. * (Default is Color3(0.2, 0.2, 0.3))
  41182. */
  41183. fogColor: Color3;
  41184. /**
  41185. * Gets or sets the fog density to use
  41186. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41187. * (Default is 0.1)
  41188. */
  41189. fogDensity: number;
  41190. /**
  41191. * Gets or sets the fog start distance to use
  41192. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41193. * (Default is 0)
  41194. */
  41195. fogStart: number;
  41196. /**
  41197. * Gets or sets the fog end distance to use
  41198. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41199. * (Default is 1000)
  41200. */
  41201. fogEnd: number;
  41202. /**
  41203. * Flag indicating that the frame buffer binding is handled by another component
  41204. */
  41205. prePass: boolean;
  41206. private _shadowsEnabled;
  41207. /**
  41208. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41209. */
  41210. set shadowsEnabled(value: boolean);
  41211. get shadowsEnabled(): boolean;
  41212. private _lightsEnabled;
  41213. /**
  41214. * Gets or sets a boolean indicating if lights are enabled on this scene
  41215. */
  41216. set lightsEnabled(value: boolean);
  41217. get lightsEnabled(): boolean;
  41218. /** All of the active cameras added to this scene. */
  41219. activeCameras: Camera[];
  41220. /** @hidden */
  41221. _activeCamera: Nullable<Camera>;
  41222. /** Gets or sets the current active camera */
  41223. get activeCamera(): Nullable<Camera>;
  41224. set activeCamera(value: Nullable<Camera>);
  41225. private _defaultMaterial;
  41226. /** The default material used on meshes when no material is affected */
  41227. get defaultMaterial(): Material;
  41228. /** The default material used on meshes when no material is affected */
  41229. set defaultMaterial(value: Material);
  41230. private _texturesEnabled;
  41231. /**
  41232. * Gets or sets a boolean indicating if textures are enabled on this scene
  41233. */
  41234. set texturesEnabled(value: boolean);
  41235. get texturesEnabled(): boolean;
  41236. /**
  41237. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41238. */
  41239. physicsEnabled: boolean;
  41240. /**
  41241. * Gets or sets a boolean indicating if particles are enabled on this scene
  41242. */
  41243. particlesEnabled: boolean;
  41244. /**
  41245. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41246. */
  41247. spritesEnabled: boolean;
  41248. private _skeletonsEnabled;
  41249. /**
  41250. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41251. */
  41252. set skeletonsEnabled(value: boolean);
  41253. get skeletonsEnabled(): boolean;
  41254. /**
  41255. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41256. */
  41257. lensFlaresEnabled: boolean;
  41258. /**
  41259. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41260. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41261. */
  41262. collisionsEnabled: boolean;
  41263. private _collisionCoordinator;
  41264. /** @hidden */
  41265. get collisionCoordinator(): ICollisionCoordinator;
  41266. /**
  41267. * Defines the gravity applied to this scene (used only for collisions)
  41268. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41269. */
  41270. gravity: Vector3;
  41271. /**
  41272. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41273. */
  41274. postProcessesEnabled: boolean;
  41275. /**
  41276. * Gets the current postprocess manager
  41277. */
  41278. postProcessManager: PostProcessManager;
  41279. /**
  41280. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41281. */
  41282. renderTargetsEnabled: boolean;
  41283. /**
  41284. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41285. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41286. */
  41287. dumpNextRenderTargets: boolean;
  41288. /**
  41289. * The list of user defined render targets added to the scene
  41290. */
  41291. customRenderTargets: RenderTargetTexture[];
  41292. /**
  41293. * Defines if texture loading must be delayed
  41294. * If true, textures will only be loaded when they need to be rendered
  41295. */
  41296. useDelayedTextureLoading: boolean;
  41297. /**
  41298. * Gets the list of meshes imported to the scene through SceneLoader
  41299. */
  41300. importedMeshesFiles: String[];
  41301. /**
  41302. * Gets or sets a boolean indicating if probes are enabled on this scene
  41303. */
  41304. probesEnabled: boolean;
  41305. /**
  41306. * Gets or sets the current offline provider to use to store scene data
  41307. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41308. */
  41309. offlineProvider: IOfflineProvider;
  41310. /**
  41311. * Gets or sets the action manager associated with the scene
  41312. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41313. */
  41314. actionManager: AbstractActionManager;
  41315. private _meshesForIntersections;
  41316. /**
  41317. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41318. */
  41319. proceduralTexturesEnabled: boolean;
  41320. private _engine;
  41321. private _totalVertices;
  41322. /** @hidden */
  41323. _activeIndices: PerfCounter;
  41324. /** @hidden */
  41325. _activeParticles: PerfCounter;
  41326. /** @hidden */
  41327. _activeBones: PerfCounter;
  41328. private _animationRatio;
  41329. /** @hidden */
  41330. _animationTimeLast: number;
  41331. /** @hidden */
  41332. _animationTime: number;
  41333. /**
  41334. * Gets or sets a general scale for animation speed
  41335. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41336. */
  41337. animationTimeScale: number;
  41338. /** @hidden */
  41339. _cachedMaterial: Nullable<Material>;
  41340. /** @hidden */
  41341. _cachedEffect: Nullable<Effect>;
  41342. /** @hidden */
  41343. _cachedVisibility: Nullable<number>;
  41344. private _renderId;
  41345. private _frameId;
  41346. private _executeWhenReadyTimeoutId;
  41347. private _intermediateRendering;
  41348. private _viewUpdateFlag;
  41349. private _projectionUpdateFlag;
  41350. /** @hidden */
  41351. _toBeDisposed: Nullable<IDisposable>[];
  41352. private _activeRequests;
  41353. /** @hidden */
  41354. _pendingData: any[];
  41355. private _isDisposed;
  41356. /**
  41357. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41358. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41359. */
  41360. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41361. private _activeMeshes;
  41362. private _processedMaterials;
  41363. private _renderTargets;
  41364. /** @hidden */
  41365. _activeParticleSystems: SmartArray<IParticleSystem>;
  41366. private _activeSkeletons;
  41367. private _softwareSkinnedMeshes;
  41368. private _renderingManager;
  41369. /** @hidden */
  41370. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41371. private _transformMatrix;
  41372. private _sceneUbo;
  41373. /** @hidden */
  41374. _viewMatrix: Matrix;
  41375. private _projectionMatrix;
  41376. /** @hidden */
  41377. _forcedViewPosition: Nullable<Vector3>;
  41378. /** @hidden */
  41379. _frustumPlanes: Plane[];
  41380. /**
  41381. * Gets the list of frustum planes (built from the active camera)
  41382. */
  41383. get frustumPlanes(): Plane[];
  41384. /**
  41385. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41386. * This is useful if there are more lights that the maximum simulteanous authorized
  41387. */
  41388. requireLightSorting: boolean;
  41389. /** @hidden */
  41390. readonly useMaterialMeshMap: boolean;
  41391. /** @hidden */
  41392. readonly useClonedMeshMap: boolean;
  41393. private _externalData;
  41394. private _uid;
  41395. /**
  41396. * @hidden
  41397. * Backing store of defined scene components.
  41398. */
  41399. _components: ISceneComponent[];
  41400. /**
  41401. * @hidden
  41402. * Backing store of defined scene components.
  41403. */
  41404. _serializableComponents: ISceneSerializableComponent[];
  41405. /**
  41406. * List of components to register on the next registration step.
  41407. */
  41408. private _transientComponents;
  41409. /**
  41410. * Registers the transient components if needed.
  41411. */
  41412. private _registerTransientComponents;
  41413. /**
  41414. * @hidden
  41415. * Add a component to the scene.
  41416. * Note that the ccomponent could be registered on th next frame if this is called after
  41417. * the register component stage.
  41418. * @param component Defines the component to add to the scene
  41419. */
  41420. _addComponent(component: ISceneComponent): void;
  41421. /**
  41422. * @hidden
  41423. * Gets a component from the scene.
  41424. * @param name defines the name of the component to retrieve
  41425. * @returns the component or null if not present
  41426. */
  41427. _getComponent(name: string): Nullable<ISceneComponent>;
  41428. /**
  41429. * @hidden
  41430. * Defines the actions happening before camera updates.
  41431. */
  41432. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41433. /**
  41434. * @hidden
  41435. * Defines the actions happening before clear the canvas.
  41436. */
  41437. _beforeClearStage: Stage<SimpleStageAction>;
  41438. /**
  41439. * @hidden
  41440. * Defines the actions when collecting render targets for the frame.
  41441. */
  41442. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41443. /**
  41444. * @hidden
  41445. * Defines the actions happening for one camera in the frame.
  41446. */
  41447. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41448. /**
  41449. * @hidden
  41450. * Defines the actions happening during the per mesh ready checks.
  41451. */
  41452. _isReadyForMeshStage: Stage<MeshStageAction>;
  41453. /**
  41454. * @hidden
  41455. * Defines the actions happening before evaluate active mesh checks.
  41456. */
  41457. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41458. /**
  41459. * @hidden
  41460. * Defines the actions happening during the evaluate sub mesh checks.
  41461. */
  41462. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41463. /**
  41464. * @hidden
  41465. * Defines the actions happening during the active mesh stage.
  41466. */
  41467. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41468. /**
  41469. * @hidden
  41470. * Defines the actions happening during the per camera render target step.
  41471. */
  41472. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41473. /**
  41474. * @hidden
  41475. * Defines the actions happening just before the active camera is drawing.
  41476. */
  41477. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41478. /**
  41479. * @hidden
  41480. * Defines the actions happening just before a render target is drawing.
  41481. */
  41482. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41483. /**
  41484. * @hidden
  41485. * Defines the actions happening just before a rendering group is drawing.
  41486. */
  41487. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41488. /**
  41489. * @hidden
  41490. * Defines the actions happening just before a mesh is drawing.
  41491. */
  41492. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41493. /**
  41494. * @hidden
  41495. * Defines the actions happening just after a mesh has been drawn.
  41496. */
  41497. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41498. /**
  41499. * @hidden
  41500. * Defines the actions happening just after a rendering group has been drawn.
  41501. */
  41502. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41503. /**
  41504. * @hidden
  41505. * Defines the actions happening just after the active camera has been drawn.
  41506. */
  41507. _afterCameraDrawStage: Stage<CameraStageAction>;
  41508. /**
  41509. * @hidden
  41510. * Defines the actions happening just after a render target has been drawn.
  41511. */
  41512. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41513. /**
  41514. * @hidden
  41515. * Defines the actions happening just after rendering all cameras and computing intersections.
  41516. */
  41517. _afterRenderStage: Stage<SimpleStageAction>;
  41518. /**
  41519. * @hidden
  41520. * Defines the actions happening when a pointer move event happens.
  41521. */
  41522. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41523. /**
  41524. * @hidden
  41525. * Defines the actions happening when a pointer down event happens.
  41526. */
  41527. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41528. /**
  41529. * @hidden
  41530. * Defines the actions happening when a pointer up event happens.
  41531. */
  41532. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41533. /**
  41534. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41535. */
  41536. private geometriesByUniqueId;
  41537. /**
  41538. * Creates a new Scene
  41539. * @param engine defines the engine to use to render this scene
  41540. * @param options defines the scene options
  41541. */
  41542. constructor(engine: Engine, options?: SceneOptions);
  41543. /**
  41544. * Gets a string identifying the name of the class
  41545. * @returns "Scene" string
  41546. */
  41547. getClassName(): string;
  41548. private _defaultMeshCandidates;
  41549. /**
  41550. * @hidden
  41551. */
  41552. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41553. private _defaultSubMeshCandidates;
  41554. /**
  41555. * @hidden
  41556. */
  41557. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41558. /**
  41559. * Sets the default candidate providers for the scene.
  41560. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41561. * and getCollidingSubMeshCandidates to their default function
  41562. */
  41563. setDefaultCandidateProviders(): void;
  41564. /**
  41565. * Gets the mesh that is currently under the pointer
  41566. */
  41567. get meshUnderPointer(): Nullable<AbstractMesh>;
  41568. /**
  41569. * Gets or sets the current on-screen X position of the pointer
  41570. */
  41571. get pointerX(): number;
  41572. set pointerX(value: number);
  41573. /**
  41574. * Gets or sets the current on-screen Y position of the pointer
  41575. */
  41576. get pointerY(): number;
  41577. set pointerY(value: number);
  41578. /**
  41579. * Gets the cached material (ie. the latest rendered one)
  41580. * @returns the cached material
  41581. */
  41582. getCachedMaterial(): Nullable<Material>;
  41583. /**
  41584. * Gets the cached effect (ie. the latest rendered one)
  41585. * @returns the cached effect
  41586. */
  41587. getCachedEffect(): Nullable<Effect>;
  41588. /**
  41589. * Gets the cached visibility state (ie. the latest rendered one)
  41590. * @returns the cached visibility state
  41591. */
  41592. getCachedVisibility(): Nullable<number>;
  41593. /**
  41594. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41595. * @param material defines the current material
  41596. * @param effect defines the current effect
  41597. * @param visibility defines the current visibility state
  41598. * @returns true if one parameter is not cached
  41599. */
  41600. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41601. /**
  41602. * Gets the engine associated with the scene
  41603. * @returns an Engine
  41604. */
  41605. getEngine(): Engine;
  41606. /**
  41607. * Gets the total number of vertices rendered per frame
  41608. * @returns the total number of vertices rendered per frame
  41609. */
  41610. getTotalVertices(): number;
  41611. /**
  41612. * Gets the performance counter for total vertices
  41613. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41614. */
  41615. get totalVerticesPerfCounter(): PerfCounter;
  41616. /**
  41617. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41618. * @returns the total number of active indices rendered per frame
  41619. */
  41620. getActiveIndices(): number;
  41621. /**
  41622. * Gets the performance counter for active indices
  41623. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41624. */
  41625. get totalActiveIndicesPerfCounter(): PerfCounter;
  41626. /**
  41627. * Gets the total number of active particles rendered per frame
  41628. * @returns the total number of active particles rendered per frame
  41629. */
  41630. getActiveParticles(): number;
  41631. /**
  41632. * Gets the performance counter for active particles
  41633. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41634. */
  41635. get activeParticlesPerfCounter(): PerfCounter;
  41636. /**
  41637. * Gets the total number of active bones rendered per frame
  41638. * @returns the total number of active bones rendered per frame
  41639. */
  41640. getActiveBones(): number;
  41641. /**
  41642. * Gets the performance counter for active bones
  41643. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41644. */
  41645. get activeBonesPerfCounter(): PerfCounter;
  41646. /**
  41647. * Gets the array of active meshes
  41648. * @returns an array of AbstractMesh
  41649. */
  41650. getActiveMeshes(): SmartArray<AbstractMesh>;
  41651. /**
  41652. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41653. * @returns a number
  41654. */
  41655. getAnimationRatio(): number;
  41656. /**
  41657. * Gets an unique Id for the current render phase
  41658. * @returns a number
  41659. */
  41660. getRenderId(): number;
  41661. /**
  41662. * Gets an unique Id for the current frame
  41663. * @returns a number
  41664. */
  41665. getFrameId(): number;
  41666. /** Call this function if you want to manually increment the render Id*/
  41667. incrementRenderId(): void;
  41668. private _createUbo;
  41669. /**
  41670. * Use this method to simulate a pointer move on a mesh
  41671. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41672. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41673. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41674. * @returns the current scene
  41675. */
  41676. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41677. /**
  41678. * Use this method to simulate a pointer down on a mesh
  41679. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41680. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41681. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41682. * @returns the current scene
  41683. */
  41684. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41685. /**
  41686. * Use this method to simulate a pointer up on a mesh
  41687. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41688. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41689. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41690. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41691. * @returns the current scene
  41692. */
  41693. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41694. /**
  41695. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41696. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41697. * @returns true if the pointer was captured
  41698. */
  41699. isPointerCaptured(pointerId?: number): boolean;
  41700. /**
  41701. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41702. * @param attachUp defines if you want to attach events to pointerup
  41703. * @param attachDown defines if you want to attach events to pointerdown
  41704. * @param attachMove defines if you want to attach events to pointermove
  41705. */
  41706. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41707. /** Detaches all event handlers*/
  41708. detachControl(): void;
  41709. /**
  41710. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41711. * Delay loaded resources are not taking in account
  41712. * @return true if all required resources are ready
  41713. */
  41714. isReady(): boolean;
  41715. /** Resets all cached information relative to material (including effect and visibility) */
  41716. resetCachedMaterial(): void;
  41717. /**
  41718. * Registers a function to be called before every frame render
  41719. * @param func defines the function to register
  41720. */
  41721. registerBeforeRender(func: () => void): void;
  41722. /**
  41723. * Unregisters a function called before every frame render
  41724. * @param func defines the function to unregister
  41725. */
  41726. unregisterBeforeRender(func: () => void): void;
  41727. /**
  41728. * Registers a function to be called after every frame render
  41729. * @param func defines the function to register
  41730. */
  41731. registerAfterRender(func: () => void): void;
  41732. /**
  41733. * Unregisters a function called after every frame render
  41734. * @param func defines the function to unregister
  41735. */
  41736. unregisterAfterRender(func: () => void): void;
  41737. private _executeOnceBeforeRender;
  41738. /**
  41739. * The provided function will run before render once and will be disposed afterwards.
  41740. * A timeout delay can be provided so that the function will be executed in N ms.
  41741. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41742. * @param func The function to be executed.
  41743. * @param timeout optional delay in ms
  41744. */
  41745. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41746. /** @hidden */
  41747. _addPendingData(data: any): void;
  41748. /** @hidden */
  41749. _removePendingData(data: any): void;
  41750. /**
  41751. * Returns the number of items waiting to be loaded
  41752. * @returns the number of items waiting to be loaded
  41753. */
  41754. getWaitingItemsCount(): number;
  41755. /**
  41756. * Returns a boolean indicating if the scene is still loading data
  41757. */
  41758. get isLoading(): boolean;
  41759. /**
  41760. * Registers a function to be executed when the scene is ready
  41761. * @param {Function} func - the function to be executed
  41762. */
  41763. executeWhenReady(func: () => void): void;
  41764. /**
  41765. * Returns a promise that resolves when the scene is ready
  41766. * @returns A promise that resolves when the scene is ready
  41767. */
  41768. whenReadyAsync(): Promise<void>;
  41769. /** @hidden */
  41770. _checkIsReady(): void;
  41771. /**
  41772. * Gets all animatable attached to the scene
  41773. */
  41774. get animatables(): Animatable[];
  41775. /**
  41776. * Resets the last animation time frame.
  41777. * Useful to override when animations start running when loading a scene for the first time.
  41778. */
  41779. resetLastAnimationTimeFrame(): void;
  41780. /**
  41781. * Gets the current view matrix
  41782. * @returns a Matrix
  41783. */
  41784. getViewMatrix(): Matrix;
  41785. /**
  41786. * Gets the current projection matrix
  41787. * @returns a Matrix
  41788. */
  41789. getProjectionMatrix(): Matrix;
  41790. /**
  41791. * Gets the current transform matrix
  41792. * @returns a Matrix made of View * Projection
  41793. */
  41794. getTransformMatrix(): Matrix;
  41795. /**
  41796. * Sets the current transform matrix
  41797. * @param viewL defines the View matrix to use
  41798. * @param projectionL defines the Projection matrix to use
  41799. * @param viewR defines the right View matrix to use (if provided)
  41800. * @param projectionR defines the right Projection matrix to use (if provided)
  41801. */
  41802. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41803. /**
  41804. * Gets the uniform buffer used to store scene data
  41805. * @returns a UniformBuffer
  41806. */
  41807. getSceneUniformBuffer(): UniformBuffer;
  41808. /**
  41809. * Gets an unique (relatively to the current scene) Id
  41810. * @returns an unique number for the scene
  41811. */
  41812. getUniqueId(): number;
  41813. /**
  41814. * Add a mesh to the list of scene's meshes
  41815. * @param newMesh defines the mesh to add
  41816. * @param recursive if all child meshes should also be added to the scene
  41817. */
  41818. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41819. /**
  41820. * Remove a mesh for the list of scene's meshes
  41821. * @param toRemove defines the mesh to remove
  41822. * @param recursive if all child meshes should also be removed from the scene
  41823. * @returns the index where the mesh was in the mesh list
  41824. */
  41825. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41826. /**
  41827. * Add a transform node to the list of scene's transform nodes
  41828. * @param newTransformNode defines the transform node to add
  41829. */
  41830. addTransformNode(newTransformNode: TransformNode): void;
  41831. /**
  41832. * Remove a transform node for the list of scene's transform nodes
  41833. * @param toRemove defines the transform node to remove
  41834. * @returns the index where the transform node was in the transform node list
  41835. */
  41836. removeTransformNode(toRemove: TransformNode): number;
  41837. /**
  41838. * Remove a skeleton for the list of scene's skeletons
  41839. * @param toRemove defines the skeleton to remove
  41840. * @returns the index where the skeleton was in the skeleton list
  41841. */
  41842. removeSkeleton(toRemove: Skeleton): number;
  41843. /**
  41844. * Remove a morph target for the list of scene's morph targets
  41845. * @param toRemove defines the morph target to remove
  41846. * @returns the index where the morph target was in the morph target list
  41847. */
  41848. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41849. /**
  41850. * Remove a light for the list of scene's lights
  41851. * @param toRemove defines the light to remove
  41852. * @returns the index where the light was in the light list
  41853. */
  41854. removeLight(toRemove: Light): number;
  41855. /**
  41856. * Remove a camera for the list of scene's cameras
  41857. * @param toRemove defines the camera to remove
  41858. * @returns the index where the camera was in the camera list
  41859. */
  41860. removeCamera(toRemove: Camera): number;
  41861. /**
  41862. * Remove a particle system for the list of scene's particle systems
  41863. * @param toRemove defines the particle system to remove
  41864. * @returns the index where the particle system was in the particle system list
  41865. */
  41866. removeParticleSystem(toRemove: IParticleSystem): number;
  41867. /**
  41868. * Remove a animation for the list of scene's animations
  41869. * @param toRemove defines the animation to remove
  41870. * @returns the index where the animation was in the animation list
  41871. */
  41872. removeAnimation(toRemove: Animation): number;
  41873. /**
  41874. * Will stop the animation of the given target
  41875. * @param target - the target
  41876. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  41877. * @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)
  41878. */
  41879. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  41880. /**
  41881. * Removes the given animation group from this scene.
  41882. * @param toRemove The animation group to remove
  41883. * @returns The index of the removed animation group
  41884. */
  41885. removeAnimationGroup(toRemove: AnimationGroup): number;
  41886. /**
  41887. * Removes the given multi-material from this scene.
  41888. * @param toRemove The multi-material to remove
  41889. * @returns The index of the removed multi-material
  41890. */
  41891. removeMultiMaterial(toRemove: MultiMaterial): number;
  41892. /**
  41893. * Removes the given material from this scene.
  41894. * @param toRemove The material to remove
  41895. * @returns The index of the removed material
  41896. */
  41897. removeMaterial(toRemove: Material): number;
  41898. /**
  41899. * Removes the given action manager from this scene.
  41900. * @param toRemove The action manager to remove
  41901. * @returns The index of the removed action manager
  41902. */
  41903. removeActionManager(toRemove: AbstractActionManager): number;
  41904. /**
  41905. * Removes the given texture from this scene.
  41906. * @param toRemove The texture to remove
  41907. * @returns The index of the removed texture
  41908. */
  41909. removeTexture(toRemove: BaseTexture): number;
  41910. /**
  41911. * Adds the given light to this scene
  41912. * @param newLight The light to add
  41913. */
  41914. addLight(newLight: Light): void;
  41915. /**
  41916. * Sorts the list list based on light priorities
  41917. */
  41918. sortLightsByPriority(): void;
  41919. /**
  41920. * Adds the given camera to this scene
  41921. * @param newCamera The camera to add
  41922. */
  41923. addCamera(newCamera: Camera): void;
  41924. /**
  41925. * Adds the given skeleton to this scene
  41926. * @param newSkeleton The skeleton to add
  41927. */
  41928. addSkeleton(newSkeleton: Skeleton): void;
  41929. /**
  41930. * Adds the given particle system to this scene
  41931. * @param newParticleSystem The particle system to add
  41932. */
  41933. addParticleSystem(newParticleSystem: IParticleSystem): void;
  41934. /**
  41935. * Adds the given animation to this scene
  41936. * @param newAnimation The animation to add
  41937. */
  41938. addAnimation(newAnimation: Animation): void;
  41939. /**
  41940. * Adds the given animation group to this scene.
  41941. * @param newAnimationGroup The animation group to add
  41942. */
  41943. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  41944. /**
  41945. * Adds the given multi-material to this scene
  41946. * @param newMultiMaterial The multi-material to add
  41947. */
  41948. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  41949. /**
  41950. * Adds the given material to this scene
  41951. * @param newMaterial The material to add
  41952. */
  41953. addMaterial(newMaterial: Material): void;
  41954. /**
  41955. * Adds the given morph target to this scene
  41956. * @param newMorphTargetManager The morph target to add
  41957. */
  41958. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  41959. /**
  41960. * Adds the given geometry to this scene
  41961. * @param newGeometry The geometry to add
  41962. */
  41963. addGeometry(newGeometry: Geometry): void;
  41964. /**
  41965. * Adds the given action manager to this scene
  41966. * @param newActionManager The action manager to add
  41967. */
  41968. addActionManager(newActionManager: AbstractActionManager): void;
  41969. /**
  41970. * Adds the given texture to this scene.
  41971. * @param newTexture The texture to add
  41972. */
  41973. addTexture(newTexture: BaseTexture): void;
  41974. /**
  41975. * Switch active camera
  41976. * @param newCamera defines the new active camera
  41977. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  41978. */
  41979. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  41980. /**
  41981. * sets the active camera of the scene using its ID
  41982. * @param id defines the camera's ID
  41983. * @return the new active camera or null if none found.
  41984. */
  41985. setActiveCameraByID(id: string): Nullable<Camera>;
  41986. /**
  41987. * sets the active camera of the scene using its name
  41988. * @param name defines the camera's name
  41989. * @returns the new active camera or null if none found.
  41990. */
  41991. setActiveCameraByName(name: string): Nullable<Camera>;
  41992. /**
  41993. * get an animation group using its name
  41994. * @param name defines the material's name
  41995. * @return the animation group or null if none found.
  41996. */
  41997. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41998. /**
  41999. * Get a material using its unique id
  42000. * @param uniqueId defines the material's unique id
  42001. * @return the material or null if none found.
  42002. */
  42003. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  42004. /**
  42005. * get a material using its id
  42006. * @param id defines the material's ID
  42007. * @return the material or null if none found.
  42008. */
  42009. getMaterialByID(id: string): Nullable<Material>;
  42010. /**
  42011. * Gets a the last added material using a given id
  42012. * @param id defines the material's ID
  42013. * @return the last material with the given id or null if none found.
  42014. */
  42015. getLastMaterialByID(id: string): Nullable<Material>;
  42016. /**
  42017. * Gets a material using its name
  42018. * @param name defines the material's name
  42019. * @return the material or null if none found.
  42020. */
  42021. getMaterialByName(name: string): Nullable<Material>;
  42022. /**
  42023. * Get a texture using its unique id
  42024. * @param uniqueId defines the texture's unique id
  42025. * @return the texture or null if none found.
  42026. */
  42027. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42028. /**
  42029. * Gets a camera using its id
  42030. * @param id defines the id to look for
  42031. * @returns the camera or null if not found
  42032. */
  42033. getCameraByID(id: string): Nullable<Camera>;
  42034. /**
  42035. * Gets a camera using its unique id
  42036. * @param uniqueId defines the unique id to look for
  42037. * @returns the camera or null if not found
  42038. */
  42039. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42040. /**
  42041. * Gets a camera using its name
  42042. * @param name defines the camera's name
  42043. * @return the camera or null if none found.
  42044. */
  42045. getCameraByName(name: string): Nullable<Camera>;
  42046. /**
  42047. * Gets a bone using its id
  42048. * @param id defines the bone's id
  42049. * @return the bone or null if not found
  42050. */
  42051. getBoneByID(id: string): Nullable<Bone>;
  42052. /**
  42053. * Gets a bone using its id
  42054. * @param name defines the bone's name
  42055. * @return the bone or null if not found
  42056. */
  42057. getBoneByName(name: string): Nullable<Bone>;
  42058. /**
  42059. * Gets a light node using its name
  42060. * @param name defines the the light's name
  42061. * @return the light or null if none found.
  42062. */
  42063. getLightByName(name: string): Nullable<Light>;
  42064. /**
  42065. * Gets a light node using its id
  42066. * @param id defines the light's id
  42067. * @return the light or null if none found.
  42068. */
  42069. getLightByID(id: string): Nullable<Light>;
  42070. /**
  42071. * Gets a light node using its scene-generated unique ID
  42072. * @param uniqueId defines the light's unique id
  42073. * @return the light or null if none found.
  42074. */
  42075. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42076. /**
  42077. * Gets a particle system by id
  42078. * @param id defines the particle system id
  42079. * @return the corresponding system or null if none found
  42080. */
  42081. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42082. /**
  42083. * Gets a geometry using its ID
  42084. * @param id defines the geometry's id
  42085. * @return the geometry or null if none found.
  42086. */
  42087. getGeometryByID(id: string): Nullable<Geometry>;
  42088. private _getGeometryByUniqueID;
  42089. /**
  42090. * Add a new geometry to this scene
  42091. * @param geometry defines the geometry to be added to the scene.
  42092. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42093. * @return a boolean defining if the geometry was added or not
  42094. */
  42095. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42096. /**
  42097. * Removes an existing geometry
  42098. * @param geometry defines the geometry to be removed from the scene
  42099. * @return a boolean defining if the geometry was removed or not
  42100. */
  42101. removeGeometry(geometry: Geometry): boolean;
  42102. /**
  42103. * Gets the list of geometries attached to the scene
  42104. * @returns an array of Geometry
  42105. */
  42106. getGeometries(): Geometry[];
  42107. /**
  42108. * Gets the first added mesh found of a given ID
  42109. * @param id defines the id to search for
  42110. * @return the mesh found or null if not found at all
  42111. */
  42112. getMeshByID(id: string): Nullable<AbstractMesh>;
  42113. /**
  42114. * Gets a list of meshes using their id
  42115. * @param id defines the id to search for
  42116. * @returns a list of meshes
  42117. */
  42118. getMeshesByID(id: string): Array<AbstractMesh>;
  42119. /**
  42120. * Gets the first added transform node found of a given ID
  42121. * @param id defines the id to search for
  42122. * @return the found transform node or null if not found at all.
  42123. */
  42124. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42125. /**
  42126. * Gets a transform node with its auto-generated unique id
  42127. * @param uniqueId efines the unique id to search for
  42128. * @return the found transform node or null if not found at all.
  42129. */
  42130. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42131. /**
  42132. * Gets a list of transform nodes using their id
  42133. * @param id defines the id to search for
  42134. * @returns a list of transform nodes
  42135. */
  42136. getTransformNodesByID(id: string): Array<TransformNode>;
  42137. /**
  42138. * Gets a mesh with its auto-generated unique id
  42139. * @param uniqueId defines the unique id to search for
  42140. * @return the found mesh or null if not found at all.
  42141. */
  42142. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42143. /**
  42144. * Gets a the last added mesh using a given id
  42145. * @param id defines the id to search for
  42146. * @return the found mesh or null if not found at all.
  42147. */
  42148. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42149. /**
  42150. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42151. * @param id defines the id to search for
  42152. * @return the found node or null if not found at all
  42153. */
  42154. getLastEntryByID(id: string): Nullable<Node>;
  42155. /**
  42156. * Gets a node (Mesh, Camera, Light) using a given id
  42157. * @param id defines the id to search for
  42158. * @return the found node or null if not found at all
  42159. */
  42160. getNodeByID(id: string): Nullable<Node>;
  42161. /**
  42162. * Gets a node (Mesh, Camera, Light) using a given name
  42163. * @param name defines the name to search for
  42164. * @return the found node or null if not found at all.
  42165. */
  42166. getNodeByName(name: string): Nullable<Node>;
  42167. /**
  42168. * Gets a mesh using a given name
  42169. * @param name defines the name to search for
  42170. * @return the found mesh or null if not found at all.
  42171. */
  42172. getMeshByName(name: string): Nullable<AbstractMesh>;
  42173. /**
  42174. * Gets a transform node using a given name
  42175. * @param name defines the name to search for
  42176. * @return the found transform node or null if not found at all.
  42177. */
  42178. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42179. /**
  42180. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42181. * @param id defines the id to search for
  42182. * @return the found skeleton or null if not found at all.
  42183. */
  42184. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42185. /**
  42186. * Gets a skeleton using a given auto generated unique id
  42187. * @param uniqueId defines the unique id to search for
  42188. * @return the found skeleton or null if not found at all.
  42189. */
  42190. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42191. /**
  42192. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42193. * @param id defines the id to search for
  42194. * @return the found skeleton or null if not found at all.
  42195. */
  42196. getSkeletonById(id: string): Nullable<Skeleton>;
  42197. /**
  42198. * Gets a skeleton using a given name
  42199. * @param name defines the name to search for
  42200. * @return the found skeleton or null if not found at all.
  42201. */
  42202. getSkeletonByName(name: string): Nullable<Skeleton>;
  42203. /**
  42204. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42205. * @param id defines the id to search for
  42206. * @return the found morph target manager or null if not found at all.
  42207. */
  42208. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42209. /**
  42210. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42211. * @param id defines the id to search for
  42212. * @return the found morph target or null if not found at all.
  42213. */
  42214. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42215. /**
  42216. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42217. * @param name defines the name to search for
  42218. * @return the found morph target or null if not found at all.
  42219. */
  42220. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42221. /**
  42222. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42223. * @param name defines the name to search for
  42224. * @return the found post process or null if not found at all.
  42225. */
  42226. getPostProcessByName(name: string): Nullable<PostProcess>;
  42227. /**
  42228. * Gets a boolean indicating if the given mesh is active
  42229. * @param mesh defines the mesh to look for
  42230. * @returns true if the mesh is in the active list
  42231. */
  42232. isActiveMesh(mesh: AbstractMesh): boolean;
  42233. /**
  42234. * Return a unique id as a string which can serve as an identifier for the scene
  42235. */
  42236. get uid(): string;
  42237. /**
  42238. * Add an externaly attached data from its key.
  42239. * This method call will fail and return false, if such key already exists.
  42240. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42241. * @param key the unique key that identifies the data
  42242. * @param data the data object to associate to the key for this Engine instance
  42243. * @return true if no such key were already present and the data was added successfully, false otherwise
  42244. */
  42245. addExternalData<T>(key: string, data: T): boolean;
  42246. /**
  42247. * Get an externaly attached data from its key
  42248. * @param key the unique key that identifies the data
  42249. * @return the associated data, if present (can be null), or undefined if not present
  42250. */
  42251. getExternalData<T>(key: string): Nullable<T>;
  42252. /**
  42253. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42254. * @param key the unique key that identifies the data
  42255. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42256. * @return the associated data, can be null if the factory returned null.
  42257. */
  42258. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42259. /**
  42260. * Remove an externaly attached data from the Engine instance
  42261. * @param key the unique key that identifies the data
  42262. * @return true if the data was successfully removed, false if it doesn't exist
  42263. */
  42264. removeExternalData(key: string): boolean;
  42265. private _evaluateSubMesh;
  42266. /**
  42267. * Clear the processed materials smart array preventing retention point in material dispose.
  42268. */
  42269. freeProcessedMaterials(): void;
  42270. private _preventFreeActiveMeshesAndRenderingGroups;
  42271. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42272. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42273. * when disposing several meshes in a row or a hierarchy of meshes.
  42274. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42275. */
  42276. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42277. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42278. /**
  42279. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42280. */
  42281. freeActiveMeshes(): void;
  42282. /**
  42283. * Clear the info related to rendering groups preventing retention points during dispose.
  42284. */
  42285. freeRenderingGroups(): void;
  42286. /** @hidden */
  42287. _isInIntermediateRendering(): boolean;
  42288. /**
  42289. * Lambda returning the list of potentially active meshes.
  42290. */
  42291. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42292. /**
  42293. * Lambda returning the list of potentially active sub meshes.
  42294. */
  42295. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42296. /**
  42297. * Lambda returning the list of potentially intersecting sub meshes.
  42298. */
  42299. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42300. /**
  42301. * Lambda returning the list of potentially colliding sub meshes.
  42302. */
  42303. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42304. private _activeMeshesFrozen;
  42305. private _skipEvaluateActiveMeshesCompletely;
  42306. /**
  42307. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42308. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42309. * @returns the current scene
  42310. */
  42311. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42312. /**
  42313. * Use this function to restart evaluating active meshes on every frame
  42314. * @returns the current scene
  42315. */
  42316. unfreezeActiveMeshes(): Scene;
  42317. private _evaluateActiveMeshes;
  42318. private _activeMesh;
  42319. /**
  42320. * Update the transform matrix to update from the current active camera
  42321. * @param force defines a boolean used to force the update even if cache is up to date
  42322. */
  42323. updateTransformMatrix(force?: boolean): void;
  42324. private _bindFrameBuffer;
  42325. /** @hidden */
  42326. _allowPostProcessClearColor: boolean;
  42327. /** @hidden */
  42328. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42329. private _processSubCameras;
  42330. private _checkIntersections;
  42331. /** @hidden */
  42332. _advancePhysicsEngineStep(step: number): void;
  42333. /**
  42334. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42335. */
  42336. getDeterministicFrameTime: () => number;
  42337. /** @hidden */
  42338. _animate(): void;
  42339. /** Execute all animations (for a frame) */
  42340. animate(): void;
  42341. /**
  42342. * Render the scene
  42343. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42344. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42345. */
  42346. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42347. /**
  42348. * Freeze all materials
  42349. * A frozen material will not be updatable but should be faster to render
  42350. */
  42351. freezeMaterials(): void;
  42352. /**
  42353. * Unfreeze all materials
  42354. * A frozen material will not be updatable but should be faster to render
  42355. */
  42356. unfreezeMaterials(): void;
  42357. /**
  42358. * Releases all held ressources
  42359. */
  42360. dispose(): void;
  42361. /**
  42362. * Gets if the scene is already disposed
  42363. */
  42364. get isDisposed(): boolean;
  42365. /**
  42366. * Call this function to reduce memory footprint of the scene.
  42367. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42368. */
  42369. clearCachedVertexData(): void;
  42370. /**
  42371. * This function will remove the local cached buffer data from texture.
  42372. * It will save memory but will prevent the texture from being rebuilt
  42373. */
  42374. cleanCachedTextureBuffer(): void;
  42375. /**
  42376. * Get the world extend vectors with an optional filter
  42377. *
  42378. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42379. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42380. */
  42381. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42382. min: Vector3;
  42383. max: Vector3;
  42384. };
  42385. /**
  42386. * Creates a ray that can be used to pick in the scene
  42387. * @param x defines the x coordinate of the origin (on-screen)
  42388. * @param y defines the y coordinate of the origin (on-screen)
  42389. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42390. * @param camera defines the camera to use for the picking
  42391. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42392. * @returns a Ray
  42393. */
  42394. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42395. /**
  42396. * Creates a ray that can be used to pick in the scene
  42397. * @param x defines the x coordinate of the origin (on-screen)
  42398. * @param y defines the y coordinate of the origin (on-screen)
  42399. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42400. * @param result defines the ray where to store the picking ray
  42401. * @param camera defines the camera to use for the picking
  42402. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42403. * @returns the current scene
  42404. */
  42405. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42406. /**
  42407. * Creates a ray that can be used to pick in the scene
  42408. * @param x defines the x coordinate of the origin (on-screen)
  42409. * @param y defines the y coordinate of the origin (on-screen)
  42410. * @param camera defines the camera to use for the picking
  42411. * @returns a Ray
  42412. */
  42413. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42414. /**
  42415. * Creates a ray that can be used to pick in the scene
  42416. * @param x defines the x coordinate of the origin (on-screen)
  42417. * @param y defines the y coordinate of the origin (on-screen)
  42418. * @param result defines the ray where to store the picking ray
  42419. * @param camera defines the camera to use for the picking
  42420. * @returns the current scene
  42421. */
  42422. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42423. /** Launch a ray to try to pick a mesh in the scene
  42424. * @param x position on screen
  42425. * @param y position on screen
  42426. * @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
  42427. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42428. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42429. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42430. * @returns a PickingInfo
  42431. */
  42432. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42433. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42434. * @param x position on screen
  42435. * @param y position on screen
  42436. * @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
  42437. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42438. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42439. * @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)
  42440. */
  42441. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42442. /** Use the given ray to pick a mesh in the scene
  42443. * @param ray The ray to use to pick meshes
  42444. * @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
  42445. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42446. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42447. * @returns a PickingInfo
  42448. */
  42449. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42450. /**
  42451. * Launch a ray to try to pick a mesh in the scene
  42452. * @param x X position on screen
  42453. * @param y Y position on screen
  42454. * @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
  42455. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42456. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42457. * @returns an array of PickingInfo
  42458. */
  42459. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42460. /**
  42461. * Launch a ray to try to pick a mesh in the scene
  42462. * @param ray Ray to use
  42463. * @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
  42464. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42465. * @returns an array of PickingInfo
  42466. */
  42467. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42468. /**
  42469. * Force the value of meshUnderPointer
  42470. * @param mesh defines the mesh to use
  42471. */
  42472. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  42473. /**
  42474. * Gets the mesh under the pointer
  42475. * @returns a Mesh or null if no mesh is under the pointer
  42476. */
  42477. getPointerOverMesh(): Nullable<AbstractMesh>;
  42478. /** @hidden */
  42479. _rebuildGeometries(): void;
  42480. /** @hidden */
  42481. _rebuildTextures(): void;
  42482. private _getByTags;
  42483. /**
  42484. * Get a list of meshes by tags
  42485. * @param tagsQuery defines the tags query to use
  42486. * @param forEach defines a predicate used to filter results
  42487. * @returns an array of Mesh
  42488. */
  42489. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42490. /**
  42491. * Get a list of cameras by tags
  42492. * @param tagsQuery defines the tags query to use
  42493. * @param forEach defines a predicate used to filter results
  42494. * @returns an array of Camera
  42495. */
  42496. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42497. /**
  42498. * Get a list of lights by tags
  42499. * @param tagsQuery defines the tags query to use
  42500. * @param forEach defines a predicate used to filter results
  42501. * @returns an array of Light
  42502. */
  42503. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42504. /**
  42505. * Get a list of materials by tags
  42506. * @param tagsQuery defines the tags query to use
  42507. * @param forEach defines a predicate used to filter results
  42508. * @returns an array of Material
  42509. */
  42510. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42511. /**
  42512. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42513. * This allowed control for front to back rendering or reversly depending of the special needs.
  42514. *
  42515. * @param renderingGroupId The rendering group id corresponding to its index
  42516. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42517. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42518. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42519. */
  42520. 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;
  42521. /**
  42522. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42523. *
  42524. * @param renderingGroupId The rendering group id corresponding to its index
  42525. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42526. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42527. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42528. */
  42529. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42530. /**
  42531. * Gets the current auto clear configuration for one rendering group of the rendering
  42532. * manager.
  42533. * @param index the rendering group index to get the information for
  42534. * @returns The auto clear setup for the requested rendering group
  42535. */
  42536. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42537. private _blockMaterialDirtyMechanism;
  42538. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42539. get blockMaterialDirtyMechanism(): boolean;
  42540. set blockMaterialDirtyMechanism(value: boolean);
  42541. /**
  42542. * Will flag all materials as dirty to trigger new shader compilation
  42543. * @param flag defines the flag used to specify which material part must be marked as dirty
  42544. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42545. */
  42546. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42547. /** @hidden */
  42548. _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;
  42549. /** @hidden */
  42550. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42551. /** @hidden */
  42552. _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;
  42553. /** @hidden */
  42554. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42555. /** @hidden */
  42556. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42557. /** @hidden */
  42558. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42559. }
  42560. }
  42561. declare module "babylonjs/assetContainer" {
  42562. import { AbstractScene } from "babylonjs/abstractScene";
  42563. import { Scene } from "babylonjs/scene";
  42564. import { Mesh } from "babylonjs/Meshes/mesh";
  42565. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42566. import { Skeleton } from "babylonjs/Bones/skeleton";
  42567. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42568. import { Animatable } from "babylonjs/Animations/animatable";
  42569. import { Nullable } from "babylonjs/types";
  42570. import { Node } from "babylonjs/node";
  42571. /**
  42572. * Set of assets to keep when moving a scene into an asset container.
  42573. */
  42574. export class KeepAssets extends AbstractScene {
  42575. }
  42576. /**
  42577. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42578. */
  42579. export class InstantiatedEntries {
  42580. /**
  42581. * List of new root nodes (eg. nodes with no parent)
  42582. */
  42583. rootNodes: TransformNode[];
  42584. /**
  42585. * List of new skeletons
  42586. */
  42587. skeletons: Skeleton[];
  42588. /**
  42589. * List of new animation groups
  42590. */
  42591. animationGroups: AnimationGroup[];
  42592. }
  42593. /**
  42594. * Container with a set of assets that can be added or removed from a scene.
  42595. */
  42596. export class AssetContainer extends AbstractScene {
  42597. private _wasAddedToScene;
  42598. /**
  42599. * The scene the AssetContainer belongs to.
  42600. */
  42601. scene: Scene;
  42602. /**
  42603. * Instantiates an AssetContainer.
  42604. * @param scene The scene the AssetContainer belongs to.
  42605. */
  42606. constructor(scene: Scene);
  42607. /**
  42608. * Instantiate or clone all meshes and add the new ones to the scene.
  42609. * Skeletons and animation groups will all be cloned
  42610. * @param nameFunction defines an optional function used to get new names for clones
  42611. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42612. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42613. */
  42614. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42615. /**
  42616. * Adds all the assets from the container to the scene.
  42617. */
  42618. addAllToScene(): void;
  42619. /**
  42620. * Removes all the assets in the container from the scene
  42621. */
  42622. removeAllFromScene(): void;
  42623. /**
  42624. * Disposes all the assets in the container
  42625. */
  42626. dispose(): void;
  42627. private _moveAssets;
  42628. /**
  42629. * Removes all the assets contained in the scene and adds them to the container.
  42630. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42631. */
  42632. moveAllFromScene(keepAssets?: KeepAssets): void;
  42633. /**
  42634. * 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.
  42635. * @returns the root mesh
  42636. */
  42637. createRootMesh(): Mesh;
  42638. /**
  42639. * Merge animations (direct and animation groups) from this asset container into a scene
  42640. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42641. * @param animatables set of animatables to retarget to a node from the scene
  42642. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42643. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42644. */
  42645. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42646. }
  42647. }
  42648. declare module "babylonjs/abstractScene" {
  42649. import { Scene } from "babylonjs/scene";
  42650. import { Nullable } from "babylonjs/types";
  42651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42652. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42653. import { Geometry } from "babylonjs/Meshes/geometry";
  42654. import { Skeleton } from "babylonjs/Bones/skeleton";
  42655. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42656. import { AssetContainer } from "babylonjs/assetContainer";
  42657. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42658. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42659. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42660. import { Material } from "babylonjs/Materials/material";
  42661. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42662. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42663. import { Camera } from "babylonjs/Cameras/camera";
  42664. import { Light } from "babylonjs/Lights/light";
  42665. import { Node } from "babylonjs/node";
  42666. import { Animation } from "babylonjs/Animations/animation";
  42667. /**
  42668. * Defines how the parser contract is defined.
  42669. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42670. */
  42671. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42672. /**
  42673. * Defines how the individual parser contract is defined.
  42674. * These parser can parse an individual asset
  42675. */
  42676. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42677. /**
  42678. * Base class of the scene acting as a container for the different elements composing a scene.
  42679. * This class is dynamically extended by the different components of the scene increasing
  42680. * flexibility and reducing coupling
  42681. */
  42682. export abstract class AbstractScene {
  42683. /**
  42684. * Stores the list of available parsers in the application.
  42685. */
  42686. private static _BabylonFileParsers;
  42687. /**
  42688. * Stores the list of available individual parsers in the application.
  42689. */
  42690. private static _IndividualBabylonFileParsers;
  42691. /**
  42692. * Adds a parser in the list of available ones
  42693. * @param name Defines the name of the parser
  42694. * @param parser Defines the parser to add
  42695. */
  42696. static AddParser(name: string, parser: BabylonFileParser): void;
  42697. /**
  42698. * Gets a general parser from the list of avaialble ones
  42699. * @param name Defines the name of the parser
  42700. * @returns the requested parser or null
  42701. */
  42702. static GetParser(name: string): Nullable<BabylonFileParser>;
  42703. /**
  42704. * Adds n individual parser in the list of available ones
  42705. * @param name Defines the name of the parser
  42706. * @param parser Defines the parser to add
  42707. */
  42708. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42709. /**
  42710. * Gets an individual parser from the list of avaialble ones
  42711. * @param name Defines the name of the parser
  42712. * @returns the requested parser or null
  42713. */
  42714. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42715. /**
  42716. * Parser json data and populate both a scene and its associated container object
  42717. * @param jsonData Defines the data to parse
  42718. * @param scene Defines the scene to parse the data for
  42719. * @param container Defines the container attached to the parsing sequence
  42720. * @param rootUrl Defines the root url of the data
  42721. */
  42722. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42723. /**
  42724. * Gets the list of root nodes (ie. nodes with no parent)
  42725. */
  42726. rootNodes: Node[];
  42727. /** All of the cameras added to this scene
  42728. * @see https://doc.babylonjs.com/babylon101/cameras
  42729. */
  42730. cameras: Camera[];
  42731. /**
  42732. * All of the lights added to this scene
  42733. * @see https://doc.babylonjs.com/babylon101/lights
  42734. */
  42735. lights: Light[];
  42736. /**
  42737. * All of the (abstract) meshes added to this scene
  42738. */
  42739. meshes: AbstractMesh[];
  42740. /**
  42741. * The list of skeletons added to the scene
  42742. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42743. */
  42744. skeletons: Skeleton[];
  42745. /**
  42746. * All of the particle systems added to this scene
  42747. * @see https://doc.babylonjs.com/babylon101/particles
  42748. */
  42749. particleSystems: IParticleSystem[];
  42750. /**
  42751. * Gets a list of Animations associated with the scene
  42752. */
  42753. animations: Animation[];
  42754. /**
  42755. * All of the animation groups added to this scene
  42756. * @see https://doc.babylonjs.com/how_to/group
  42757. */
  42758. animationGroups: AnimationGroup[];
  42759. /**
  42760. * All of the multi-materials added to this scene
  42761. * @see https://doc.babylonjs.com/how_to/multi_materials
  42762. */
  42763. multiMaterials: MultiMaterial[];
  42764. /**
  42765. * All of the materials added to this scene
  42766. * In the context of a Scene, it is not supposed to be modified manually.
  42767. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42768. * Note also that the order of the Material within the array is not significant and might change.
  42769. * @see https://doc.babylonjs.com/babylon101/materials
  42770. */
  42771. materials: Material[];
  42772. /**
  42773. * The list of morph target managers added to the scene
  42774. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42775. */
  42776. morphTargetManagers: MorphTargetManager[];
  42777. /**
  42778. * The list of geometries used in the scene.
  42779. */
  42780. geometries: Geometry[];
  42781. /**
  42782. * All of the tranform nodes added to this scene
  42783. * In the context of a Scene, it is not supposed to be modified manually.
  42784. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42785. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42786. * @see https://doc.babylonjs.com/how_to/transformnode
  42787. */
  42788. transformNodes: TransformNode[];
  42789. /**
  42790. * ActionManagers available on the scene.
  42791. */
  42792. actionManagers: AbstractActionManager[];
  42793. /**
  42794. * Textures to keep.
  42795. */
  42796. textures: BaseTexture[];
  42797. /**
  42798. * Environment texture for the scene
  42799. */
  42800. environmentTexture: Nullable<BaseTexture>;
  42801. /**
  42802. * The list of postprocesses added to the scene
  42803. */
  42804. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42805. /**
  42806. * @returns all meshes, lights, cameras, transformNodes and bones
  42807. */
  42808. getNodes(): Array<Node>;
  42809. }
  42810. }
  42811. declare module "babylonjs/Audio/sound" {
  42812. import { Observable } from "babylonjs/Misc/observable";
  42813. import { Vector3 } from "babylonjs/Maths/math.vector";
  42814. import { Nullable } from "babylonjs/types";
  42815. import { Scene } from "babylonjs/scene";
  42816. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42817. /**
  42818. * Interface used to define options for Sound class
  42819. */
  42820. export interface ISoundOptions {
  42821. /**
  42822. * Does the sound autoplay once loaded.
  42823. */
  42824. autoplay?: boolean;
  42825. /**
  42826. * Does the sound loop after it finishes playing once.
  42827. */
  42828. loop?: boolean;
  42829. /**
  42830. * Sound's volume
  42831. */
  42832. volume?: number;
  42833. /**
  42834. * Is it a spatial sound?
  42835. */
  42836. spatialSound?: boolean;
  42837. /**
  42838. * Maximum distance to hear that sound
  42839. */
  42840. maxDistance?: number;
  42841. /**
  42842. * Uses user defined attenuation function
  42843. */
  42844. useCustomAttenuation?: boolean;
  42845. /**
  42846. * Define the roll off factor of spatial sounds.
  42847. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42848. */
  42849. rolloffFactor?: number;
  42850. /**
  42851. * Define the reference distance the sound should be heard perfectly.
  42852. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42853. */
  42854. refDistance?: number;
  42855. /**
  42856. * Define the distance attenuation model the sound will follow.
  42857. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42858. */
  42859. distanceModel?: string;
  42860. /**
  42861. * Defines the playback speed (1 by default)
  42862. */
  42863. playbackRate?: number;
  42864. /**
  42865. * Defines if the sound is from a streaming source
  42866. */
  42867. streaming?: boolean;
  42868. /**
  42869. * Defines an optional length (in seconds) inside the sound file
  42870. */
  42871. length?: number;
  42872. /**
  42873. * Defines an optional offset (in seconds) inside the sound file
  42874. */
  42875. offset?: number;
  42876. /**
  42877. * If true, URLs will not be required to state the audio file codec to use.
  42878. */
  42879. skipCodecCheck?: boolean;
  42880. }
  42881. /**
  42882. * Defines a sound that can be played in the application.
  42883. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  42884. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42885. */
  42886. export class Sound {
  42887. /**
  42888. * The name of the sound in the scene.
  42889. */
  42890. name: string;
  42891. /**
  42892. * Does the sound autoplay once loaded.
  42893. */
  42894. autoplay: boolean;
  42895. /**
  42896. * Does the sound loop after it finishes playing once.
  42897. */
  42898. loop: boolean;
  42899. /**
  42900. * Does the sound use a custom attenuation curve to simulate the falloff
  42901. * happening when the source gets further away from the camera.
  42902. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42903. */
  42904. useCustomAttenuation: boolean;
  42905. /**
  42906. * The sound track id this sound belongs to.
  42907. */
  42908. soundTrackId: number;
  42909. /**
  42910. * Is this sound currently played.
  42911. */
  42912. isPlaying: boolean;
  42913. /**
  42914. * Is this sound currently paused.
  42915. */
  42916. isPaused: boolean;
  42917. /**
  42918. * Does this sound enables spatial sound.
  42919. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42920. */
  42921. spatialSound: boolean;
  42922. /**
  42923. * Define the reference distance the sound should be heard perfectly.
  42924. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42925. */
  42926. refDistance: number;
  42927. /**
  42928. * Define the roll off factor of spatial sounds.
  42929. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42930. */
  42931. rolloffFactor: number;
  42932. /**
  42933. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  42934. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42935. */
  42936. maxDistance: number;
  42937. /**
  42938. * Define the distance attenuation model the sound will follow.
  42939. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42940. */
  42941. distanceModel: string;
  42942. /**
  42943. * @hidden
  42944. * Back Compat
  42945. **/
  42946. onended: () => any;
  42947. /**
  42948. * Gets or sets an object used to store user defined information for the sound.
  42949. */
  42950. metadata: any;
  42951. /**
  42952. * Observable event when the current playing sound finishes.
  42953. */
  42954. onEndedObservable: Observable<Sound>;
  42955. private _panningModel;
  42956. private _playbackRate;
  42957. private _streaming;
  42958. private _startTime;
  42959. private _startOffset;
  42960. private _position;
  42961. /** @hidden */
  42962. _positionInEmitterSpace: boolean;
  42963. private _localDirection;
  42964. private _volume;
  42965. private _isReadyToPlay;
  42966. private _isDirectional;
  42967. private _readyToPlayCallback;
  42968. private _audioBuffer;
  42969. private _soundSource;
  42970. private _streamingSource;
  42971. private _soundPanner;
  42972. private _soundGain;
  42973. private _inputAudioNode;
  42974. private _outputAudioNode;
  42975. private _coneInnerAngle;
  42976. private _coneOuterAngle;
  42977. private _coneOuterGain;
  42978. private _scene;
  42979. private _connectedTransformNode;
  42980. private _customAttenuationFunction;
  42981. private _registerFunc;
  42982. private _isOutputConnected;
  42983. private _htmlAudioElement;
  42984. private _urlType;
  42985. private _length?;
  42986. private _offset?;
  42987. /** @hidden */
  42988. static _SceneComponentInitialization: (scene: Scene) => void;
  42989. /**
  42990. * Create a sound and attach it to a scene
  42991. * @param name Name of your sound
  42992. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  42993. * @param scene defines the scene the sound belongs to
  42994. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  42995. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  42996. */
  42997. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  42998. /**
  42999. * Release the sound and its associated resources
  43000. */
  43001. dispose(): void;
  43002. /**
  43003. * Gets if the sounds is ready to be played or not.
  43004. * @returns true if ready, otherwise false
  43005. */
  43006. isReady(): boolean;
  43007. private _soundLoaded;
  43008. /**
  43009. * Sets the data of the sound from an audiobuffer
  43010. * @param audioBuffer The audioBuffer containing the data
  43011. */
  43012. setAudioBuffer(audioBuffer: AudioBuffer): void;
  43013. /**
  43014. * Updates the current sounds options such as maxdistance, loop...
  43015. * @param options A JSON object containing values named as the object properties
  43016. */
  43017. updateOptions(options: ISoundOptions): void;
  43018. private _createSpatialParameters;
  43019. private _updateSpatialParameters;
  43020. /**
  43021. * Switch the panning model to HRTF:
  43022. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43023. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43024. */
  43025. switchPanningModelToHRTF(): void;
  43026. /**
  43027. * Switch the panning model to Equal Power:
  43028. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43029. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43030. */
  43031. switchPanningModelToEqualPower(): void;
  43032. private _switchPanningModel;
  43033. /**
  43034. * Connect this sound to a sound track audio node like gain...
  43035. * @param soundTrackAudioNode the sound track audio node to connect to
  43036. */
  43037. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43038. /**
  43039. * Transform this sound into a directional source
  43040. * @param coneInnerAngle Size of the inner cone in degree
  43041. * @param coneOuterAngle Size of the outer cone in degree
  43042. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43043. */
  43044. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43045. /**
  43046. * Gets or sets the inner angle for the directional cone.
  43047. */
  43048. get directionalConeInnerAngle(): number;
  43049. /**
  43050. * Gets or sets the inner angle for the directional cone.
  43051. */
  43052. set directionalConeInnerAngle(value: number);
  43053. /**
  43054. * Gets or sets the outer angle for the directional cone.
  43055. */
  43056. get directionalConeOuterAngle(): number;
  43057. /**
  43058. * Gets or sets the outer angle for the directional cone.
  43059. */
  43060. set directionalConeOuterAngle(value: number);
  43061. /**
  43062. * Sets the position of the emitter if spatial sound is enabled
  43063. * @param newPosition Defines the new posisiton
  43064. */
  43065. setPosition(newPosition: Vector3): void;
  43066. /**
  43067. * Sets the local direction of the emitter if spatial sound is enabled
  43068. * @param newLocalDirection Defines the new local direction
  43069. */
  43070. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43071. private _updateDirection;
  43072. /** @hidden */
  43073. updateDistanceFromListener(): void;
  43074. /**
  43075. * Sets a new custom attenuation function for the sound.
  43076. * @param callback Defines the function used for the attenuation
  43077. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43078. */
  43079. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43080. /**
  43081. * Play the sound
  43082. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43083. * @param offset (optional) Start the sound at a specific time in seconds
  43084. * @param length (optional) Sound duration (in seconds)
  43085. */
  43086. play(time?: number, offset?: number, length?: number): void;
  43087. private _onended;
  43088. /**
  43089. * Stop the sound
  43090. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43091. */
  43092. stop(time?: number): void;
  43093. /**
  43094. * Put the sound in pause
  43095. */
  43096. pause(): void;
  43097. /**
  43098. * Sets a dedicated volume for this sounds
  43099. * @param newVolume Define the new volume of the sound
  43100. * @param time Define time for gradual change to new volume
  43101. */
  43102. setVolume(newVolume: number, time?: number): void;
  43103. /**
  43104. * Set the sound play back rate
  43105. * @param newPlaybackRate Define the playback rate the sound should be played at
  43106. */
  43107. setPlaybackRate(newPlaybackRate: number): void;
  43108. /**
  43109. * Gets the volume of the sound.
  43110. * @returns the volume of the sound
  43111. */
  43112. getVolume(): number;
  43113. /**
  43114. * Attach the sound to a dedicated mesh
  43115. * @param transformNode The transform node to connect the sound with
  43116. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43117. */
  43118. attachToMesh(transformNode: TransformNode): void;
  43119. /**
  43120. * Detach the sound from the previously attached mesh
  43121. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43122. */
  43123. detachFromMesh(): void;
  43124. private _onRegisterAfterWorldMatrixUpdate;
  43125. /**
  43126. * Clone the current sound in the scene.
  43127. * @returns the new sound clone
  43128. */
  43129. clone(): Nullable<Sound>;
  43130. /**
  43131. * Gets the current underlying audio buffer containing the data
  43132. * @returns the audio buffer
  43133. */
  43134. getAudioBuffer(): Nullable<AudioBuffer>;
  43135. /**
  43136. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43137. * @returns the source node
  43138. */
  43139. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43140. /**
  43141. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43142. * @returns the gain node
  43143. */
  43144. getSoundGain(): Nullable<GainNode>;
  43145. /**
  43146. * Serializes the Sound in a JSON representation
  43147. * @returns the JSON representation of the sound
  43148. */
  43149. serialize(): any;
  43150. /**
  43151. * Parse a JSON representation of a sound to innstantiate in a given scene
  43152. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43153. * @param scene Define the scene the new parsed sound should be created in
  43154. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43155. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43156. * @returns the newly parsed sound
  43157. */
  43158. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43159. }
  43160. }
  43161. declare module "babylonjs/Actions/directAudioActions" {
  43162. import { Action } from "babylonjs/Actions/action";
  43163. import { Condition } from "babylonjs/Actions/condition";
  43164. import { Sound } from "babylonjs/Audio/sound";
  43165. /**
  43166. * This defines an action helpful to play a defined sound on a triggered action.
  43167. */
  43168. export class PlaySoundAction extends Action {
  43169. private _sound;
  43170. /**
  43171. * Instantiate the action
  43172. * @param triggerOptions defines the trigger options
  43173. * @param sound defines the sound to play
  43174. * @param condition defines the trigger related conditions
  43175. */
  43176. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43177. /** @hidden */
  43178. _prepare(): void;
  43179. /**
  43180. * Execute the action and play the sound.
  43181. */
  43182. execute(): void;
  43183. /**
  43184. * Serializes the actions and its related information.
  43185. * @param parent defines the object to serialize in
  43186. * @returns the serialized object
  43187. */
  43188. serialize(parent: any): any;
  43189. }
  43190. /**
  43191. * This defines an action helpful to stop a defined sound on a triggered action.
  43192. */
  43193. export class StopSoundAction extends Action {
  43194. private _sound;
  43195. /**
  43196. * Instantiate the action
  43197. * @param triggerOptions defines the trigger options
  43198. * @param sound defines the sound to stop
  43199. * @param condition defines the trigger related conditions
  43200. */
  43201. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43202. /** @hidden */
  43203. _prepare(): void;
  43204. /**
  43205. * Execute the action and stop the sound.
  43206. */
  43207. execute(): void;
  43208. /**
  43209. * Serializes the actions and its related information.
  43210. * @param parent defines the object to serialize in
  43211. * @returns the serialized object
  43212. */
  43213. serialize(parent: any): any;
  43214. }
  43215. }
  43216. declare module "babylonjs/Actions/interpolateValueAction" {
  43217. import { Action } from "babylonjs/Actions/action";
  43218. import { Condition } from "babylonjs/Actions/condition";
  43219. import { Observable } from "babylonjs/Misc/observable";
  43220. /**
  43221. * This defines an action responsible to change the value of a property
  43222. * by interpolating between its current value and the newly set one once triggered.
  43223. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43224. */
  43225. export class InterpolateValueAction extends Action {
  43226. /**
  43227. * Defines the path of the property where the value should be interpolated
  43228. */
  43229. propertyPath: string;
  43230. /**
  43231. * Defines the target value at the end of the interpolation.
  43232. */
  43233. value: any;
  43234. /**
  43235. * Defines the time it will take for the property to interpolate to the value.
  43236. */
  43237. duration: number;
  43238. /**
  43239. * Defines if the other scene animations should be stopped when the action has been triggered
  43240. */
  43241. stopOtherAnimations?: boolean;
  43242. /**
  43243. * Defines a callback raised once the interpolation animation has been done.
  43244. */
  43245. onInterpolationDone?: () => void;
  43246. /**
  43247. * Observable triggered once the interpolation animation has been done.
  43248. */
  43249. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43250. private _target;
  43251. private _effectiveTarget;
  43252. private _property;
  43253. /**
  43254. * Instantiate the action
  43255. * @param triggerOptions defines the trigger options
  43256. * @param target defines the object containing the value to interpolate
  43257. * @param propertyPath defines the path to the property in the target object
  43258. * @param value defines the target value at the end of the interpolation
  43259. * @param duration deines the time it will take for the property to interpolate to the value.
  43260. * @param condition defines the trigger related conditions
  43261. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43262. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43263. */
  43264. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43265. /** @hidden */
  43266. _prepare(): void;
  43267. /**
  43268. * Execute the action starts the value interpolation.
  43269. */
  43270. execute(): void;
  43271. /**
  43272. * Serializes the actions and its related information.
  43273. * @param parent defines the object to serialize in
  43274. * @returns the serialized object
  43275. */
  43276. serialize(parent: any): any;
  43277. }
  43278. }
  43279. declare module "babylonjs/Actions/index" {
  43280. export * from "babylonjs/Actions/abstractActionManager";
  43281. export * from "babylonjs/Actions/action";
  43282. export * from "babylonjs/Actions/actionEvent";
  43283. export * from "babylonjs/Actions/actionManager";
  43284. export * from "babylonjs/Actions/condition";
  43285. export * from "babylonjs/Actions/directActions";
  43286. export * from "babylonjs/Actions/directAudioActions";
  43287. export * from "babylonjs/Actions/interpolateValueAction";
  43288. }
  43289. declare module "babylonjs/Animations/index" {
  43290. export * from "babylonjs/Animations/animatable";
  43291. export * from "babylonjs/Animations/animation";
  43292. export * from "babylonjs/Animations/animationGroup";
  43293. export * from "babylonjs/Animations/animationPropertiesOverride";
  43294. export * from "babylonjs/Animations/easing";
  43295. export * from "babylonjs/Animations/runtimeAnimation";
  43296. export * from "babylonjs/Animations/animationEvent";
  43297. export * from "babylonjs/Animations/animationGroup";
  43298. export * from "babylonjs/Animations/animationKey";
  43299. export * from "babylonjs/Animations/animationRange";
  43300. export * from "babylonjs/Animations/animatable.interface";
  43301. }
  43302. declare module "babylonjs/Audio/soundTrack" {
  43303. import { Sound } from "babylonjs/Audio/sound";
  43304. import { Analyser } from "babylonjs/Audio/analyser";
  43305. import { Scene } from "babylonjs/scene";
  43306. /**
  43307. * Options allowed during the creation of a sound track.
  43308. */
  43309. export interface ISoundTrackOptions {
  43310. /**
  43311. * The volume the sound track should take during creation
  43312. */
  43313. volume?: number;
  43314. /**
  43315. * Define if the sound track is the main sound track of the scene
  43316. */
  43317. mainTrack?: boolean;
  43318. }
  43319. /**
  43320. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43321. * It will be also used in a future release to apply effects on a specific track.
  43322. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43323. */
  43324. export class SoundTrack {
  43325. /**
  43326. * The unique identifier of the sound track in the scene.
  43327. */
  43328. id: number;
  43329. /**
  43330. * The list of sounds included in the sound track.
  43331. */
  43332. soundCollection: Array<Sound>;
  43333. private _outputAudioNode;
  43334. private _scene;
  43335. private _connectedAnalyser;
  43336. private _options;
  43337. private _isInitialized;
  43338. /**
  43339. * Creates a new sound track.
  43340. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43341. * @param scene Define the scene the sound track belongs to
  43342. * @param options
  43343. */
  43344. constructor(scene: Scene, options?: ISoundTrackOptions);
  43345. private _initializeSoundTrackAudioGraph;
  43346. /**
  43347. * Release the sound track and its associated resources
  43348. */
  43349. dispose(): void;
  43350. /**
  43351. * Adds a sound to this sound track
  43352. * @param sound define the cound to add
  43353. * @ignoreNaming
  43354. */
  43355. AddSound(sound: Sound): void;
  43356. /**
  43357. * Removes a sound to this sound track
  43358. * @param sound define the cound to remove
  43359. * @ignoreNaming
  43360. */
  43361. RemoveSound(sound: Sound): void;
  43362. /**
  43363. * Set a global volume for the full sound track.
  43364. * @param newVolume Define the new volume of the sound track
  43365. */
  43366. setVolume(newVolume: number): void;
  43367. /**
  43368. * Switch the panning model to HRTF:
  43369. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43370. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43371. */
  43372. switchPanningModelToHRTF(): void;
  43373. /**
  43374. * Switch the panning model to Equal Power:
  43375. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43376. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43377. */
  43378. switchPanningModelToEqualPower(): void;
  43379. /**
  43380. * Connect the sound track to an audio analyser allowing some amazing
  43381. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43382. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43383. * @param analyser The analyser to connect to the engine
  43384. */
  43385. connectToAnalyser(analyser: Analyser): void;
  43386. }
  43387. }
  43388. declare module "babylonjs/Audio/audioSceneComponent" {
  43389. import { Sound } from "babylonjs/Audio/sound";
  43390. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43391. import { Nullable } from "babylonjs/types";
  43392. import { Vector3 } from "babylonjs/Maths/math.vector";
  43393. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43394. import { Scene } from "babylonjs/scene";
  43395. import { AbstractScene } from "babylonjs/abstractScene";
  43396. import "babylonjs/Audio/audioEngine";
  43397. module "babylonjs/abstractScene" {
  43398. interface AbstractScene {
  43399. /**
  43400. * The list of sounds used in the scene.
  43401. */
  43402. sounds: Nullable<Array<Sound>>;
  43403. }
  43404. }
  43405. module "babylonjs/scene" {
  43406. interface Scene {
  43407. /**
  43408. * @hidden
  43409. * Backing field
  43410. */
  43411. _mainSoundTrack: SoundTrack;
  43412. /**
  43413. * The main sound track played by the scene.
  43414. * It cotains your primary collection of sounds.
  43415. */
  43416. mainSoundTrack: SoundTrack;
  43417. /**
  43418. * The list of sound tracks added to the scene
  43419. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43420. */
  43421. soundTracks: Nullable<Array<SoundTrack>>;
  43422. /**
  43423. * Gets a sound using a given name
  43424. * @param name defines the name to search for
  43425. * @return the found sound or null if not found at all.
  43426. */
  43427. getSoundByName(name: string): Nullable<Sound>;
  43428. /**
  43429. * Gets or sets if audio support is enabled
  43430. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43431. */
  43432. audioEnabled: boolean;
  43433. /**
  43434. * Gets or sets if audio will be output to headphones
  43435. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43436. */
  43437. headphone: boolean;
  43438. /**
  43439. * Gets or sets custom audio listener position provider
  43440. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43441. */
  43442. audioListenerPositionProvider: Nullable<() => Vector3>;
  43443. /**
  43444. * Gets or sets a refresh rate when using 3D audio positioning
  43445. */
  43446. audioPositioningRefreshRate: number;
  43447. }
  43448. }
  43449. /**
  43450. * Defines the sound scene component responsible to manage any sounds
  43451. * in a given scene.
  43452. */
  43453. export class AudioSceneComponent implements ISceneSerializableComponent {
  43454. /**
  43455. * The component name helpfull to identify the component in the list of scene components.
  43456. */
  43457. readonly name: string;
  43458. /**
  43459. * The scene the component belongs to.
  43460. */
  43461. scene: Scene;
  43462. private _audioEnabled;
  43463. /**
  43464. * Gets whether audio is enabled or not.
  43465. * Please use related enable/disable method to switch state.
  43466. */
  43467. get audioEnabled(): boolean;
  43468. private _headphone;
  43469. /**
  43470. * Gets whether audio is outputing to headphone or not.
  43471. * Please use the according Switch methods to change output.
  43472. */
  43473. get headphone(): boolean;
  43474. /**
  43475. * Gets or sets a refresh rate when using 3D audio positioning
  43476. */
  43477. audioPositioningRefreshRate: number;
  43478. private _audioListenerPositionProvider;
  43479. /**
  43480. * Gets the current audio listener position provider
  43481. */
  43482. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43483. /**
  43484. * Sets a custom listener position for all sounds in the scene
  43485. * By default, this is the position of the first active camera
  43486. */
  43487. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43488. /**
  43489. * Creates a new instance of the component for the given scene
  43490. * @param scene Defines the scene to register the component in
  43491. */
  43492. constructor(scene: Scene);
  43493. /**
  43494. * Registers the component in a given scene
  43495. */
  43496. register(): void;
  43497. /**
  43498. * Rebuilds the elements related to this component in case of
  43499. * context lost for instance.
  43500. */
  43501. rebuild(): void;
  43502. /**
  43503. * Serializes the component data to the specified json object
  43504. * @param serializationObject The object to serialize to
  43505. */
  43506. serialize(serializationObject: any): void;
  43507. /**
  43508. * Adds all the elements from the container to the scene
  43509. * @param container the container holding the elements
  43510. */
  43511. addFromContainer(container: AbstractScene): void;
  43512. /**
  43513. * Removes all the elements in the container from the scene
  43514. * @param container contains the elements to remove
  43515. * @param dispose if the removed element should be disposed (default: false)
  43516. */
  43517. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43518. /**
  43519. * Disposes the component and the associated ressources.
  43520. */
  43521. dispose(): void;
  43522. /**
  43523. * Disables audio in the associated scene.
  43524. */
  43525. disableAudio(): void;
  43526. /**
  43527. * Enables audio in the associated scene.
  43528. */
  43529. enableAudio(): void;
  43530. /**
  43531. * Switch audio to headphone output.
  43532. */
  43533. switchAudioModeForHeadphones(): void;
  43534. /**
  43535. * Switch audio to normal speakers.
  43536. */
  43537. switchAudioModeForNormalSpeakers(): void;
  43538. private _cachedCameraDirection;
  43539. private _cachedCameraPosition;
  43540. private _lastCheck;
  43541. private _afterRender;
  43542. }
  43543. }
  43544. declare module "babylonjs/Audio/weightedsound" {
  43545. import { Sound } from "babylonjs/Audio/sound";
  43546. /**
  43547. * Wraps one or more Sound objects and selects one with random weight for playback.
  43548. */
  43549. export class WeightedSound {
  43550. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43551. loop: boolean;
  43552. private _coneInnerAngle;
  43553. private _coneOuterAngle;
  43554. private _volume;
  43555. /** A Sound is currently playing. */
  43556. isPlaying: boolean;
  43557. /** A Sound is currently paused. */
  43558. isPaused: boolean;
  43559. private _sounds;
  43560. private _weights;
  43561. private _currentIndex?;
  43562. /**
  43563. * Creates a new WeightedSound from the list of sounds given.
  43564. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43565. * @param sounds Array of Sounds that will be selected from.
  43566. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43567. */
  43568. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43569. /**
  43570. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43571. */
  43572. get directionalConeInnerAngle(): number;
  43573. /**
  43574. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43575. */
  43576. set directionalConeInnerAngle(value: number);
  43577. /**
  43578. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43579. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43580. */
  43581. get directionalConeOuterAngle(): number;
  43582. /**
  43583. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43584. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43585. */
  43586. set directionalConeOuterAngle(value: number);
  43587. /**
  43588. * Playback volume.
  43589. */
  43590. get volume(): number;
  43591. /**
  43592. * Playback volume.
  43593. */
  43594. set volume(value: number);
  43595. private _onended;
  43596. /**
  43597. * Suspend playback
  43598. */
  43599. pause(): void;
  43600. /**
  43601. * Stop playback
  43602. */
  43603. stop(): void;
  43604. /**
  43605. * Start playback.
  43606. * @param startOffset Position the clip head at a specific time in seconds.
  43607. */
  43608. play(startOffset?: number): void;
  43609. }
  43610. }
  43611. declare module "babylonjs/Audio/index" {
  43612. export * from "babylonjs/Audio/analyser";
  43613. export * from "babylonjs/Audio/audioEngine";
  43614. export * from "babylonjs/Audio/audioSceneComponent";
  43615. export * from "babylonjs/Audio/sound";
  43616. export * from "babylonjs/Audio/soundTrack";
  43617. export * from "babylonjs/Audio/weightedsound";
  43618. }
  43619. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43620. import { Behavior } from "babylonjs/Behaviors/behavior";
  43621. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43622. import { BackEase } from "babylonjs/Animations/easing";
  43623. /**
  43624. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43625. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43626. */
  43627. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43628. /**
  43629. * Gets the name of the behavior.
  43630. */
  43631. get name(): string;
  43632. /**
  43633. * The easing function used by animations
  43634. */
  43635. static EasingFunction: BackEase;
  43636. /**
  43637. * The easing mode used by animations
  43638. */
  43639. static EasingMode: number;
  43640. /**
  43641. * The duration of the animation, in milliseconds
  43642. */
  43643. transitionDuration: number;
  43644. /**
  43645. * Length of the distance animated by the transition when lower radius is reached
  43646. */
  43647. lowerRadiusTransitionRange: number;
  43648. /**
  43649. * Length of the distance animated by the transition when upper radius is reached
  43650. */
  43651. upperRadiusTransitionRange: number;
  43652. private _autoTransitionRange;
  43653. /**
  43654. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43655. */
  43656. get autoTransitionRange(): boolean;
  43657. /**
  43658. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43659. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43660. */
  43661. set autoTransitionRange(value: boolean);
  43662. private _attachedCamera;
  43663. private _onAfterCheckInputsObserver;
  43664. private _onMeshTargetChangedObserver;
  43665. /**
  43666. * Initializes the behavior.
  43667. */
  43668. init(): void;
  43669. /**
  43670. * Attaches the behavior to its arc rotate camera.
  43671. * @param camera Defines the camera to attach the behavior to
  43672. */
  43673. attach(camera: ArcRotateCamera): void;
  43674. /**
  43675. * Detaches the behavior from its current arc rotate camera.
  43676. */
  43677. detach(): void;
  43678. private _radiusIsAnimating;
  43679. private _radiusBounceTransition;
  43680. private _animatables;
  43681. private _cachedWheelPrecision;
  43682. /**
  43683. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43684. * @param radiusLimit The limit to check against.
  43685. * @return Bool to indicate if at limit.
  43686. */
  43687. private _isRadiusAtLimit;
  43688. /**
  43689. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43690. * @param radiusDelta The delta by which to animate to. Can be negative.
  43691. */
  43692. private _applyBoundRadiusAnimation;
  43693. /**
  43694. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43695. */
  43696. protected _clearAnimationLocks(): void;
  43697. /**
  43698. * Stops and removes all animations that have been applied to the camera
  43699. */
  43700. stopAllAnimations(): void;
  43701. }
  43702. }
  43703. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43704. import { Behavior } from "babylonjs/Behaviors/behavior";
  43705. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43706. import { ExponentialEase } from "babylonjs/Animations/easing";
  43707. import { Nullable } from "babylonjs/types";
  43708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43709. import { Vector3 } from "babylonjs/Maths/math.vector";
  43710. /**
  43711. * 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.
  43712. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43713. */
  43714. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43715. /**
  43716. * Gets the name of the behavior.
  43717. */
  43718. get name(): string;
  43719. private _mode;
  43720. private _radiusScale;
  43721. private _positionScale;
  43722. private _defaultElevation;
  43723. private _elevationReturnTime;
  43724. private _elevationReturnWaitTime;
  43725. private _zoomStopsAnimation;
  43726. private _framingTime;
  43727. /**
  43728. * The easing function used by animations
  43729. */
  43730. static EasingFunction: ExponentialEase;
  43731. /**
  43732. * The easing mode used by animations
  43733. */
  43734. static EasingMode: number;
  43735. /**
  43736. * Sets the current mode used by the behavior
  43737. */
  43738. set mode(mode: number);
  43739. /**
  43740. * Gets current mode used by the behavior.
  43741. */
  43742. get mode(): number;
  43743. /**
  43744. * Sets the scale applied to the radius (1 by default)
  43745. */
  43746. set radiusScale(radius: number);
  43747. /**
  43748. * Gets the scale applied to the radius
  43749. */
  43750. get radiusScale(): number;
  43751. /**
  43752. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43753. */
  43754. set positionScale(scale: number);
  43755. /**
  43756. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43757. */
  43758. get positionScale(): number;
  43759. /**
  43760. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43761. * behaviour is triggered, in radians.
  43762. */
  43763. set defaultElevation(elevation: number);
  43764. /**
  43765. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43766. * behaviour is triggered, in radians.
  43767. */
  43768. get defaultElevation(): number;
  43769. /**
  43770. * Sets the time (in milliseconds) taken to return to the default beta position.
  43771. * Negative value indicates camera should not return to default.
  43772. */
  43773. set elevationReturnTime(speed: number);
  43774. /**
  43775. * Gets the time (in milliseconds) taken to return to the default beta position.
  43776. * Negative value indicates camera should not return to default.
  43777. */
  43778. get elevationReturnTime(): number;
  43779. /**
  43780. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43781. */
  43782. set elevationReturnWaitTime(time: number);
  43783. /**
  43784. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43785. */
  43786. get elevationReturnWaitTime(): number;
  43787. /**
  43788. * Sets the flag that indicates if user zooming should stop animation.
  43789. */
  43790. set zoomStopsAnimation(flag: boolean);
  43791. /**
  43792. * Gets the flag that indicates if user zooming should stop animation.
  43793. */
  43794. get zoomStopsAnimation(): boolean;
  43795. /**
  43796. * Sets the transition time when framing the mesh, in milliseconds
  43797. */
  43798. set framingTime(time: number);
  43799. /**
  43800. * Gets the transition time when framing the mesh, in milliseconds
  43801. */
  43802. get framingTime(): number;
  43803. /**
  43804. * Define if the behavior should automatically change the configured
  43805. * camera limits and sensibilities.
  43806. */
  43807. autoCorrectCameraLimitsAndSensibility: boolean;
  43808. private _onPrePointerObservableObserver;
  43809. private _onAfterCheckInputsObserver;
  43810. private _onMeshTargetChangedObserver;
  43811. private _attachedCamera;
  43812. private _isPointerDown;
  43813. private _lastInteractionTime;
  43814. /**
  43815. * Initializes the behavior.
  43816. */
  43817. init(): void;
  43818. /**
  43819. * Attaches the behavior to its arc rotate camera.
  43820. * @param camera Defines the camera to attach the behavior to
  43821. */
  43822. attach(camera: ArcRotateCamera): void;
  43823. /**
  43824. * Detaches the behavior from its current arc rotate camera.
  43825. */
  43826. detach(): void;
  43827. private _animatables;
  43828. private _betaIsAnimating;
  43829. private _betaTransition;
  43830. private _radiusTransition;
  43831. private _vectorTransition;
  43832. /**
  43833. * Targets the given mesh and updates zoom level accordingly.
  43834. * @param mesh The mesh to target.
  43835. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43836. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43837. */
  43838. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43839. /**
  43840. * Targets the given mesh with its children and updates zoom level accordingly.
  43841. * @param mesh The mesh to target.
  43842. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43843. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43844. */
  43845. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43846. /**
  43847. * Targets the given meshes with their children and updates zoom level accordingly.
  43848. * @param meshes The mesh to target.
  43849. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43850. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43851. */
  43852. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43853. /**
  43854. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  43855. * @param minimumWorld Determines the smaller position of the bounding box extend
  43856. * @param maximumWorld Determines the bigger position of the bounding box extend
  43857. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43858. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43859. */
  43860. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43861. /**
  43862. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  43863. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  43864. * frustum width.
  43865. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  43866. * to fully enclose the mesh in the viewing frustum.
  43867. */
  43868. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  43869. /**
  43870. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  43871. * is automatically returned to its default position (expected to be above ground plane).
  43872. */
  43873. private _maintainCameraAboveGround;
  43874. /**
  43875. * Returns the frustum slope based on the canvas ratio and camera FOV
  43876. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  43877. */
  43878. private _getFrustumSlope;
  43879. /**
  43880. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  43881. */
  43882. private _clearAnimationLocks;
  43883. /**
  43884. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43885. */
  43886. private _applyUserInteraction;
  43887. /**
  43888. * Stops and removes all animations that have been applied to the camera
  43889. */
  43890. stopAllAnimations(): void;
  43891. /**
  43892. * Gets a value indicating if the user is moving the camera
  43893. */
  43894. get isUserIsMoving(): boolean;
  43895. /**
  43896. * The camera can move all the way towards the mesh.
  43897. */
  43898. static IgnoreBoundsSizeMode: number;
  43899. /**
  43900. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  43901. */
  43902. static FitFrustumSidesMode: number;
  43903. }
  43904. }
  43905. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  43906. import { Nullable } from "babylonjs/types";
  43907. import { Camera } from "babylonjs/Cameras/camera";
  43908. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43909. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43910. /**
  43911. * Base class for Camera Pointer Inputs.
  43912. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  43913. * for example usage.
  43914. */
  43915. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  43916. /**
  43917. * Defines the camera the input is attached to.
  43918. */
  43919. abstract camera: Camera;
  43920. /**
  43921. * Whether keyboard modifier keys are pressed at time of last mouse event.
  43922. */
  43923. protected _altKey: boolean;
  43924. protected _ctrlKey: boolean;
  43925. protected _metaKey: boolean;
  43926. protected _shiftKey: boolean;
  43927. /**
  43928. * Which mouse buttons were pressed at time of last mouse event.
  43929. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  43930. */
  43931. protected _buttonsPressed: number;
  43932. /**
  43933. * Defines the buttons associated with the input to handle camera move.
  43934. */
  43935. buttons: number[];
  43936. /**
  43937. * Attach the input controls to a specific dom element to get the input from.
  43938. * @param element Defines the element the controls should be listened from
  43939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43940. */
  43941. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43942. /**
  43943. * Detach the current controls from the specified dom element.
  43944. * @param element Defines the element to stop listening the inputs from
  43945. */
  43946. detachControl(element: Nullable<HTMLElement>): void;
  43947. /**
  43948. * Gets the class name of the current input.
  43949. * @returns the class name
  43950. */
  43951. getClassName(): string;
  43952. /**
  43953. * Get the friendly name associated with the input class.
  43954. * @returns the input friendly name
  43955. */
  43956. getSimpleName(): string;
  43957. /**
  43958. * Called on pointer POINTERDOUBLETAP event.
  43959. * Override this method to provide functionality on POINTERDOUBLETAP event.
  43960. */
  43961. protected onDoubleTap(type: string): void;
  43962. /**
  43963. * Called on pointer POINTERMOVE event if only a single touch is active.
  43964. * Override this method to provide functionality.
  43965. */
  43966. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43967. /**
  43968. * Called on pointer POINTERMOVE event if multiple touches are active.
  43969. * Override this method to provide functionality.
  43970. */
  43971. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43972. /**
  43973. * Called on JS contextmenu event.
  43974. * Override this method to provide functionality.
  43975. */
  43976. protected onContextMenu(evt: PointerEvent): void;
  43977. /**
  43978. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43979. * press.
  43980. * Override this method to provide functionality.
  43981. */
  43982. protected onButtonDown(evt: PointerEvent): void;
  43983. /**
  43984. * Called each time a new POINTERUP event occurs. Ie, for each button
  43985. * release.
  43986. * Override this method to provide functionality.
  43987. */
  43988. protected onButtonUp(evt: PointerEvent): void;
  43989. /**
  43990. * Called when window becomes inactive.
  43991. * Override this method to provide functionality.
  43992. */
  43993. protected onLostFocus(): void;
  43994. private _pointerInput;
  43995. private _observer;
  43996. private _onLostFocus;
  43997. private pointA;
  43998. private pointB;
  43999. }
  44000. }
  44001. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  44002. import { Nullable } from "babylonjs/types";
  44003. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44004. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44005. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44006. /**
  44007. * Manage the pointers inputs to control an arc rotate camera.
  44008. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44009. */
  44010. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  44011. /**
  44012. * Defines the camera the input is attached to.
  44013. */
  44014. camera: ArcRotateCamera;
  44015. /**
  44016. * Gets the class name of the current input.
  44017. * @returns the class name
  44018. */
  44019. getClassName(): string;
  44020. /**
  44021. * Defines the buttons associated with the input to handle camera move.
  44022. */
  44023. buttons: number[];
  44024. /**
  44025. * Defines the pointer angular sensibility along the X axis or how fast is
  44026. * the camera rotating.
  44027. */
  44028. angularSensibilityX: number;
  44029. /**
  44030. * Defines the pointer angular sensibility along the Y axis or how fast is
  44031. * the camera rotating.
  44032. */
  44033. angularSensibilityY: number;
  44034. /**
  44035. * Defines the pointer pinch precision or how fast is the camera zooming.
  44036. */
  44037. pinchPrecision: number;
  44038. /**
  44039. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44040. * from 0.
  44041. * It defines the percentage of current camera.radius to use as delta when
  44042. * pinch zoom is used.
  44043. */
  44044. pinchDeltaPercentage: number;
  44045. /**
  44046. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44047. * that any object in the plane at the camera's target point will scale
  44048. * perfectly with finger motion.
  44049. * Overrides pinchDeltaPercentage and pinchPrecision.
  44050. */
  44051. useNaturalPinchZoom: boolean;
  44052. /**
  44053. * Defines the pointer panning sensibility or how fast is the camera moving.
  44054. */
  44055. panningSensibility: number;
  44056. /**
  44057. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44058. */
  44059. multiTouchPanning: boolean;
  44060. /**
  44061. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44062. * zoom (pinch) through multitouch.
  44063. */
  44064. multiTouchPanAndZoom: boolean;
  44065. /**
  44066. * Revers pinch action direction.
  44067. */
  44068. pinchInwards: boolean;
  44069. private _isPanClick;
  44070. private _twoFingerActivityCount;
  44071. private _isPinching;
  44072. /**
  44073. * Called on pointer POINTERMOVE event if only a single touch is active.
  44074. */
  44075. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44076. /**
  44077. * Called on pointer POINTERDOUBLETAP event.
  44078. */
  44079. protected onDoubleTap(type: string): void;
  44080. /**
  44081. * Called on pointer POINTERMOVE event if multiple touches are active.
  44082. */
  44083. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44084. /**
  44085. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44086. * press.
  44087. */
  44088. protected onButtonDown(evt: PointerEvent): void;
  44089. /**
  44090. * Called each time a new POINTERUP event occurs. Ie, for each button
  44091. * release.
  44092. */
  44093. protected onButtonUp(evt: PointerEvent): void;
  44094. /**
  44095. * Called when window becomes inactive.
  44096. */
  44097. protected onLostFocus(): void;
  44098. }
  44099. }
  44100. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44101. import { Nullable } from "babylonjs/types";
  44102. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44103. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44104. /**
  44105. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44106. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44107. */
  44108. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44109. /**
  44110. * Defines the camera the input is attached to.
  44111. */
  44112. camera: ArcRotateCamera;
  44113. /**
  44114. * Defines the list of key codes associated with the up action (increase alpha)
  44115. */
  44116. keysUp: number[];
  44117. /**
  44118. * Defines the list of key codes associated with the down action (decrease alpha)
  44119. */
  44120. keysDown: number[];
  44121. /**
  44122. * Defines the list of key codes associated with the left action (increase beta)
  44123. */
  44124. keysLeft: number[];
  44125. /**
  44126. * Defines the list of key codes associated with the right action (decrease beta)
  44127. */
  44128. keysRight: number[];
  44129. /**
  44130. * Defines the list of key codes associated with the reset action.
  44131. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44132. */
  44133. keysReset: number[];
  44134. /**
  44135. * Defines the panning sensibility of the inputs.
  44136. * (How fast is the camera panning)
  44137. */
  44138. panningSensibility: number;
  44139. /**
  44140. * Defines the zooming sensibility of the inputs.
  44141. * (How fast is the camera zooming)
  44142. */
  44143. zoomingSensibility: number;
  44144. /**
  44145. * Defines whether maintaining the alt key down switch the movement mode from
  44146. * orientation to zoom.
  44147. */
  44148. useAltToZoom: boolean;
  44149. /**
  44150. * Rotation speed of the camera
  44151. */
  44152. angularSpeed: number;
  44153. private _keys;
  44154. private _ctrlPressed;
  44155. private _altPressed;
  44156. private _onCanvasBlurObserver;
  44157. private _onKeyboardObserver;
  44158. private _engine;
  44159. private _scene;
  44160. /**
  44161. * Attach the input controls to a specific dom element to get the input from.
  44162. * @param element Defines the element the controls should be listened from
  44163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44164. */
  44165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44166. /**
  44167. * Detach the current controls from the specified dom element.
  44168. * @param element Defines the element to stop listening the inputs from
  44169. */
  44170. detachControl(element: Nullable<HTMLElement>): void;
  44171. /**
  44172. * Update the current camera state depending on the inputs that have been used this frame.
  44173. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44174. */
  44175. checkInputs(): void;
  44176. /**
  44177. * Gets the class name of the current intput.
  44178. * @returns the class name
  44179. */
  44180. getClassName(): string;
  44181. /**
  44182. * Get the friendly name associated with the input class.
  44183. * @returns the input friendly name
  44184. */
  44185. getSimpleName(): string;
  44186. }
  44187. }
  44188. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44189. import { Nullable } from "babylonjs/types";
  44190. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44191. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44192. /**
  44193. * Manage the mouse wheel inputs to control an arc rotate camera.
  44194. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44195. */
  44196. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44197. /**
  44198. * Defines the camera the input is attached to.
  44199. */
  44200. camera: ArcRotateCamera;
  44201. /**
  44202. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44203. */
  44204. wheelPrecision: number;
  44205. /**
  44206. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44207. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44208. */
  44209. wheelDeltaPercentage: number;
  44210. private _wheel;
  44211. private _observer;
  44212. private computeDeltaFromMouseWheelLegacyEvent;
  44213. /**
  44214. * Attach the input controls to a specific dom element to get the input from.
  44215. * @param element Defines the element the controls should be listened from
  44216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44217. */
  44218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44219. /**
  44220. * Detach the current controls from the specified dom element.
  44221. * @param element Defines the element to stop listening the inputs from
  44222. */
  44223. detachControl(element: Nullable<HTMLElement>): void;
  44224. /**
  44225. * Gets the class name of the current intput.
  44226. * @returns the class name
  44227. */
  44228. getClassName(): string;
  44229. /**
  44230. * Get the friendly name associated with the input class.
  44231. * @returns the input friendly name
  44232. */
  44233. getSimpleName(): string;
  44234. }
  44235. }
  44236. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44237. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44238. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44239. /**
  44240. * Default Inputs manager for the ArcRotateCamera.
  44241. * It groups all the default supported inputs for ease of use.
  44242. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44243. */
  44244. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44245. /**
  44246. * Instantiates a new ArcRotateCameraInputsManager.
  44247. * @param camera Defines the camera the inputs belong to
  44248. */
  44249. constructor(camera: ArcRotateCamera);
  44250. /**
  44251. * Add mouse wheel input support to the input manager.
  44252. * @returns the current input manager
  44253. */
  44254. addMouseWheel(): ArcRotateCameraInputsManager;
  44255. /**
  44256. * Add pointers input support to the input manager.
  44257. * @returns the current input manager
  44258. */
  44259. addPointers(): ArcRotateCameraInputsManager;
  44260. /**
  44261. * Add keyboard input support to the input manager.
  44262. * @returns the current input manager
  44263. */
  44264. addKeyboard(): ArcRotateCameraInputsManager;
  44265. }
  44266. }
  44267. declare module "babylonjs/Cameras/arcRotateCamera" {
  44268. import { Observable } from "babylonjs/Misc/observable";
  44269. import { Nullable } from "babylonjs/types";
  44270. import { Scene } from "babylonjs/scene";
  44271. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44273. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44274. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44275. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44276. import { Camera } from "babylonjs/Cameras/camera";
  44277. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44278. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44279. import { Collider } from "babylonjs/Collisions/collider";
  44280. /**
  44281. * This represents an orbital type of camera.
  44282. *
  44283. * 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.
  44284. * 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.
  44285. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44286. */
  44287. export class ArcRotateCamera extends TargetCamera {
  44288. /**
  44289. * Defines the rotation angle of the camera along the longitudinal axis.
  44290. */
  44291. alpha: number;
  44292. /**
  44293. * Defines the rotation angle of the camera along the latitudinal axis.
  44294. */
  44295. beta: number;
  44296. /**
  44297. * Defines the radius of the camera from it s target point.
  44298. */
  44299. radius: number;
  44300. protected _target: Vector3;
  44301. protected _targetHost: Nullable<AbstractMesh>;
  44302. /**
  44303. * Defines the target point of the camera.
  44304. * The camera looks towards it form the radius distance.
  44305. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44306. */
  44307. get target(): Vector3;
  44308. set target(value: Vector3);
  44309. /**
  44310. * Define the current local position of the camera in the scene
  44311. */
  44312. get position(): Vector3;
  44313. set position(newPosition: Vector3);
  44314. protected _upVector: Vector3;
  44315. protected _upToYMatrix: Matrix;
  44316. protected _YToUpMatrix: Matrix;
  44317. /**
  44318. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44319. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44320. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44321. */
  44322. set upVector(vec: Vector3);
  44323. get upVector(): Vector3;
  44324. /**
  44325. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44326. */
  44327. setMatUp(): void;
  44328. /**
  44329. * Current inertia value on the longitudinal axis.
  44330. * The bigger this number the longer it will take for the camera to stop.
  44331. */
  44332. inertialAlphaOffset: number;
  44333. /**
  44334. * Current inertia value on the latitudinal axis.
  44335. * The bigger this number the longer it will take for the camera to stop.
  44336. */
  44337. inertialBetaOffset: number;
  44338. /**
  44339. * Current inertia value on the radius axis.
  44340. * The bigger this number the longer it will take for the camera to stop.
  44341. */
  44342. inertialRadiusOffset: number;
  44343. /**
  44344. * Minimum allowed angle on the longitudinal axis.
  44345. * This can help limiting how the Camera is able to move in the scene.
  44346. */
  44347. lowerAlphaLimit: Nullable<number>;
  44348. /**
  44349. * Maximum allowed angle on the longitudinal axis.
  44350. * This can help limiting how the Camera is able to move in the scene.
  44351. */
  44352. upperAlphaLimit: Nullable<number>;
  44353. /**
  44354. * Minimum allowed angle on the latitudinal axis.
  44355. * This can help limiting how the Camera is able to move in the scene.
  44356. */
  44357. lowerBetaLimit: number;
  44358. /**
  44359. * Maximum allowed angle on the latitudinal axis.
  44360. * This can help limiting how the Camera is able to move in the scene.
  44361. */
  44362. upperBetaLimit: number;
  44363. /**
  44364. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44365. * This can help limiting how the Camera is able to move in the scene.
  44366. */
  44367. lowerRadiusLimit: Nullable<number>;
  44368. /**
  44369. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44370. * This can help limiting how the Camera is able to move in the scene.
  44371. */
  44372. upperRadiusLimit: Nullable<number>;
  44373. /**
  44374. * Defines the current inertia value used during panning of the camera along the X axis.
  44375. */
  44376. inertialPanningX: number;
  44377. /**
  44378. * Defines the current inertia value used during panning of the camera along the Y axis.
  44379. */
  44380. inertialPanningY: number;
  44381. /**
  44382. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44383. * Basically if your fingers moves away from more than this distance you will be considered
  44384. * in pinch mode.
  44385. */
  44386. pinchToPanMaxDistance: number;
  44387. /**
  44388. * Defines the maximum distance the camera can pan.
  44389. * This could help keeping the cammera always in your scene.
  44390. */
  44391. panningDistanceLimit: Nullable<number>;
  44392. /**
  44393. * Defines the target of the camera before paning.
  44394. */
  44395. panningOriginTarget: Vector3;
  44396. /**
  44397. * Defines the value of the inertia used during panning.
  44398. * 0 would mean stop inertia and one would mean no decelleration at all.
  44399. */
  44400. panningInertia: number;
  44401. /**
  44402. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44403. */
  44404. get angularSensibilityX(): number;
  44405. set angularSensibilityX(value: number);
  44406. /**
  44407. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44408. */
  44409. get angularSensibilityY(): number;
  44410. set angularSensibilityY(value: number);
  44411. /**
  44412. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44413. */
  44414. get pinchPrecision(): number;
  44415. set pinchPrecision(value: number);
  44416. /**
  44417. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44418. * It will be used instead of pinchDeltaPrecision if different from 0.
  44419. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44420. */
  44421. get pinchDeltaPercentage(): number;
  44422. set pinchDeltaPercentage(value: number);
  44423. /**
  44424. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44425. * and pinch delta percentage.
  44426. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44427. * that any object in the plane at the camera's target point will scale
  44428. * perfectly with finger motion.
  44429. */
  44430. get useNaturalPinchZoom(): boolean;
  44431. set useNaturalPinchZoom(value: boolean);
  44432. /**
  44433. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44434. */
  44435. get panningSensibility(): number;
  44436. set panningSensibility(value: number);
  44437. /**
  44438. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44439. */
  44440. get keysUp(): number[];
  44441. set keysUp(value: number[]);
  44442. /**
  44443. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44444. */
  44445. get keysDown(): number[];
  44446. set keysDown(value: number[]);
  44447. /**
  44448. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44449. */
  44450. get keysLeft(): number[];
  44451. set keysLeft(value: number[]);
  44452. /**
  44453. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44454. */
  44455. get keysRight(): number[];
  44456. set keysRight(value: number[]);
  44457. /**
  44458. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44459. */
  44460. get wheelPrecision(): number;
  44461. set wheelPrecision(value: number);
  44462. /**
  44463. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44464. * It will be used instead of pinchDeltaPrecision if different from 0.
  44465. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44466. */
  44467. get wheelDeltaPercentage(): number;
  44468. set wheelDeltaPercentage(value: number);
  44469. /**
  44470. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44471. */
  44472. zoomOnFactor: number;
  44473. /**
  44474. * Defines a screen offset for the camera position.
  44475. */
  44476. targetScreenOffset: Vector2;
  44477. /**
  44478. * Allows the camera to be completely reversed.
  44479. * If false the camera can not arrive upside down.
  44480. */
  44481. allowUpsideDown: boolean;
  44482. /**
  44483. * Define if double tap/click is used to restore the previously saved state of the camera.
  44484. */
  44485. useInputToRestoreState: boolean;
  44486. /** @hidden */
  44487. _viewMatrix: Matrix;
  44488. /** @hidden */
  44489. _useCtrlForPanning: boolean;
  44490. /** @hidden */
  44491. _panningMouseButton: number;
  44492. /**
  44493. * Defines the input associated to the camera.
  44494. */
  44495. inputs: ArcRotateCameraInputsManager;
  44496. /** @hidden */
  44497. _reset: () => void;
  44498. /**
  44499. * Defines the allowed panning axis.
  44500. */
  44501. panningAxis: Vector3;
  44502. protected _localDirection: Vector3;
  44503. protected _transformedDirection: Vector3;
  44504. private _bouncingBehavior;
  44505. /**
  44506. * Gets the bouncing behavior of the camera if it has been enabled.
  44507. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44508. */
  44509. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44510. /**
  44511. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44512. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44513. */
  44514. get useBouncingBehavior(): boolean;
  44515. set useBouncingBehavior(value: boolean);
  44516. private _framingBehavior;
  44517. /**
  44518. * Gets the framing behavior of the camera if it has been enabled.
  44519. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44520. */
  44521. get framingBehavior(): Nullable<FramingBehavior>;
  44522. /**
  44523. * Defines if the framing behavior of the camera is enabled on the camera.
  44524. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44525. */
  44526. get useFramingBehavior(): boolean;
  44527. set useFramingBehavior(value: boolean);
  44528. private _autoRotationBehavior;
  44529. /**
  44530. * Gets the auto rotation behavior of the camera if it has been enabled.
  44531. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44532. */
  44533. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44534. /**
  44535. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44536. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44537. */
  44538. get useAutoRotationBehavior(): boolean;
  44539. set useAutoRotationBehavior(value: boolean);
  44540. /**
  44541. * Observable triggered when the mesh target has been changed on the camera.
  44542. */
  44543. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44544. /**
  44545. * Event raised when the camera is colliding with a mesh.
  44546. */
  44547. onCollide: (collidedMesh: AbstractMesh) => void;
  44548. /**
  44549. * Defines whether the camera should check collision with the objects oh the scene.
  44550. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44551. */
  44552. checkCollisions: boolean;
  44553. /**
  44554. * Defines the collision radius of the camera.
  44555. * This simulates a sphere around the camera.
  44556. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44557. */
  44558. collisionRadius: Vector3;
  44559. protected _collider: Collider;
  44560. protected _previousPosition: Vector3;
  44561. protected _collisionVelocity: Vector3;
  44562. protected _newPosition: Vector3;
  44563. protected _previousAlpha: number;
  44564. protected _previousBeta: number;
  44565. protected _previousRadius: number;
  44566. protected _collisionTriggered: boolean;
  44567. protected _targetBoundingCenter: Nullable<Vector3>;
  44568. private _computationVector;
  44569. /**
  44570. * Instantiates a new ArcRotateCamera in a given scene
  44571. * @param name Defines the name of the camera
  44572. * @param alpha Defines the camera rotation along the logitudinal axis
  44573. * @param beta Defines the camera rotation along the latitudinal axis
  44574. * @param radius Defines the camera distance from its target
  44575. * @param target Defines the camera target
  44576. * @param scene Defines the scene the camera belongs to
  44577. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44578. */
  44579. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44580. /** @hidden */
  44581. _initCache(): void;
  44582. /** @hidden */
  44583. _updateCache(ignoreParentClass?: boolean): void;
  44584. protected _getTargetPosition(): Vector3;
  44585. private _storedAlpha;
  44586. private _storedBeta;
  44587. private _storedRadius;
  44588. private _storedTarget;
  44589. private _storedTargetScreenOffset;
  44590. /**
  44591. * Stores the current state of the camera (alpha, beta, radius and target)
  44592. * @returns the camera itself
  44593. */
  44594. storeState(): Camera;
  44595. /**
  44596. * @hidden
  44597. * Restored camera state. You must call storeState() first
  44598. */
  44599. _restoreStateValues(): boolean;
  44600. /** @hidden */
  44601. _isSynchronizedViewMatrix(): boolean;
  44602. /**
  44603. * Attached controls to the current camera.
  44604. * @param element Defines the element the controls should be listened from
  44605. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44606. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44607. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44608. */
  44609. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44610. /**
  44611. * Detach the current controls from the camera.
  44612. * The camera will stop reacting to inputs.
  44613. * @param element Defines the element to stop listening the inputs from
  44614. */
  44615. detachControl(element: HTMLElement): void;
  44616. /** @hidden */
  44617. _checkInputs(): void;
  44618. protected _checkLimits(): void;
  44619. /**
  44620. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44621. */
  44622. rebuildAnglesAndRadius(): void;
  44623. /**
  44624. * Use a position to define the current camera related information like alpha, beta and radius
  44625. * @param position Defines the position to set the camera at
  44626. */
  44627. setPosition(position: Vector3): void;
  44628. /**
  44629. * Defines the target the camera should look at.
  44630. * This will automatically adapt alpha beta and radius to fit within the new target.
  44631. * @param target Defines the new target as a Vector or a mesh
  44632. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44633. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44634. */
  44635. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44636. /** @hidden */
  44637. _getViewMatrix(): Matrix;
  44638. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44639. /**
  44640. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44641. * @param meshes Defines the mesh to zoom on
  44642. * @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)
  44643. */
  44644. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44645. /**
  44646. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44647. * The target will be changed but the radius
  44648. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44649. * @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)
  44650. */
  44651. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44652. min: Vector3;
  44653. max: Vector3;
  44654. distance: number;
  44655. }, doNotUpdateMaxZ?: boolean): void;
  44656. /**
  44657. * @override
  44658. * Override Camera.createRigCamera
  44659. */
  44660. createRigCamera(name: string, cameraIndex: number): Camera;
  44661. /**
  44662. * @hidden
  44663. * @override
  44664. * Override Camera._updateRigCameras
  44665. */
  44666. _updateRigCameras(): void;
  44667. /**
  44668. * Destroy the camera and release the current resources hold by it.
  44669. */
  44670. dispose(): void;
  44671. /**
  44672. * Gets the current object class name.
  44673. * @return the class name
  44674. */
  44675. getClassName(): string;
  44676. }
  44677. }
  44678. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44679. import { Behavior } from "babylonjs/Behaviors/behavior";
  44680. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44681. /**
  44682. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44683. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44684. */
  44685. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44686. /**
  44687. * Gets the name of the behavior.
  44688. */
  44689. get name(): string;
  44690. private _zoomStopsAnimation;
  44691. private _idleRotationSpeed;
  44692. private _idleRotationWaitTime;
  44693. private _idleRotationSpinupTime;
  44694. /**
  44695. * Sets the flag that indicates if user zooming should stop animation.
  44696. */
  44697. set zoomStopsAnimation(flag: boolean);
  44698. /**
  44699. * Gets the flag that indicates if user zooming should stop animation.
  44700. */
  44701. get zoomStopsAnimation(): boolean;
  44702. /**
  44703. * Sets the default speed at which the camera rotates around the model.
  44704. */
  44705. set idleRotationSpeed(speed: number);
  44706. /**
  44707. * Gets the default speed at which the camera rotates around the model.
  44708. */
  44709. get idleRotationSpeed(): number;
  44710. /**
  44711. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44712. */
  44713. set idleRotationWaitTime(time: number);
  44714. /**
  44715. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44716. */
  44717. get idleRotationWaitTime(): number;
  44718. /**
  44719. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44720. */
  44721. set idleRotationSpinupTime(time: number);
  44722. /**
  44723. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44724. */
  44725. get idleRotationSpinupTime(): number;
  44726. /**
  44727. * Gets a value indicating if the camera is currently rotating because of this behavior
  44728. */
  44729. get rotationInProgress(): boolean;
  44730. private _onPrePointerObservableObserver;
  44731. private _onAfterCheckInputsObserver;
  44732. private _attachedCamera;
  44733. private _isPointerDown;
  44734. private _lastFrameTime;
  44735. private _lastInteractionTime;
  44736. private _cameraRotationSpeed;
  44737. /**
  44738. * Initializes the behavior.
  44739. */
  44740. init(): void;
  44741. /**
  44742. * Attaches the behavior to its arc rotate camera.
  44743. * @param camera Defines the camera to attach the behavior to
  44744. */
  44745. attach(camera: ArcRotateCamera): void;
  44746. /**
  44747. * Detaches the behavior from its current arc rotate camera.
  44748. */
  44749. detach(): void;
  44750. /**
  44751. * Returns true if user is scrolling.
  44752. * @return true if user is scrolling.
  44753. */
  44754. private _userIsZooming;
  44755. private _lastFrameRadius;
  44756. private _shouldAnimationStopForInteraction;
  44757. /**
  44758. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44759. */
  44760. private _applyUserInteraction;
  44761. private _userIsMoving;
  44762. }
  44763. }
  44764. declare module "babylonjs/Behaviors/Cameras/index" {
  44765. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44766. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44767. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44768. }
  44769. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44770. import { Mesh } from "babylonjs/Meshes/mesh";
  44771. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44772. import { Behavior } from "babylonjs/Behaviors/behavior";
  44773. /**
  44774. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44775. */
  44776. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44777. private ui;
  44778. /**
  44779. * The name of the behavior
  44780. */
  44781. name: string;
  44782. /**
  44783. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44784. */
  44785. distanceAwayFromFace: number;
  44786. /**
  44787. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44788. */
  44789. distanceAwayFromBottomOfFace: number;
  44790. private _faceVectors;
  44791. private _target;
  44792. private _scene;
  44793. private _onRenderObserver;
  44794. private _tmpMatrix;
  44795. private _tmpVector;
  44796. /**
  44797. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44798. * @param ui The transform node that should be attched to the mesh
  44799. */
  44800. constructor(ui: TransformNode);
  44801. /**
  44802. * Initializes the behavior
  44803. */
  44804. init(): void;
  44805. private _closestFace;
  44806. private _zeroVector;
  44807. private _lookAtTmpMatrix;
  44808. private _lookAtToRef;
  44809. /**
  44810. * Attaches the AttachToBoxBehavior to the passed in mesh
  44811. * @param target The mesh that the specified node will be attached to
  44812. */
  44813. attach(target: Mesh): void;
  44814. /**
  44815. * Detaches the behavior from the mesh
  44816. */
  44817. detach(): void;
  44818. }
  44819. }
  44820. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44821. import { Behavior } from "babylonjs/Behaviors/behavior";
  44822. import { Mesh } from "babylonjs/Meshes/mesh";
  44823. /**
  44824. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44825. */
  44826. export class FadeInOutBehavior implements Behavior<Mesh> {
  44827. /**
  44828. * Time in milliseconds to delay before fading in (Default: 0)
  44829. */
  44830. delay: number;
  44831. /**
  44832. * Time in milliseconds for the mesh to fade in (Default: 300)
  44833. */
  44834. fadeInTime: number;
  44835. private _millisecondsPerFrame;
  44836. private _hovered;
  44837. private _hoverValue;
  44838. private _ownerNode;
  44839. /**
  44840. * Instatiates the FadeInOutBehavior
  44841. */
  44842. constructor();
  44843. /**
  44844. * The name of the behavior
  44845. */
  44846. get name(): string;
  44847. /**
  44848. * Initializes the behavior
  44849. */
  44850. init(): void;
  44851. /**
  44852. * Attaches the fade behavior on the passed in mesh
  44853. * @param ownerNode The mesh that will be faded in/out once attached
  44854. */
  44855. attach(ownerNode: Mesh): void;
  44856. /**
  44857. * Detaches the behavior from the mesh
  44858. */
  44859. detach(): void;
  44860. /**
  44861. * Triggers the mesh to begin fading in or out
  44862. * @param value if the object should fade in or out (true to fade in)
  44863. */
  44864. fadeIn(value: boolean): void;
  44865. private _update;
  44866. private _setAllVisibility;
  44867. }
  44868. }
  44869. declare module "babylonjs/Misc/pivotTools" {
  44870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44871. /**
  44872. * Class containing a set of static utilities functions for managing Pivots
  44873. * @hidden
  44874. */
  44875. export class PivotTools {
  44876. private static _PivotCached;
  44877. private static _OldPivotPoint;
  44878. private static _PivotTranslation;
  44879. private static _PivotTmpVector;
  44880. /** @hidden */
  44881. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  44882. /** @hidden */
  44883. static _RestorePivotPoint(mesh: AbstractMesh): void;
  44884. }
  44885. }
  44886. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  44887. import { Scene } from "babylonjs/scene";
  44888. import { Vector4 } from "babylonjs/Maths/math.vector";
  44889. import { Mesh } from "babylonjs/Meshes/mesh";
  44890. import { Nullable } from "babylonjs/types";
  44891. import { Plane } from "babylonjs/Maths/math.plane";
  44892. /**
  44893. * Class containing static functions to help procedurally build meshes
  44894. */
  44895. export class PlaneBuilder {
  44896. /**
  44897. * Creates a plane mesh
  44898. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  44899. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  44900. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  44901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44904. * @param name defines the name of the mesh
  44905. * @param options defines the options used to create the mesh
  44906. * @param scene defines the hosting scene
  44907. * @returns the plane mesh
  44908. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  44909. */
  44910. static CreatePlane(name: string, options: {
  44911. size?: number;
  44912. width?: number;
  44913. height?: number;
  44914. sideOrientation?: number;
  44915. frontUVs?: Vector4;
  44916. backUVs?: Vector4;
  44917. updatable?: boolean;
  44918. sourcePlane?: Plane;
  44919. }, scene?: Nullable<Scene>): Mesh;
  44920. }
  44921. }
  44922. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  44923. import { Behavior } from "babylonjs/Behaviors/behavior";
  44924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44925. import { Observable } from "babylonjs/Misc/observable";
  44926. import { Vector3 } from "babylonjs/Maths/math.vector";
  44927. import { Ray } from "babylonjs/Culling/ray";
  44928. import "babylonjs/Meshes/Builders/planeBuilder";
  44929. /**
  44930. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  44931. */
  44932. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  44933. private static _AnyMouseID;
  44934. /**
  44935. * Abstract mesh the behavior is set on
  44936. */
  44937. attachedNode: AbstractMesh;
  44938. private _dragPlane;
  44939. private _scene;
  44940. private _pointerObserver;
  44941. private _beforeRenderObserver;
  44942. private static _planeScene;
  44943. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  44944. /**
  44945. * 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)
  44946. */
  44947. maxDragAngle: number;
  44948. /**
  44949. * @hidden
  44950. */
  44951. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  44952. /**
  44953. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44954. */
  44955. currentDraggingPointerID: number;
  44956. /**
  44957. * The last position where the pointer hit the drag plane in world space
  44958. */
  44959. lastDragPosition: Vector3;
  44960. /**
  44961. * If the behavior is currently in a dragging state
  44962. */
  44963. dragging: boolean;
  44964. /**
  44965. * 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)
  44966. */
  44967. dragDeltaRatio: number;
  44968. /**
  44969. * If the drag plane orientation should be updated during the dragging (Default: true)
  44970. */
  44971. updateDragPlane: boolean;
  44972. private _debugMode;
  44973. private _moving;
  44974. /**
  44975. * Fires each time the attached mesh is dragged with the pointer
  44976. * * delta between last drag position and current drag position in world space
  44977. * * dragDistance along the drag axis
  44978. * * dragPlaneNormal normal of the current drag plane used during the drag
  44979. * * dragPlanePoint in world space where the drag intersects the drag plane
  44980. */
  44981. onDragObservable: Observable<{
  44982. delta: Vector3;
  44983. dragPlanePoint: Vector3;
  44984. dragPlaneNormal: Vector3;
  44985. dragDistance: number;
  44986. pointerId: number;
  44987. }>;
  44988. /**
  44989. * Fires each time a drag begins (eg. mouse down on mesh)
  44990. */
  44991. onDragStartObservable: Observable<{
  44992. dragPlanePoint: Vector3;
  44993. pointerId: number;
  44994. }>;
  44995. /**
  44996. * Fires each time a drag ends (eg. mouse release after drag)
  44997. */
  44998. onDragEndObservable: Observable<{
  44999. dragPlanePoint: Vector3;
  45000. pointerId: number;
  45001. }>;
  45002. /**
  45003. * If the attached mesh should be moved when dragged
  45004. */
  45005. moveAttached: boolean;
  45006. /**
  45007. * If the drag behavior will react to drag events (Default: true)
  45008. */
  45009. enabled: boolean;
  45010. /**
  45011. * If pointer events should start and release the drag (Default: true)
  45012. */
  45013. startAndReleaseDragOnPointerEvents: boolean;
  45014. /**
  45015. * If camera controls should be detached during the drag
  45016. */
  45017. detachCameraControls: boolean;
  45018. /**
  45019. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  45020. */
  45021. useObjectOrientationForDragging: boolean;
  45022. private _options;
  45023. /**
  45024. * Gets the options used by the behavior
  45025. */
  45026. get options(): {
  45027. dragAxis?: Vector3;
  45028. dragPlaneNormal?: Vector3;
  45029. };
  45030. /**
  45031. * Sets the options used by the behavior
  45032. */
  45033. set options(options: {
  45034. dragAxis?: Vector3;
  45035. dragPlaneNormal?: Vector3;
  45036. });
  45037. /**
  45038. * Creates a pointer drag behavior that can be attached to a mesh
  45039. * @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)
  45040. */
  45041. constructor(options?: {
  45042. dragAxis?: Vector3;
  45043. dragPlaneNormal?: Vector3;
  45044. });
  45045. /**
  45046. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45047. */
  45048. validateDrag: (targetPosition: Vector3) => boolean;
  45049. /**
  45050. * The name of the behavior
  45051. */
  45052. get name(): string;
  45053. /**
  45054. * Initializes the behavior
  45055. */
  45056. init(): void;
  45057. private _tmpVector;
  45058. private _alternatePickedPoint;
  45059. private _worldDragAxis;
  45060. private _targetPosition;
  45061. private _attachedElement;
  45062. /**
  45063. * Attaches the drag behavior the passed in mesh
  45064. * @param ownerNode The mesh that will be dragged around once attached
  45065. * @param predicate Predicate to use for pick filtering
  45066. */
  45067. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45068. /**
  45069. * Force relase the drag action by code.
  45070. */
  45071. releaseDrag(): void;
  45072. private _startDragRay;
  45073. private _lastPointerRay;
  45074. /**
  45075. * Simulates the start of a pointer drag event on the behavior
  45076. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45077. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45078. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45079. */
  45080. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45081. private _startDrag;
  45082. private _dragDelta;
  45083. private _moveDrag;
  45084. private _pickWithRayOnDragPlane;
  45085. private _pointA;
  45086. private _pointC;
  45087. private _localAxis;
  45088. private _lookAt;
  45089. private _updateDragPlanePosition;
  45090. /**
  45091. * Detaches the behavior from the mesh
  45092. */
  45093. detach(): void;
  45094. }
  45095. }
  45096. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45097. import { Mesh } from "babylonjs/Meshes/mesh";
  45098. import { Behavior } from "babylonjs/Behaviors/behavior";
  45099. /**
  45100. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45101. */
  45102. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45103. private _dragBehaviorA;
  45104. private _dragBehaviorB;
  45105. private _startDistance;
  45106. private _initialScale;
  45107. private _targetScale;
  45108. private _ownerNode;
  45109. private _sceneRenderObserver;
  45110. /**
  45111. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45112. */
  45113. constructor();
  45114. /**
  45115. * The name of the behavior
  45116. */
  45117. get name(): string;
  45118. /**
  45119. * Initializes the behavior
  45120. */
  45121. init(): void;
  45122. private _getCurrentDistance;
  45123. /**
  45124. * Attaches the scale behavior the passed in mesh
  45125. * @param ownerNode The mesh that will be scaled around once attached
  45126. */
  45127. attach(ownerNode: Mesh): void;
  45128. /**
  45129. * Detaches the behavior from the mesh
  45130. */
  45131. detach(): void;
  45132. }
  45133. }
  45134. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45135. import { Behavior } from "babylonjs/Behaviors/behavior";
  45136. import { Mesh } from "babylonjs/Meshes/mesh";
  45137. import { Observable } from "babylonjs/Misc/observable";
  45138. /**
  45139. * 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
  45140. */
  45141. export class SixDofDragBehavior implements Behavior<Mesh> {
  45142. private static _virtualScene;
  45143. private _ownerNode;
  45144. private _sceneRenderObserver;
  45145. private _scene;
  45146. private _targetPosition;
  45147. private _virtualOriginMesh;
  45148. private _virtualDragMesh;
  45149. private _pointerObserver;
  45150. private _moving;
  45151. private _startingOrientation;
  45152. private _attachedElement;
  45153. /**
  45154. * 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)
  45155. */
  45156. private zDragFactor;
  45157. /**
  45158. * If the object should rotate to face the drag origin
  45159. */
  45160. rotateDraggedObject: boolean;
  45161. /**
  45162. * If the behavior is currently in a dragging state
  45163. */
  45164. dragging: boolean;
  45165. /**
  45166. * 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)
  45167. */
  45168. dragDeltaRatio: number;
  45169. /**
  45170. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45171. */
  45172. currentDraggingPointerID: number;
  45173. /**
  45174. * If camera controls should be detached during the drag
  45175. */
  45176. detachCameraControls: boolean;
  45177. /**
  45178. * Fires each time a drag starts
  45179. */
  45180. onDragStartObservable: Observable<{}>;
  45181. /**
  45182. * Fires each time a drag ends (eg. mouse release after drag)
  45183. */
  45184. onDragEndObservable: Observable<{}>;
  45185. /**
  45186. * 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
  45187. */
  45188. constructor();
  45189. /**
  45190. * The name of the behavior
  45191. */
  45192. get name(): string;
  45193. /**
  45194. * Initializes the behavior
  45195. */
  45196. init(): void;
  45197. /**
  45198. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45199. */
  45200. private get _pointerCamera();
  45201. /**
  45202. * Attaches the scale behavior the passed in mesh
  45203. * @param ownerNode The mesh that will be scaled around once attached
  45204. */
  45205. attach(ownerNode: Mesh): void;
  45206. /**
  45207. * Detaches the behavior from the mesh
  45208. */
  45209. detach(): void;
  45210. }
  45211. }
  45212. declare module "babylonjs/Behaviors/Meshes/index" {
  45213. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45214. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45215. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45216. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45217. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45218. }
  45219. declare module "babylonjs/Behaviors/index" {
  45220. export * from "babylonjs/Behaviors/behavior";
  45221. export * from "babylonjs/Behaviors/Cameras/index";
  45222. export * from "babylonjs/Behaviors/Meshes/index";
  45223. }
  45224. declare module "babylonjs/Bones/boneIKController" {
  45225. import { Bone } from "babylonjs/Bones/bone";
  45226. import { Vector3 } from "babylonjs/Maths/math.vector";
  45227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45228. import { Nullable } from "babylonjs/types";
  45229. /**
  45230. * Class used to apply inverse kinematics to bones
  45231. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45232. */
  45233. export class BoneIKController {
  45234. private static _tmpVecs;
  45235. private static _tmpQuat;
  45236. private static _tmpMats;
  45237. /**
  45238. * Gets or sets the target mesh
  45239. */
  45240. targetMesh: AbstractMesh;
  45241. /** Gets or sets the mesh used as pole */
  45242. poleTargetMesh: AbstractMesh;
  45243. /**
  45244. * Gets or sets the bone used as pole
  45245. */
  45246. poleTargetBone: Nullable<Bone>;
  45247. /**
  45248. * Gets or sets the target position
  45249. */
  45250. targetPosition: Vector3;
  45251. /**
  45252. * Gets or sets the pole target position
  45253. */
  45254. poleTargetPosition: Vector3;
  45255. /**
  45256. * Gets or sets the pole target local offset
  45257. */
  45258. poleTargetLocalOffset: Vector3;
  45259. /**
  45260. * Gets or sets the pole angle
  45261. */
  45262. poleAngle: number;
  45263. /**
  45264. * Gets or sets the mesh associated with the controller
  45265. */
  45266. mesh: AbstractMesh;
  45267. /**
  45268. * 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)
  45269. */
  45270. slerpAmount: number;
  45271. private _bone1Quat;
  45272. private _bone1Mat;
  45273. private _bone2Ang;
  45274. private _bone1;
  45275. private _bone2;
  45276. private _bone1Length;
  45277. private _bone2Length;
  45278. private _maxAngle;
  45279. private _maxReach;
  45280. private _rightHandedSystem;
  45281. private _bendAxis;
  45282. private _slerping;
  45283. private _adjustRoll;
  45284. /**
  45285. * Gets or sets maximum allowed angle
  45286. */
  45287. get maxAngle(): number;
  45288. set maxAngle(value: number);
  45289. /**
  45290. * Creates a new BoneIKController
  45291. * @param mesh defines the mesh to control
  45292. * @param bone defines the bone to control
  45293. * @param options defines options to set up the controller
  45294. */
  45295. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45296. targetMesh?: AbstractMesh;
  45297. poleTargetMesh?: AbstractMesh;
  45298. poleTargetBone?: Bone;
  45299. poleTargetLocalOffset?: Vector3;
  45300. poleAngle?: number;
  45301. bendAxis?: Vector3;
  45302. maxAngle?: number;
  45303. slerpAmount?: number;
  45304. });
  45305. private _setMaxAngle;
  45306. /**
  45307. * Force the controller to update the bones
  45308. */
  45309. update(): void;
  45310. }
  45311. }
  45312. declare module "babylonjs/Bones/boneLookController" {
  45313. import { Vector3 } from "babylonjs/Maths/math.vector";
  45314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45315. import { Bone } from "babylonjs/Bones/bone";
  45316. import { Space } from "babylonjs/Maths/math.axis";
  45317. /**
  45318. * Class used to make a bone look toward a point in space
  45319. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45320. */
  45321. export class BoneLookController {
  45322. private static _tmpVecs;
  45323. private static _tmpQuat;
  45324. private static _tmpMats;
  45325. /**
  45326. * The target Vector3 that the bone will look at
  45327. */
  45328. target: Vector3;
  45329. /**
  45330. * The mesh that the bone is attached to
  45331. */
  45332. mesh: AbstractMesh;
  45333. /**
  45334. * The bone that will be looking to the target
  45335. */
  45336. bone: Bone;
  45337. /**
  45338. * The up axis of the coordinate system that is used when the bone is rotated
  45339. */
  45340. upAxis: Vector3;
  45341. /**
  45342. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45343. */
  45344. upAxisSpace: Space;
  45345. /**
  45346. * Used to make an adjustment to the yaw of the bone
  45347. */
  45348. adjustYaw: number;
  45349. /**
  45350. * Used to make an adjustment to the pitch of the bone
  45351. */
  45352. adjustPitch: number;
  45353. /**
  45354. * Used to make an adjustment to the roll of the bone
  45355. */
  45356. adjustRoll: number;
  45357. /**
  45358. * 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)
  45359. */
  45360. slerpAmount: number;
  45361. private _minYaw;
  45362. private _maxYaw;
  45363. private _minPitch;
  45364. private _maxPitch;
  45365. private _minYawSin;
  45366. private _minYawCos;
  45367. private _maxYawSin;
  45368. private _maxYawCos;
  45369. private _midYawConstraint;
  45370. private _minPitchTan;
  45371. private _maxPitchTan;
  45372. private _boneQuat;
  45373. private _slerping;
  45374. private _transformYawPitch;
  45375. private _transformYawPitchInv;
  45376. private _firstFrameSkipped;
  45377. private _yawRange;
  45378. private _fowardAxis;
  45379. /**
  45380. * Gets or sets the minimum yaw angle that the bone can look to
  45381. */
  45382. get minYaw(): number;
  45383. set minYaw(value: number);
  45384. /**
  45385. * Gets or sets the maximum yaw angle that the bone can look to
  45386. */
  45387. get maxYaw(): number;
  45388. set maxYaw(value: number);
  45389. /**
  45390. * Gets or sets the minimum pitch angle that the bone can look to
  45391. */
  45392. get minPitch(): number;
  45393. set minPitch(value: number);
  45394. /**
  45395. * Gets or sets the maximum pitch angle that the bone can look to
  45396. */
  45397. get maxPitch(): number;
  45398. set maxPitch(value: number);
  45399. /**
  45400. * Create a BoneLookController
  45401. * @param mesh the mesh that the bone belongs to
  45402. * @param bone the bone that will be looking to the target
  45403. * @param target the target Vector3 to look at
  45404. * @param options optional settings:
  45405. * * maxYaw: the maximum angle the bone will yaw to
  45406. * * minYaw: the minimum angle the bone will yaw to
  45407. * * maxPitch: the maximum angle the bone will pitch to
  45408. * * minPitch: the minimum angle the bone will yaw to
  45409. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45410. * * upAxis: the up axis of the coordinate system
  45411. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45412. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45413. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45414. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45415. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45416. * * adjustRoll: used to make an adjustment to the roll of the bone
  45417. **/
  45418. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45419. maxYaw?: number;
  45420. minYaw?: number;
  45421. maxPitch?: number;
  45422. minPitch?: number;
  45423. slerpAmount?: number;
  45424. upAxis?: Vector3;
  45425. upAxisSpace?: Space;
  45426. yawAxis?: Vector3;
  45427. pitchAxis?: Vector3;
  45428. adjustYaw?: number;
  45429. adjustPitch?: number;
  45430. adjustRoll?: number;
  45431. });
  45432. /**
  45433. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45434. */
  45435. update(): void;
  45436. private _getAngleDiff;
  45437. private _getAngleBetween;
  45438. private _isAngleBetween;
  45439. }
  45440. }
  45441. declare module "babylonjs/Bones/index" {
  45442. export * from "babylonjs/Bones/bone";
  45443. export * from "babylonjs/Bones/boneIKController";
  45444. export * from "babylonjs/Bones/boneLookController";
  45445. export * from "babylonjs/Bones/skeleton";
  45446. }
  45447. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45448. import { Nullable } from "babylonjs/types";
  45449. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45450. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45451. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45452. /**
  45453. * Manage the gamepad inputs to control an arc rotate camera.
  45454. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45455. */
  45456. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45457. /**
  45458. * Defines the camera the input is attached to.
  45459. */
  45460. camera: ArcRotateCamera;
  45461. /**
  45462. * Defines the gamepad the input is gathering event from.
  45463. */
  45464. gamepad: Nullable<Gamepad>;
  45465. /**
  45466. * Defines the gamepad rotation sensiblity.
  45467. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45468. */
  45469. gamepadRotationSensibility: number;
  45470. /**
  45471. * Defines the gamepad move sensiblity.
  45472. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45473. */
  45474. gamepadMoveSensibility: number;
  45475. private _yAxisScale;
  45476. /**
  45477. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45478. */
  45479. get invertYAxis(): boolean;
  45480. set invertYAxis(value: boolean);
  45481. private _onGamepadConnectedObserver;
  45482. private _onGamepadDisconnectedObserver;
  45483. /**
  45484. * Attach the input controls to a specific dom element to get the input from.
  45485. * @param element Defines the element the controls should be listened from
  45486. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45487. */
  45488. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45489. /**
  45490. * Detach the current controls from the specified dom element.
  45491. * @param element Defines the element to stop listening the inputs from
  45492. */
  45493. detachControl(element: Nullable<HTMLElement>): void;
  45494. /**
  45495. * Update the current camera state depending on the inputs that have been used this frame.
  45496. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45497. */
  45498. checkInputs(): void;
  45499. /**
  45500. * Gets the class name of the current intput.
  45501. * @returns the class name
  45502. */
  45503. getClassName(): string;
  45504. /**
  45505. * Get the friendly name associated with the input class.
  45506. * @returns the input friendly name
  45507. */
  45508. getSimpleName(): string;
  45509. }
  45510. }
  45511. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45512. import { Nullable } from "babylonjs/types";
  45513. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45514. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45515. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45516. interface ArcRotateCameraInputsManager {
  45517. /**
  45518. * Add orientation input support to the input manager.
  45519. * @returns the current input manager
  45520. */
  45521. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45522. }
  45523. }
  45524. /**
  45525. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45526. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45527. */
  45528. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45529. /**
  45530. * Defines the camera the input is attached to.
  45531. */
  45532. camera: ArcRotateCamera;
  45533. /**
  45534. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45535. */
  45536. alphaCorrection: number;
  45537. /**
  45538. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45539. */
  45540. gammaCorrection: number;
  45541. private _alpha;
  45542. private _gamma;
  45543. private _dirty;
  45544. private _deviceOrientationHandler;
  45545. /**
  45546. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45547. */
  45548. constructor();
  45549. /**
  45550. * Attach the input controls to a specific dom element to get the input from.
  45551. * @param element Defines the element the controls should be listened from
  45552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45553. */
  45554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45555. /** @hidden */
  45556. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45557. /**
  45558. * Update the current camera state depending on the inputs that have been used this frame.
  45559. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45560. */
  45561. checkInputs(): void;
  45562. /**
  45563. * Detach the current controls from the specified dom element.
  45564. * @param element Defines the element to stop listening the inputs from
  45565. */
  45566. detachControl(element: Nullable<HTMLElement>): void;
  45567. /**
  45568. * Gets the class name of the current intput.
  45569. * @returns the class name
  45570. */
  45571. getClassName(): string;
  45572. /**
  45573. * Get the friendly name associated with the input class.
  45574. * @returns the input friendly name
  45575. */
  45576. getSimpleName(): string;
  45577. }
  45578. }
  45579. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45580. import { Nullable } from "babylonjs/types";
  45581. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45582. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45583. /**
  45584. * Listen to mouse events to control the camera.
  45585. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45586. */
  45587. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45588. /**
  45589. * Defines the camera the input is attached to.
  45590. */
  45591. camera: FlyCamera;
  45592. /**
  45593. * Defines if touch is enabled. (Default is true.)
  45594. */
  45595. touchEnabled: boolean;
  45596. /**
  45597. * Defines the buttons associated with the input to handle camera rotation.
  45598. */
  45599. buttons: number[];
  45600. /**
  45601. * Assign buttons for Yaw control.
  45602. */
  45603. buttonsYaw: number[];
  45604. /**
  45605. * Assign buttons for Pitch control.
  45606. */
  45607. buttonsPitch: number[];
  45608. /**
  45609. * Assign buttons for Roll control.
  45610. */
  45611. buttonsRoll: number[];
  45612. /**
  45613. * Detect if any button is being pressed while mouse is moved.
  45614. * -1 = Mouse locked.
  45615. * 0 = Left button.
  45616. * 1 = Middle Button.
  45617. * 2 = Right Button.
  45618. */
  45619. activeButton: number;
  45620. /**
  45621. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45622. * Higher values reduce its sensitivity.
  45623. */
  45624. angularSensibility: number;
  45625. private _mousemoveCallback;
  45626. private _observer;
  45627. private _rollObserver;
  45628. private previousPosition;
  45629. private noPreventDefault;
  45630. private element;
  45631. /**
  45632. * Listen to mouse events to control the camera.
  45633. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45634. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45635. */
  45636. constructor(touchEnabled?: boolean);
  45637. /**
  45638. * Attach the mouse control to the HTML DOM element.
  45639. * @param element Defines the element that listens to the input events.
  45640. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45641. */
  45642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45643. /**
  45644. * Detach the current controls from the specified dom element.
  45645. * @param element Defines the element to stop listening the inputs from
  45646. */
  45647. detachControl(element: Nullable<HTMLElement>): void;
  45648. /**
  45649. * Gets the class name of the current input.
  45650. * @returns the class name.
  45651. */
  45652. getClassName(): string;
  45653. /**
  45654. * Get the friendly name associated with the input class.
  45655. * @returns the input's friendly name.
  45656. */
  45657. getSimpleName(): string;
  45658. private _pointerInput;
  45659. private _onMouseMove;
  45660. /**
  45661. * Rotate camera by mouse offset.
  45662. */
  45663. private rotateCamera;
  45664. }
  45665. }
  45666. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45667. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45668. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45669. /**
  45670. * Default Inputs manager for the FlyCamera.
  45671. * It groups all the default supported inputs for ease of use.
  45672. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45673. */
  45674. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45675. /**
  45676. * Instantiates a new FlyCameraInputsManager.
  45677. * @param camera Defines the camera the inputs belong to.
  45678. */
  45679. constructor(camera: FlyCamera);
  45680. /**
  45681. * Add keyboard input support to the input manager.
  45682. * @returns the new FlyCameraKeyboardMoveInput().
  45683. */
  45684. addKeyboard(): FlyCameraInputsManager;
  45685. /**
  45686. * Add mouse input support to the input manager.
  45687. * @param touchEnabled Enable touch screen support.
  45688. * @returns the new FlyCameraMouseInput().
  45689. */
  45690. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45691. }
  45692. }
  45693. declare module "babylonjs/Cameras/flyCamera" {
  45694. import { Scene } from "babylonjs/scene";
  45695. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45697. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45698. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45699. /**
  45700. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45701. * such as in a 3D Space Shooter or a Flight Simulator.
  45702. */
  45703. export class FlyCamera extends TargetCamera {
  45704. /**
  45705. * Define the collision ellipsoid of the camera.
  45706. * This is helpful for simulating a camera body, like a player's body.
  45707. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45708. */
  45709. ellipsoid: Vector3;
  45710. /**
  45711. * Define an offset for the position of the ellipsoid around the camera.
  45712. * This can be helpful if the camera is attached away from the player's body center,
  45713. * such as at its head.
  45714. */
  45715. ellipsoidOffset: Vector3;
  45716. /**
  45717. * Enable or disable collisions of the camera with the rest of the scene objects.
  45718. */
  45719. checkCollisions: boolean;
  45720. /**
  45721. * Enable or disable gravity on the camera.
  45722. */
  45723. applyGravity: boolean;
  45724. /**
  45725. * Define the current direction the camera is moving to.
  45726. */
  45727. cameraDirection: Vector3;
  45728. /**
  45729. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45730. * This overrides and empties cameraRotation.
  45731. */
  45732. rotationQuaternion: Quaternion;
  45733. /**
  45734. * Track Roll to maintain the wanted Rolling when looking around.
  45735. */
  45736. _trackRoll: number;
  45737. /**
  45738. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45739. */
  45740. rollCorrect: number;
  45741. /**
  45742. * Mimic a banked turn, Rolling the camera when Yawing.
  45743. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45744. */
  45745. bankedTurn: boolean;
  45746. /**
  45747. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45748. */
  45749. bankedTurnLimit: number;
  45750. /**
  45751. * Value of 0 disables the banked Roll.
  45752. * Value of 1 is equal to the Yaw angle in radians.
  45753. */
  45754. bankedTurnMultiplier: number;
  45755. /**
  45756. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45757. */
  45758. inputs: FlyCameraInputsManager;
  45759. /**
  45760. * Gets the input sensibility for mouse input.
  45761. * Higher values reduce sensitivity.
  45762. */
  45763. get angularSensibility(): number;
  45764. /**
  45765. * Sets the input sensibility for a mouse input.
  45766. * Higher values reduce sensitivity.
  45767. */
  45768. set angularSensibility(value: number);
  45769. /**
  45770. * Get the keys for camera movement forward.
  45771. */
  45772. get keysForward(): number[];
  45773. /**
  45774. * Set the keys for camera movement forward.
  45775. */
  45776. set keysForward(value: number[]);
  45777. /**
  45778. * Get the keys for camera movement backward.
  45779. */
  45780. get keysBackward(): number[];
  45781. set keysBackward(value: number[]);
  45782. /**
  45783. * Get the keys for camera movement up.
  45784. */
  45785. get keysUp(): number[];
  45786. /**
  45787. * Set the keys for camera movement up.
  45788. */
  45789. set keysUp(value: number[]);
  45790. /**
  45791. * Get the keys for camera movement down.
  45792. */
  45793. get keysDown(): number[];
  45794. /**
  45795. * Set the keys for camera movement down.
  45796. */
  45797. set keysDown(value: number[]);
  45798. /**
  45799. * Get the keys for camera movement left.
  45800. */
  45801. get keysLeft(): number[];
  45802. /**
  45803. * Set the keys for camera movement left.
  45804. */
  45805. set keysLeft(value: number[]);
  45806. /**
  45807. * Set the keys for camera movement right.
  45808. */
  45809. get keysRight(): number[];
  45810. /**
  45811. * Set the keys for camera movement right.
  45812. */
  45813. set keysRight(value: number[]);
  45814. /**
  45815. * Event raised when the camera collides with a mesh in the scene.
  45816. */
  45817. onCollide: (collidedMesh: AbstractMesh) => void;
  45818. private _collider;
  45819. private _needMoveForGravity;
  45820. private _oldPosition;
  45821. private _diffPosition;
  45822. private _newPosition;
  45823. /** @hidden */
  45824. _localDirection: Vector3;
  45825. /** @hidden */
  45826. _transformedDirection: Vector3;
  45827. /**
  45828. * Instantiates a FlyCamera.
  45829. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45830. * such as in a 3D Space Shooter or a Flight Simulator.
  45831. * @param name Define the name of the camera in the scene.
  45832. * @param position Define the starting position of the camera in the scene.
  45833. * @param scene Define the scene the camera belongs to.
  45834. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45835. */
  45836. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45837. /**
  45838. * Attach a control to the HTML DOM element.
  45839. * @param element Defines the element that listens to the input events.
  45840. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45841. */
  45842. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45843. /**
  45844. * Detach a control from the HTML DOM element.
  45845. * The camera will stop reacting to that input.
  45846. * @param element Defines the element that listens to the input events.
  45847. */
  45848. detachControl(element: HTMLElement): void;
  45849. private _collisionMask;
  45850. /**
  45851. * Get the mask that the camera ignores in collision events.
  45852. */
  45853. get collisionMask(): number;
  45854. /**
  45855. * Set the mask that the camera ignores in collision events.
  45856. */
  45857. set collisionMask(mask: number);
  45858. /** @hidden */
  45859. _collideWithWorld(displacement: Vector3): void;
  45860. /** @hidden */
  45861. private _onCollisionPositionChange;
  45862. /** @hidden */
  45863. _checkInputs(): void;
  45864. /** @hidden */
  45865. _decideIfNeedsToMove(): boolean;
  45866. /** @hidden */
  45867. _updatePosition(): void;
  45868. /**
  45869. * Restore the Roll to its target value at the rate specified.
  45870. * @param rate - Higher means slower restoring.
  45871. * @hidden
  45872. */
  45873. restoreRoll(rate: number): void;
  45874. /**
  45875. * Destroy the camera and release the current resources held by it.
  45876. */
  45877. dispose(): void;
  45878. /**
  45879. * Get the current object class name.
  45880. * @returns the class name.
  45881. */
  45882. getClassName(): string;
  45883. }
  45884. }
  45885. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  45886. import { Nullable } from "babylonjs/types";
  45887. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45888. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45889. /**
  45890. * Listen to keyboard events to control the camera.
  45891. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45892. */
  45893. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  45894. /**
  45895. * Defines the camera the input is attached to.
  45896. */
  45897. camera: FlyCamera;
  45898. /**
  45899. * The list of keyboard keys used to control the forward move of the camera.
  45900. */
  45901. keysForward: number[];
  45902. /**
  45903. * The list of keyboard keys used to control the backward move of the camera.
  45904. */
  45905. keysBackward: number[];
  45906. /**
  45907. * The list of keyboard keys used to control the forward move of the camera.
  45908. */
  45909. keysUp: number[];
  45910. /**
  45911. * The list of keyboard keys used to control the backward move of the camera.
  45912. */
  45913. keysDown: number[];
  45914. /**
  45915. * The list of keyboard keys used to control the right strafe move of the camera.
  45916. */
  45917. keysRight: number[];
  45918. /**
  45919. * The list of keyboard keys used to control the left strafe move of the camera.
  45920. */
  45921. keysLeft: number[];
  45922. private _keys;
  45923. private _onCanvasBlurObserver;
  45924. private _onKeyboardObserver;
  45925. private _engine;
  45926. private _scene;
  45927. /**
  45928. * Attach the input controls to a specific dom element to get the input from.
  45929. * @param element Defines the element the controls should be listened from
  45930. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45931. */
  45932. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45933. /**
  45934. * Detach the current controls from the specified dom element.
  45935. * @param element Defines the element to stop listening the inputs from
  45936. */
  45937. detachControl(element: Nullable<HTMLElement>): void;
  45938. /**
  45939. * Gets the class name of the current intput.
  45940. * @returns the class name
  45941. */
  45942. getClassName(): string;
  45943. /** @hidden */
  45944. _onLostFocus(e: FocusEvent): void;
  45945. /**
  45946. * Get the friendly name associated with the input class.
  45947. * @returns the input friendly name
  45948. */
  45949. getSimpleName(): string;
  45950. /**
  45951. * Update the current camera state depending on the inputs that have been used this frame.
  45952. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45953. */
  45954. checkInputs(): void;
  45955. }
  45956. }
  45957. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  45958. import { Nullable } from "babylonjs/types";
  45959. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45960. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45961. /**
  45962. * Manage the mouse wheel inputs to control a follow camera.
  45963. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45964. */
  45965. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  45966. /**
  45967. * Defines the camera the input is attached to.
  45968. */
  45969. camera: FollowCamera;
  45970. /**
  45971. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  45972. */
  45973. axisControlRadius: boolean;
  45974. /**
  45975. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  45976. */
  45977. axisControlHeight: boolean;
  45978. /**
  45979. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  45980. */
  45981. axisControlRotation: boolean;
  45982. /**
  45983. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  45984. * relation to mouseWheel events.
  45985. */
  45986. wheelPrecision: number;
  45987. /**
  45988. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45989. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45990. */
  45991. wheelDeltaPercentage: number;
  45992. private _wheel;
  45993. private _observer;
  45994. /**
  45995. * Attach the input controls to a specific dom element to get the input from.
  45996. * @param element Defines the element the controls should be listened from
  45997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45998. */
  45999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46000. /**
  46001. * Detach the current controls from the specified dom element.
  46002. * @param element Defines the element to stop listening the inputs from
  46003. */
  46004. detachControl(element: Nullable<HTMLElement>): void;
  46005. /**
  46006. * Gets the class name of the current intput.
  46007. * @returns the class name
  46008. */
  46009. getClassName(): string;
  46010. /**
  46011. * Get the friendly name associated with the input class.
  46012. * @returns the input friendly name
  46013. */
  46014. getSimpleName(): string;
  46015. }
  46016. }
  46017. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  46018. import { Nullable } from "babylonjs/types";
  46019. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46020. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  46021. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  46022. /**
  46023. * Manage the pointers inputs to control an follow camera.
  46024. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46025. */
  46026. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46027. /**
  46028. * Defines the camera the input is attached to.
  46029. */
  46030. camera: FollowCamera;
  46031. /**
  46032. * Gets the class name of the current input.
  46033. * @returns the class name
  46034. */
  46035. getClassName(): string;
  46036. /**
  46037. * Defines the pointer angular sensibility along the X axis or how fast is
  46038. * the camera rotating.
  46039. * A negative number will reverse the axis direction.
  46040. */
  46041. angularSensibilityX: number;
  46042. /**
  46043. * Defines the pointer angular sensibility along the Y axis or how fast is
  46044. * the camera rotating.
  46045. * A negative number will reverse the axis direction.
  46046. */
  46047. angularSensibilityY: number;
  46048. /**
  46049. * Defines the pointer pinch precision or how fast is the camera zooming.
  46050. * A negative number will reverse the axis direction.
  46051. */
  46052. pinchPrecision: number;
  46053. /**
  46054. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46055. * from 0.
  46056. * It defines the percentage of current camera.radius to use as delta when
  46057. * pinch zoom is used.
  46058. */
  46059. pinchDeltaPercentage: number;
  46060. /**
  46061. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46062. */
  46063. axisXControlRadius: boolean;
  46064. /**
  46065. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46066. */
  46067. axisXControlHeight: boolean;
  46068. /**
  46069. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46070. */
  46071. axisXControlRotation: boolean;
  46072. /**
  46073. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46074. */
  46075. axisYControlRadius: boolean;
  46076. /**
  46077. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46078. */
  46079. axisYControlHeight: boolean;
  46080. /**
  46081. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46082. */
  46083. axisYControlRotation: boolean;
  46084. /**
  46085. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46086. */
  46087. axisPinchControlRadius: boolean;
  46088. /**
  46089. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46090. */
  46091. axisPinchControlHeight: boolean;
  46092. /**
  46093. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46094. */
  46095. axisPinchControlRotation: boolean;
  46096. /**
  46097. * Log error messages if basic misconfiguration has occurred.
  46098. */
  46099. warningEnable: boolean;
  46100. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46101. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46102. private _warningCounter;
  46103. private _warning;
  46104. }
  46105. }
  46106. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46107. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46108. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46109. /**
  46110. * Default Inputs manager for the FollowCamera.
  46111. * It groups all the default supported inputs for ease of use.
  46112. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46113. */
  46114. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46115. /**
  46116. * Instantiates a new FollowCameraInputsManager.
  46117. * @param camera Defines the camera the inputs belong to
  46118. */
  46119. constructor(camera: FollowCamera);
  46120. /**
  46121. * Add keyboard input support to the input manager.
  46122. * @returns the current input manager
  46123. */
  46124. addKeyboard(): FollowCameraInputsManager;
  46125. /**
  46126. * Add mouse wheel input support to the input manager.
  46127. * @returns the current input manager
  46128. */
  46129. addMouseWheel(): FollowCameraInputsManager;
  46130. /**
  46131. * Add pointers input support to the input manager.
  46132. * @returns the current input manager
  46133. */
  46134. addPointers(): FollowCameraInputsManager;
  46135. /**
  46136. * Add orientation input support to the input manager.
  46137. * @returns the current input manager
  46138. */
  46139. addVRDeviceOrientation(): FollowCameraInputsManager;
  46140. }
  46141. }
  46142. declare module "babylonjs/Cameras/followCamera" {
  46143. import { Nullable } from "babylonjs/types";
  46144. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46145. import { Scene } from "babylonjs/scene";
  46146. import { Vector3 } from "babylonjs/Maths/math.vector";
  46147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46148. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46149. /**
  46150. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46151. * an arc rotate version arcFollowCamera are available.
  46152. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46153. */
  46154. export class FollowCamera extends TargetCamera {
  46155. /**
  46156. * Distance the follow camera should follow an object at
  46157. */
  46158. radius: number;
  46159. /**
  46160. * Minimum allowed distance of the camera to the axis of rotation
  46161. * (The camera can not get closer).
  46162. * This can help limiting how the Camera is able to move in the scene.
  46163. */
  46164. lowerRadiusLimit: Nullable<number>;
  46165. /**
  46166. * Maximum allowed distance of the camera to the axis of rotation
  46167. * (The camera can not get further).
  46168. * This can help limiting how the Camera is able to move in the scene.
  46169. */
  46170. upperRadiusLimit: Nullable<number>;
  46171. /**
  46172. * Define a rotation offset between the camera and the object it follows
  46173. */
  46174. rotationOffset: number;
  46175. /**
  46176. * Minimum allowed angle to camera position relative to target object.
  46177. * This can help limiting how the Camera is able to move in the scene.
  46178. */
  46179. lowerRotationOffsetLimit: Nullable<number>;
  46180. /**
  46181. * Maximum allowed angle to camera position relative to target object.
  46182. * This can help limiting how the Camera is able to move in the scene.
  46183. */
  46184. upperRotationOffsetLimit: Nullable<number>;
  46185. /**
  46186. * Define a height offset between the camera and the object it follows.
  46187. * It can help following an object from the top (like a car chaing a plane)
  46188. */
  46189. heightOffset: number;
  46190. /**
  46191. * Minimum allowed height of camera position relative to target object.
  46192. * This can help limiting how the Camera is able to move in the scene.
  46193. */
  46194. lowerHeightOffsetLimit: Nullable<number>;
  46195. /**
  46196. * Maximum allowed height of camera position relative to target object.
  46197. * This can help limiting how the Camera is able to move in the scene.
  46198. */
  46199. upperHeightOffsetLimit: Nullable<number>;
  46200. /**
  46201. * Define how fast the camera can accelerate to follow it s target.
  46202. */
  46203. cameraAcceleration: number;
  46204. /**
  46205. * Define the speed limit of the camera following an object.
  46206. */
  46207. maxCameraSpeed: number;
  46208. /**
  46209. * Define the target of the camera.
  46210. */
  46211. lockedTarget: Nullable<AbstractMesh>;
  46212. /**
  46213. * Defines the input associated with the camera.
  46214. */
  46215. inputs: FollowCameraInputsManager;
  46216. /**
  46217. * Instantiates the follow camera.
  46218. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46219. * @param name Define the name of the camera in the scene
  46220. * @param position Define the position of the camera
  46221. * @param scene Define the scene the camera belong to
  46222. * @param lockedTarget Define the target of the camera
  46223. */
  46224. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46225. private _follow;
  46226. /**
  46227. * Attached controls to the current camera.
  46228. * @param element Defines the element the controls should be listened from
  46229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46230. */
  46231. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46232. /**
  46233. * Detach the current controls from the camera.
  46234. * The camera will stop reacting to inputs.
  46235. * @param element Defines the element to stop listening the inputs from
  46236. */
  46237. detachControl(element: HTMLElement): void;
  46238. /** @hidden */
  46239. _checkInputs(): void;
  46240. private _checkLimits;
  46241. /**
  46242. * Gets the camera class name.
  46243. * @returns the class name
  46244. */
  46245. getClassName(): string;
  46246. }
  46247. /**
  46248. * Arc Rotate version of the follow camera.
  46249. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46250. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46251. */
  46252. export class ArcFollowCamera extends TargetCamera {
  46253. /** The longitudinal angle of the camera */
  46254. alpha: number;
  46255. /** The latitudinal angle of the camera */
  46256. beta: number;
  46257. /** The radius of the camera from its target */
  46258. radius: number;
  46259. private _cartesianCoordinates;
  46260. /** Define the camera target (the mesh it should follow) */
  46261. private _meshTarget;
  46262. /**
  46263. * Instantiates a new ArcFollowCamera
  46264. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46265. * @param name Define the name of the camera
  46266. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46267. * @param beta Define the rotation angle of the camera around the elevation axis
  46268. * @param radius Define the radius of the camera from its target point
  46269. * @param target Define the target of the camera
  46270. * @param scene Define the scene the camera belongs to
  46271. */
  46272. constructor(name: string,
  46273. /** The longitudinal angle of the camera */
  46274. alpha: number,
  46275. /** The latitudinal angle of the camera */
  46276. beta: number,
  46277. /** The radius of the camera from its target */
  46278. radius: number,
  46279. /** Define the camera target (the mesh it should follow) */
  46280. target: Nullable<AbstractMesh>, scene: Scene);
  46281. private _follow;
  46282. /** @hidden */
  46283. _checkInputs(): void;
  46284. /**
  46285. * Returns the class name of the object.
  46286. * It is mostly used internally for serialization purposes.
  46287. */
  46288. getClassName(): string;
  46289. }
  46290. }
  46291. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46292. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46293. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46294. import { Nullable } from "babylonjs/types";
  46295. /**
  46296. * Manage the keyboard inputs to control the movement of a follow camera.
  46297. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46298. */
  46299. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46300. /**
  46301. * Defines the camera the input is attached to.
  46302. */
  46303. camera: FollowCamera;
  46304. /**
  46305. * Defines the list of key codes associated with the up action (increase heightOffset)
  46306. */
  46307. keysHeightOffsetIncr: number[];
  46308. /**
  46309. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46310. */
  46311. keysHeightOffsetDecr: number[];
  46312. /**
  46313. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46314. */
  46315. keysHeightOffsetModifierAlt: boolean;
  46316. /**
  46317. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46318. */
  46319. keysHeightOffsetModifierCtrl: boolean;
  46320. /**
  46321. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46322. */
  46323. keysHeightOffsetModifierShift: boolean;
  46324. /**
  46325. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46326. */
  46327. keysRotationOffsetIncr: number[];
  46328. /**
  46329. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46330. */
  46331. keysRotationOffsetDecr: number[];
  46332. /**
  46333. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46334. */
  46335. keysRotationOffsetModifierAlt: boolean;
  46336. /**
  46337. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46338. */
  46339. keysRotationOffsetModifierCtrl: boolean;
  46340. /**
  46341. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46342. */
  46343. keysRotationOffsetModifierShift: boolean;
  46344. /**
  46345. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46346. */
  46347. keysRadiusIncr: number[];
  46348. /**
  46349. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46350. */
  46351. keysRadiusDecr: number[];
  46352. /**
  46353. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46354. */
  46355. keysRadiusModifierAlt: boolean;
  46356. /**
  46357. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46358. */
  46359. keysRadiusModifierCtrl: boolean;
  46360. /**
  46361. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46362. */
  46363. keysRadiusModifierShift: boolean;
  46364. /**
  46365. * Defines the rate of change of heightOffset.
  46366. */
  46367. heightSensibility: number;
  46368. /**
  46369. * Defines the rate of change of rotationOffset.
  46370. */
  46371. rotationSensibility: number;
  46372. /**
  46373. * Defines the rate of change of radius.
  46374. */
  46375. radiusSensibility: number;
  46376. private _keys;
  46377. private _ctrlPressed;
  46378. private _altPressed;
  46379. private _shiftPressed;
  46380. private _onCanvasBlurObserver;
  46381. private _onKeyboardObserver;
  46382. private _engine;
  46383. private _scene;
  46384. /**
  46385. * Attach the input controls to a specific dom element to get the input from.
  46386. * @param element Defines the element the controls should be listened from
  46387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46388. */
  46389. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46390. /**
  46391. * Detach the current controls from the specified dom element.
  46392. * @param element Defines the element to stop listening the inputs from
  46393. */
  46394. detachControl(element: Nullable<HTMLElement>): void;
  46395. /**
  46396. * Update the current camera state depending on the inputs that have been used this frame.
  46397. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46398. */
  46399. checkInputs(): void;
  46400. /**
  46401. * Gets the class name of the current input.
  46402. * @returns the class name
  46403. */
  46404. getClassName(): string;
  46405. /**
  46406. * Get the friendly name associated with the input class.
  46407. * @returns the input friendly name
  46408. */
  46409. getSimpleName(): string;
  46410. /**
  46411. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46412. * allow modification of the heightOffset value.
  46413. */
  46414. private _modifierHeightOffset;
  46415. /**
  46416. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46417. * allow modification of the rotationOffset value.
  46418. */
  46419. private _modifierRotationOffset;
  46420. /**
  46421. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46422. * allow modification of the radius value.
  46423. */
  46424. private _modifierRadius;
  46425. }
  46426. }
  46427. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46428. import { Nullable } from "babylonjs/types";
  46429. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46430. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46431. import { Observable } from "babylonjs/Misc/observable";
  46432. module "babylonjs/Cameras/freeCameraInputsManager" {
  46433. interface FreeCameraInputsManager {
  46434. /**
  46435. * @hidden
  46436. */
  46437. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46438. /**
  46439. * Add orientation input support to the input manager.
  46440. * @returns the current input manager
  46441. */
  46442. addDeviceOrientation(): FreeCameraInputsManager;
  46443. }
  46444. }
  46445. /**
  46446. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46447. * Screen rotation is taken into account.
  46448. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46449. */
  46450. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46451. private _camera;
  46452. private _screenOrientationAngle;
  46453. private _constantTranform;
  46454. private _screenQuaternion;
  46455. private _alpha;
  46456. private _beta;
  46457. private _gamma;
  46458. /**
  46459. * Can be used to detect if a device orientation sensor is available on a device
  46460. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46461. * @returns a promise that will resolve on orientation change
  46462. */
  46463. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46464. /**
  46465. * @hidden
  46466. */
  46467. _onDeviceOrientationChangedObservable: Observable<void>;
  46468. /**
  46469. * Instantiates a new input
  46470. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46471. */
  46472. constructor();
  46473. /**
  46474. * Define the camera controlled by the input.
  46475. */
  46476. get camera(): FreeCamera;
  46477. set camera(camera: FreeCamera);
  46478. /**
  46479. * Attach the input controls to a specific dom element to get the input from.
  46480. * @param element Defines the element the controls should be listened from
  46481. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46482. */
  46483. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46484. private _orientationChanged;
  46485. private _deviceOrientation;
  46486. /**
  46487. * Detach the current controls from the specified dom element.
  46488. * @param element Defines the element to stop listening the inputs from
  46489. */
  46490. detachControl(element: Nullable<HTMLElement>): void;
  46491. /**
  46492. * Update the current camera state depending on the inputs that have been used this frame.
  46493. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46494. */
  46495. checkInputs(): void;
  46496. /**
  46497. * Gets the class name of the current intput.
  46498. * @returns the class name
  46499. */
  46500. getClassName(): string;
  46501. /**
  46502. * Get the friendly name associated with the input class.
  46503. * @returns the input friendly name
  46504. */
  46505. getSimpleName(): string;
  46506. }
  46507. }
  46508. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46509. import { Nullable } from "babylonjs/types";
  46510. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46511. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46512. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46513. /**
  46514. * Manage the gamepad inputs to control a free camera.
  46515. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46516. */
  46517. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46518. /**
  46519. * Define the camera the input is attached to.
  46520. */
  46521. camera: FreeCamera;
  46522. /**
  46523. * Define the Gamepad controlling the input
  46524. */
  46525. gamepad: Nullable<Gamepad>;
  46526. /**
  46527. * Defines the gamepad rotation sensiblity.
  46528. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46529. */
  46530. gamepadAngularSensibility: number;
  46531. /**
  46532. * Defines the gamepad move sensiblity.
  46533. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46534. */
  46535. gamepadMoveSensibility: number;
  46536. private _yAxisScale;
  46537. /**
  46538. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46539. */
  46540. get invertYAxis(): boolean;
  46541. set invertYAxis(value: boolean);
  46542. private _onGamepadConnectedObserver;
  46543. private _onGamepadDisconnectedObserver;
  46544. private _cameraTransform;
  46545. private _deltaTransform;
  46546. private _vector3;
  46547. private _vector2;
  46548. /**
  46549. * Attach the input controls to a specific dom element to get the input from.
  46550. * @param element Defines the element the controls should be listened from
  46551. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46552. */
  46553. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46554. /**
  46555. * Detach the current controls from the specified dom element.
  46556. * @param element Defines the element to stop listening the inputs from
  46557. */
  46558. detachControl(element: Nullable<HTMLElement>): void;
  46559. /**
  46560. * Update the current camera state depending on the inputs that have been used this frame.
  46561. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46562. */
  46563. checkInputs(): void;
  46564. /**
  46565. * Gets the class name of the current intput.
  46566. * @returns the class name
  46567. */
  46568. getClassName(): string;
  46569. /**
  46570. * Get the friendly name associated with the input class.
  46571. * @returns the input friendly name
  46572. */
  46573. getSimpleName(): string;
  46574. }
  46575. }
  46576. declare module "babylonjs/Misc/virtualJoystick" {
  46577. import { Nullable } from "babylonjs/types";
  46578. import { Vector3 } from "babylonjs/Maths/math.vector";
  46579. /**
  46580. * Defines the potential axis of a Joystick
  46581. */
  46582. export enum JoystickAxis {
  46583. /** X axis */
  46584. X = 0,
  46585. /** Y axis */
  46586. Y = 1,
  46587. /** Z axis */
  46588. Z = 2
  46589. }
  46590. /**
  46591. * Represents the different customization options available
  46592. * for VirtualJoystick
  46593. */
  46594. interface VirtualJoystickCustomizations {
  46595. /**
  46596. * Size of the joystick's puck
  46597. */
  46598. puckSize: number;
  46599. /**
  46600. * Size of the joystick's container
  46601. */
  46602. containerSize: number;
  46603. /**
  46604. * Color of the joystick && puck
  46605. */
  46606. color: string;
  46607. /**
  46608. * Image URL for the joystick's puck
  46609. */
  46610. puckImage?: string;
  46611. /**
  46612. * Image URL for the joystick's container
  46613. */
  46614. containerImage?: string;
  46615. /**
  46616. * Defines the unmoving position of the joystick container
  46617. */
  46618. position?: {
  46619. x: number;
  46620. y: number;
  46621. };
  46622. /**
  46623. * Defines whether or not the joystick container is always visible
  46624. */
  46625. alwaysVisible: boolean;
  46626. /**
  46627. * Defines whether or not to limit the movement of the puck to the joystick's container
  46628. */
  46629. limitToContainer: boolean;
  46630. }
  46631. /**
  46632. * Class used to define virtual joystick (used in touch mode)
  46633. */
  46634. export class VirtualJoystick {
  46635. /**
  46636. * Gets or sets a boolean indicating that left and right values must be inverted
  46637. */
  46638. reverseLeftRight: boolean;
  46639. /**
  46640. * Gets or sets a boolean indicating that up and down values must be inverted
  46641. */
  46642. reverseUpDown: boolean;
  46643. /**
  46644. * Gets the offset value for the position (ie. the change of the position value)
  46645. */
  46646. deltaPosition: Vector3;
  46647. /**
  46648. * Gets a boolean indicating if the virtual joystick was pressed
  46649. */
  46650. pressed: boolean;
  46651. /**
  46652. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46653. */
  46654. static Canvas: Nullable<HTMLCanvasElement>;
  46655. /**
  46656. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46657. */
  46658. limitToContainer: boolean;
  46659. private static _globalJoystickIndex;
  46660. private static _alwaysVisibleSticks;
  46661. private static vjCanvasContext;
  46662. private static vjCanvasWidth;
  46663. private static vjCanvasHeight;
  46664. private static halfWidth;
  46665. private static _GetDefaultOptions;
  46666. private _action;
  46667. private _axisTargetedByLeftAndRight;
  46668. private _axisTargetedByUpAndDown;
  46669. private _joystickSensibility;
  46670. private _inversedSensibility;
  46671. private _joystickPointerID;
  46672. private _joystickColor;
  46673. private _joystickPointerPos;
  46674. private _joystickPreviousPointerPos;
  46675. private _joystickPointerStartPos;
  46676. private _deltaJoystickVector;
  46677. private _leftJoystick;
  46678. private _touches;
  46679. private _joystickPosition;
  46680. private _alwaysVisible;
  46681. private _puckImage;
  46682. private _containerImage;
  46683. private _joystickPuckSize;
  46684. private _joystickContainerSize;
  46685. private _clearPuckSize;
  46686. private _clearContainerSize;
  46687. private _clearPuckSizeOffset;
  46688. private _clearContainerSizeOffset;
  46689. private _onPointerDownHandlerRef;
  46690. private _onPointerMoveHandlerRef;
  46691. private _onPointerUpHandlerRef;
  46692. private _onResize;
  46693. /**
  46694. * Creates a new virtual joystick
  46695. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46696. * @param customizations Defines the options we want to customize the VirtualJoystick
  46697. */
  46698. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46699. /**
  46700. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46701. * @param newJoystickSensibility defines the new sensibility
  46702. */
  46703. setJoystickSensibility(newJoystickSensibility: number): void;
  46704. private _onPointerDown;
  46705. private _onPointerMove;
  46706. private _onPointerUp;
  46707. /**
  46708. * Change the color of the virtual joystick
  46709. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46710. */
  46711. setJoystickColor(newColor: string): void;
  46712. /**
  46713. * Size of the joystick's container
  46714. */
  46715. set containerSize(newSize: number);
  46716. get containerSize(): number;
  46717. /**
  46718. * Size of the joystick's puck
  46719. */
  46720. set puckSize(newSize: number);
  46721. get puckSize(): number;
  46722. /**
  46723. * Clears the set position of the joystick
  46724. */
  46725. clearPosition(): void;
  46726. /**
  46727. * Defines whether or not the joystick container is always visible
  46728. */
  46729. set alwaysVisible(value: boolean);
  46730. get alwaysVisible(): boolean;
  46731. /**
  46732. * Sets the constant position of the Joystick container
  46733. * @param x X axis coordinate
  46734. * @param y Y axis coordinate
  46735. */
  46736. setPosition(x: number, y: number): void;
  46737. /**
  46738. * Defines a callback to call when the joystick is touched
  46739. * @param action defines the callback
  46740. */
  46741. setActionOnTouch(action: () => any): void;
  46742. /**
  46743. * Defines which axis you'd like to control for left & right
  46744. * @param axis defines the axis to use
  46745. */
  46746. setAxisForLeftRight(axis: JoystickAxis): void;
  46747. /**
  46748. * Defines which axis you'd like to control for up & down
  46749. * @param axis defines the axis to use
  46750. */
  46751. setAxisForUpDown(axis: JoystickAxis): void;
  46752. /**
  46753. * Clears the canvas from the previous puck / container draw
  46754. */
  46755. private _clearPreviousDraw;
  46756. /**
  46757. * Loads `urlPath` to be used for the container's image
  46758. * @param urlPath defines the urlPath of an image to use
  46759. */
  46760. setContainerImage(urlPath: string): void;
  46761. /**
  46762. * Loads `urlPath` to be used for the puck's image
  46763. * @param urlPath defines the urlPath of an image to use
  46764. */
  46765. setPuckImage(urlPath: string): void;
  46766. /**
  46767. * Draws the Virtual Joystick's container
  46768. */
  46769. private _drawContainer;
  46770. /**
  46771. * Draws the Virtual Joystick's puck
  46772. */
  46773. private _drawPuck;
  46774. private _drawVirtualJoystick;
  46775. /**
  46776. * Release internal HTML canvas
  46777. */
  46778. releaseCanvas(): void;
  46779. }
  46780. }
  46781. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46782. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46783. import { Nullable } from "babylonjs/types";
  46784. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46785. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46786. module "babylonjs/Cameras/freeCameraInputsManager" {
  46787. interface FreeCameraInputsManager {
  46788. /**
  46789. * Add virtual joystick input support to the input manager.
  46790. * @returns the current input manager
  46791. */
  46792. addVirtualJoystick(): FreeCameraInputsManager;
  46793. }
  46794. }
  46795. /**
  46796. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46797. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46798. */
  46799. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46800. /**
  46801. * Defines the camera the input is attached to.
  46802. */
  46803. camera: FreeCamera;
  46804. private _leftjoystick;
  46805. private _rightjoystick;
  46806. /**
  46807. * Gets the left stick of the virtual joystick.
  46808. * @returns The virtual Joystick
  46809. */
  46810. getLeftJoystick(): VirtualJoystick;
  46811. /**
  46812. * Gets the right stick of the virtual joystick.
  46813. * @returns The virtual Joystick
  46814. */
  46815. getRightJoystick(): VirtualJoystick;
  46816. /**
  46817. * Update the current camera state depending on the inputs that have been used this frame.
  46818. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46819. */
  46820. checkInputs(): void;
  46821. /**
  46822. * Attach the input controls to a specific dom element to get the input from.
  46823. * @param element Defines the element the controls should be listened from
  46824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46825. */
  46826. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46827. /**
  46828. * Detach the current controls from the specified dom element.
  46829. * @param element Defines the element to stop listening the inputs from
  46830. */
  46831. detachControl(element: Nullable<HTMLElement>): void;
  46832. /**
  46833. * Gets the class name of the current intput.
  46834. * @returns the class name
  46835. */
  46836. getClassName(): string;
  46837. /**
  46838. * Get the friendly name associated with the input class.
  46839. * @returns the input friendly name
  46840. */
  46841. getSimpleName(): string;
  46842. }
  46843. }
  46844. declare module "babylonjs/Cameras/Inputs/index" {
  46845. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  46846. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  46847. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  46848. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  46849. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46850. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  46851. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  46852. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  46853. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  46854. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  46855. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46856. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  46857. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  46858. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  46859. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  46860. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46861. }
  46862. declare module "babylonjs/Cameras/touchCamera" {
  46863. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46864. import { Scene } from "babylonjs/scene";
  46865. import { Vector3 } from "babylonjs/Maths/math.vector";
  46866. /**
  46867. * This represents a FPS type of camera controlled by touch.
  46868. * This is like a universal camera minus the Gamepad controls.
  46869. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46870. */
  46871. export class TouchCamera extends FreeCamera {
  46872. /**
  46873. * Defines the touch sensibility for rotation.
  46874. * The higher the faster.
  46875. */
  46876. get touchAngularSensibility(): number;
  46877. set touchAngularSensibility(value: number);
  46878. /**
  46879. * Defines the touch sensibility for move.
  46880. * The higher the faster.
  46881. */
  46882. get touchMoveSensibility(): number;
  46883. set touchMoveSensibility(value: number);
  46884. /**
  46885. * Instantiates a new touch camera.
  46886. * This represents a FPS type of camera controlled by touch.
  46887. * This is like a universal camera minus the Gamepad controls.
  46888. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46889. * @param name Define the name of the camera in the scene
  46890. * @param position Define the start position of the camera in the scene
  46891. * @param scene Define the scene the camera belongs to
  46892. */
  46893. constructor(name: string, position: Vector3, scene: Scene);
  46894. /**
  46895. * Gets the current object class name.
  46896. * @return the class name
  46897. */
  46898. getClassName(): string;
  46899. /** @hidden */
  46900. _setupInputs(): void;
  46901. }
  46902. }
  46903. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  46904. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46905. import { Scene } from "babylonjs/scene";
  46906. import { Vector3 } from "babylonjs/Maths/math.vector";
  46907. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46908. import { Axis } from "babylonjs/Maths/math.axis";
  46909. /**
  46910. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  46911. * being tilted forward or back and left or right.
  46912. */
  46913. export class DeviceOrientationCamera extends FreeCamera {
  46914. private _initialQuaternion;
  46915. private _quaternionCache;
  46916. private _tmpDragQuaternion;
  46917. private _disablePointerInputWhenUsingDeviceOrientation;
  46918. /**
  46919. * Creates a new device orientation camera
  46920. * @param name The name of the camera
  46921. * @param position The start position camera
  46922. * @param scene The scene the camera belongs to
  46923. */
  46924. constructor(name: string, position: Vector3, scene: Scene);
  46925. /**
  46926. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  46927. */
  46928. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  46929. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  46930. private _dragFactor;
  46931. /**
  46932. * Enabled turning on the y axis when the orientation sensor is active
  46933. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  46934. */
  46935. enableHorizontalDragging(dragFactor?: number): void;
  46936. /**
  46937. * Gets the current instance class name ("DeviceOrientationCamera").
  46938. * This helps avoiding instanceof at run time.
  46939. * @returns the class name
  46940. */
  46941. getClassName(): string;
  46942. /**
  46943. * @hidden
  46944. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  46945. */
  46946. _checkInputs(): void;
  46947. /**
  46948. * Reset the camera to its default orientation on the specified axis only.
  46949. * @param axis The axis to reset
  46950. */
  46951. resetToCurrentRotation(axis?: Axis): void;
  46952. }
  46953. }
  46954. declare module "babylonjs/Gamepads/xboxGamepad" {
  46955. import { Observable } from "babylonjs/Misc/observable";
  46956. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46957. /**
  46958. * Defines supported buttons for XBox360 compatible gamepads
  46959. */
  46960. export enum Xbox360Button {
  46961. /** A */
  46962. A = 0,
  46963. /** B */
  46964. B = 1,
  46965. /** X */
  46966. X = 2,
  46967. /** Y */
  46968. Y = 3,
  46969. /** Left button */
  46970. LB = 4,
  46971. /** Right button */
  46972. RB = 5,
  46973. /** Back */
  46974. Back = 8,
  46975. /** Start */
  46976. Start = 9,
  46977. /** Left stick */
  46978. LeftStick = 10,
  46979. /** Right stick */
  46980. RightStick = 11
  46981. }
  46982. /** Defines values for XBox360 DPad */
  46983. export enum Xbox360Dpad {
  46984. /** Up */
  46985. Up = 12,
  46986. /** Down */
  46987. Down = 13,
  46988. /** Left */
  46989. Left = 14,
  46990. /** Right */
  46991. Right = 15
  46992. }
  46993. /**
  46994. * Defines a XBox360 gamepad
  46995. */
  46996. export class Xbox360Pad extends Gamepad {
  46997. private _leftTrigger;
  46998. private _rightTrigger;
  46999. private _onlefttriggerchanged;
  47000. private _onrighttriggerchanged;
  47001. private _onbuttondown;
  47002. private _onbuttonup;
  47003. private _ondpaddown;
  47004. private _ondpadup;
  47005. /** Observable raised when a button is pressed */
  47006. onButtonDownObservable: Observable<Xbox360Button>;
  47007. /** Observable raised when a button is released */
  47008. onButtonUpObservable: Observable<Xbox360Button>;
  47009. /** Observable raised when a pad is pressed */
  47010. onPadDownObservable: Observable<Xbox360Dpad>;
  47011. /** Observable raised when a pad is released */
  47012. onPadUpObservable: Observable<Xbox360Dpad>;
  47013. private _buttonA;
  47014. private _buttonB;
  47015. private _buttonX;
  47016. private _buttonY;
  47017. private _buttonBack;
  47018. private _buttonStart;
  47019. private _buttonLB;
  47020. private _buttonRB;
  47021. private _buttonLeftStick;
  47022. private _buttonRightStick;
  47023. private _dPadUp;
  47024. private _dPadDown;
  47025. private _dPadLeft;
  47026. private _dPadRight;
  47027. private _isXboxOnePad;
  47028. /**
  47029. * Creates a new XBox360 gamepad object
  47030. * @param id defines the id of this gamepad
  47031. * @param index defines its index
  47032. * @param gamepad defines the internal HTML gamepad object
  47033. * @param xboxOne defines if it is a XBox One gamepad
  47034. */
  47035. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47036. /**
  47037. * Defines the callback to call when left trigger is pressed
  47038. * @param callback defines the callback to use
  47039. */
  47040. onlefttriggerchanged(callback: (value: number) => void): void;
  47041. /**
  47042. * Defines the callback to call when right trigger is pressed
  47043. * @param callback defines the callback to use
  47044. */
  47045. onrighttriggerchanged(callback: (value: number) => void): void;
  47046. /**
  47047. * Gets the left trigger value
  47048. */
  47049. get leftTrigger(): number;
  47050. /**
  47051. * Sets the left trigger value
  47052. */
  47053. set leftTrigger(newValue: number);
  47054. /**
  47055. * Gets the right trigger value
  47056. */
  47057. get rightTrigger(): number;
  47058. /**
  47059. * Sets the right trigger value
  47060. */
  47061. set rightTrigger(newValue: number);
  47062. /**
  47063. * Defines the callback to call when a button is pressed
  47064. * @param callback defines the callback to use
  47065. */
  47066. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47067. /**
  47068. * Defines the callback to call when a button is released
  47069. * @param callback defines the callback to use
  47070. */
  47071. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47072. /**
  47073. * Defines the callback to call when a pad is pressed
  47074. * @param callback defines the callback to use
  47075. */
  47076. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47077. /**
  47078. * Defines the callback to call when a pad is released
  47079. * @param callback defines the callback to use
  47080. */
  47081. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47082. private _setButtonValue;
  47083. private _setDPadValue;
  47084. /**
  47085. * Gets the value of the `A` button
  47086. */
  47087. get buttonA(): number;
  47088. /**
  47089. * Sets the value of the `A` button
  47090. */
  47091. set buttonA(value: number);
  47092. /**
  47093. * Gets the value of the `B` button
  47094. */
  47095. get buttonB(): number;
  47096. /**
  47097. * Sets the value of the `B` button
  47098. */
  47099. set buttonB(value: number);
  47100. /**
  47101. * Gets the value of the `X` button
  47102. */
  47103. get buttonX(): number;
  47104. /**
  47105. * Sets the value of the `X` button
  47106. */
  47107. set buttonX(value: number);
  47108. /**
  47109. * Gets the value of the `Y` button
  47110. */
  47111. get buttonY(): number;
  47112. /**
  47113. * Sets the value of the `Y` button
  47114. */
  47115. set buttonY(value: number);
  47116. /**
  47117. * Gets the value of the `Start` button
  47118. */
  47119. get buttonStart(): number;
  47120. /**
  47121. * Sets the value of the `Start` button
  47122. */
  47123. set buttonStart(value: number);
  47124. /**
  47125. * Gets the value of the `Back` button
  47126. */
  47127. get buttonBack(): number;
  47128. /**
  47129. * Sets the value of the `Back` button
  47130. */
  47131. set buttonBack(value: number);
  47132. /**
  47133. * Gets the value of the `Left` button
  47134. */
  47135. get buttonLB(): number;
  47136. /**
  47137. * Sets the value of the `Left` button
  47138. */
  47139. set buttonLB(value: number);
  47140. /**
  47141. * Gets the value of the `Right` button
  47142. */
  47143. get buttonRB(): number;
  47144. /**
  47145. * Sets the value of the `Right` button
  47146. */
  47147. set buttonRB(value: number);
  47148. /**
  47149. * Gets the value of the Left joystick
  47150. */
  47151. get buttonLeftStick(): number;
  47152. /**
  47153. * Sets the value of the Left joystick
  47154. */
  47155. set buttonLeftStick(value: number);
  47156. /**
  47157. * Gets the value of the Right joystick
  47158. */
  47159. get buttonRightStick(): number;
  47160. /**
  47161. * Sets the value of the Right joystick
  47162. */
  47163. set buttonRightStick(value: number);
  47164. /**
  47165. * Gets the value of D-pad up
  47166. */
  47167. get dPadUp(): number;
  47168. /**
  47169. * Sets the value of D-pad up
  47170. */
  47171. set dPadUp(value: number);
  47172. /**
  47173. * Gets the value of D-pad down
  47174. */
  47175. get dPadDown(): number;
  47176. /**
  47177. * Sets the value of D-pad down
  47178. */
  47179. set dPadDown(value: number);
  47180. /**
  47181. * Gets the value of D-pad left
  47182. */
  47183. get dPadLeft(): number;
  47184. /**
  47185. * Sets the value of D-pad left
  47186. */
  47187. set dPadLeft(value: number);
  47188. /**
  47189. * Gets the value of D-pad right
  47190. */
  47191. get dPadRight(): number;
  47192. /**
  47193. * Sets the value of D-pad right
  47194. */
  47195. set dPadRight(value: number);
  47196. /**
  47197. * Force the gamepad to synchronize with device values
  47198. */
  47199. update(): void;
  47200. /**
  47201. * Disposes the gamepad
  47202. */
  47203. dispose(): void;
  47204. }
  47205. }
  47206. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47207. import { Observable } from "babylonjs/Misc/observable";
  47208. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47209. /**
  47210. * Defines supported buttons for DualShock compatible gamepads
  47211. */
  47212. export enum DualShockButton {
  47213. /** Cross */
  47214. Cross = 0,
  47215. /** Circle */
  47216. Circle = 1,
  47217. /** Square */
  47218. Square = 2,
  47219. /** Triangle */
  47220. Triangle = 3,
  47221. /** L1 */
  47222. L1 = 4,
  47223. /** R1 */
  47224. R1 = 5,
  47225. /** Share */
  47226. Share = 8,
  47227. /** Options */
  47228. Options = 9,
  47229. /** Left stick */
  47230. LeftStick = 10,
  47231. /** Right stick */
  47232. RightStick = 11
  47233. }
  47234. /** Defines values for DualShock DPad */
  47235. export enum DualShockDpad {
  47236. /** Up */
  47237. Up = 12,
  47238. /** Down */
  47239. Down = 13,
  47240. /** Left */
  47241. Left = 14,
  47242. /** Right */
  47243. Right = 15
  47244. }
  47245. /**
  47246. * Defines a DualShock gamepad
  47247. */
  47248. export class DualShockPad extends Gamepad {
  47249. private _leftTrigger;
  47250. private _rightTrigger;
  47251. private _onlefttriggerchanged;
  47252. private _onrighttriggerchanged;
  47253. private _onbuttondown;
  47254. private _onbuttonup;
  47255. private _ondpaddown;
  47256. private _ondpadup;
  47257. /** Observable raised when a button is pressed */
  47258. onButtonDownObservable: Observable<DualShockButton>;
  47259. /** Observable raised when a button is released */
  47260. onButtonUpObservable: Observable<DualShockButton>;
  47261. /** Observable raised when a pad is pressed */
  47262. onPadDownObservable: Observable<DualShockDpad>;
  47263. /** Observable raised when a pad is released */
  47264. onPadUpObservable: Observable<DualShockDpad>;
  47265. private _buttonCross;
  47266. private _buttonCircle;
  47267. private _buttonSquare;
  47268. private _buttonTriangle;
  47269. private _buttonShare;
  47270. private _buttonOptions;
  47271. private _buttonL1;
  47272. private _buttonR1;
  47273. private _buttonLeftStick;
  47274. private _buttonRightStick;
  47275. private _dPadUp;
  47276. private _dPadDown;
  47277. private _dPadLeft;
  47278. private _dPadRight;
  47279. /**
  47280. * Creates a new DualShock gamepad object
  47281. * @param id defines the id of this gamepad
  47282. * @param index defines its index
  47283. * @param gamepad defines the internal HTML gamepad object
  47284. */
  47285. constructor(id: string, index: number, gamepad: any);
  47286. /**
  47287. * Defines the callback to call when left trigger is pressed
  47288. * @param callback defines the callback to use
  47289. */
  47290. onlefttriggerchanged(callback: (value: number) => void): void;
  47291. /**
  47292. * Defines the callback to call when right trigger is pressed
  47293. * @param callback defines the callback to use
  47294. */
  47295. onrighttriggerchanged(callback: (value: number) => void): void;
  47296. /**
  47297. * Gets the left trigger value
  47298. */
  47299. get leftTrigger(): number;
  47300. /**
  47301. * Sets the left trigger value
  47302. */
  47303. set leftTrigger(newValue: number);
  47304. /**
  47305. * Gets the right trigger value
  47306. */
  47307. get rightTrigger(): number;
  47308. /**
  47309. * Sets the right trigger value
  47310. */
  47311. set rightTrigger(newValue: number);
  47312. /**
  47313. * Defines the callback to call when a button is pressed
  47314. * @param callback defines the callback to use
  47315. */
  47316. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47317. /**
  47318. * Defines the callback to call when a button is released
  47319. * @param callback defines the callback to use
  47320. */
  47321. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47322. /**
  47323. * Defines the callback to call when a pad is pressed
  47324. * @param callback defines the callback to use
  47325. */
  47326. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47327. /**
  47328. * Defines the callback to call when a pad is released
  47329. * @param callback defines the callback to use
  47330. */
  47331. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47332. private _setButtonValue;
  47333. private _setDPadValue;
  47334. /**
  47335. * Gets the value of the `Cross` button
  47336. */
  47337. get buttonCross(): number;
  47338. /**
  47339. * Sets the value of the `Cross` button
  47340. */
  47341. set buttonCross(value: number);
  47342. /**
  47343. * Gets the value of the `Circle` button
  47344. */
  47345. get buttonCircle(): number;
  47346. /**
  47347. * Sets the value of the `Circle` button
  47348. */
  47349. set buttonCircle(value: number);
  47350. /**
  47351. * Gets the value of the `Square` button
  47352. */
  47353. get buttonSquare(): number;
  47354. /**
  47355. * Sets the value of the `Square` button
  47356. */
  47357. set buttonSquare(value: number);
  47358. /**
  47359. * Gets the value of the `Triangle` button
  47360. */
  47361. get buttonTriangle(): number;
  47362. /**
  47363. * Sets the value of the `Triangle` button
  47364. */
  47365. set buttonTriangle(value: number);
  47366. /**
  47367. * Gets the value of the `Options` button
  47368. */
  47369. get buttonOptions(): number;
  47370. /**
  47371. * Sets the value of the `Options` button
  47372. */
  47373. set buttonOptions(value: number);
  47374. /**
  47375. * Gets the value of the `Share` button
  47376. */
  47377. get buttonShare(): number;
  47378. /**
  47379. * Sets the value of the `Share` button
  47380. */
  47381. set buttonShare(value: number);
  47382. /**
  47383. * Gets the value of the `L1` button
  47384. */
  47385. get buttonL1(): number;
  47386. /**
  47387. * Sets the value of the `L1` button
  47388. */
  47389. set buttonL1(value: number);
  47390. /**
  47391. * Gets the value of the `R1` button
  47392. */
  47393. get buttonR1(): number;
  47394. /**
  47395. * Sets the value of the `R1` button
  47396. */
  47397. set buttonR1(value: number);
  47398. /**
  47399. * Gets the value of the Left joystick
  47400. */
  47401. get buttonLeftStick(): number;
  47402. /**
  47403. * Sets the value of the Left joystick
  47404. */
  47405. set buttonLeftStick(value: number);
  47406. /**
  47407. * Gets the value of the Right joystick
  47408. */
  47409. get buttonRightStick(): number;
  47410. /**
  47411. * Sets the value of the Right joystick
  47412. */
  47413. set buttonRightStick(value: number);
  47414. /**
  47415. * Gets the value of D-pad up
  47416. */
  47417. get dPadUp(): number;
  47418. /**
  47419. * Sets the value of D-pad up
  47420. */
  47421. set dPadUp(value: number);
  47422. /**
  47423. * Gets the value of D-pad down
  47424. */
  47425. get dPadDown(): number;
  47426. /**
  47427. * Sets the value of D-pad down
  47428. */
  47429. set dPadDown(value: number);
  47430. /**
  47431. * Gets the value of D-pad left
  47432. */
  47433. get dPadLeft(): number;
  47434. /**
  47435. * Sets the value of D-pad left
  47436. */
  47437. set dPadLeft(value: number);
  47438. /**
  47439. * Gets the value of D-pad right
  47440. */
  47441. get dPadRight(): number;
  47442. /**
  47443. * Sets the value of D-pad right
  47444. */
  47445. set dPadRight(value: number);
  47446. /**
  47447. * Force the gamepad to synchronize with device values
  47448. */
  47449. update(): void;
  47450. /**
  47451. * Disposes the gamepad
  47452. */
  47453. dispose(): void;
  47454. }
  47455. }
  47456. declare module "babylonjs/Gamepads/gamepadManager" {
  47457. import { Observable } from "babylonjs/Misc/observable";
  47458. import { Nullable } from "babylonjs/types";
  47459. import { Scene } from "babylonjs/scene";
  47460. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47461. /**
  47462. * Manager for handling gamepads
  47463. */
  47464. export class GamepadManager {
  47465. private _scene?;
  47466. private _babylonGamepads;
  47467. private _oneGamepadConnected;
  47468. /** @hidden */
  47469. _isMonitoring: boolean;
  47470. private _gamepadEventSupported;
  47471. private _gamepadSupport?;
  47472. /**
  47473. * observable to be triggered when the gamepad controller has been connected
  47474. */
  47475. onGamepadConnectedObservable: Observable<Gamepad>;
  47476. /**
  47477. * observable to be triggered when the gamepad controller has been disconnected
  47478. */
  47479. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47480. private _onGamepadConnectedEvent;
  47481. private _onGamepadDisconnectedEvent;
  47482. /**
  47483. * Initializes the gamepad manager
  47484. * @param _scene BabylonJS scene
  47485. */
  47486. constructor(_scene?: Scene | undefined);
  47487. /**
  47488. * The gamepads in the game pad manager
  47489. */
  47490. get gamepads(): Gamepad[];
  47491. /**
  47492. * Get the gamepad controllers based on type
  47493. * @param type The type of gamepad controller
  47494. * @returns Nullable gamepad
  47495. */
  47496. getGamepadByType(type?: number): Nullable<Gamepad>;
  47497. /**
  47498. * Disposes the gamepad manager
  47499. */
  47500. dispose(): void;
  47501. private _addNewGamepad;
  47502. private _startMonitoringGamepads;
  47503. private _stopMonitoringGamepads;
  47504. /** @hidden */
  47505. _checkGamepadsStatus(): void;
  47506. private _updateGamepadObjects;
  47507. }
  47508. }
  47509. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47510. import { Nullable } from "babylonjs/types";
  47511. import { Scene } from "babylonjs/scene";
  47512. import { ISceneComponent } from "babylonjs/sceneComponent";
  47513. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47514. module "babylonjs/scene" {
  47515. interface Scene {
  47516. /** @hidden */
  47517. _gamepadManager: Nullable<GamepadManager>;
  47518. /**
  47519. * Gets the gamepad manager associated with the scene
  47520. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47521. */
  47522. gamepadManager: GamepadManager;
  47523. }
  47524. }
  47525. module "babylonjs/Cameras/freeCameraInputsManager" {
  47526. /**
  47527. * Interface representing a free camera inputs manager
  47528. */
  47529. interface FreeCameraInputsManager {
  47530. /**
  47531. * Adds gamepad input support to the FreeCameraInputsManager.
  47532. * @returns the FreeCameraInputsManager
  47533. */
  47534. addGamepad(): FreeCameraInputsManager;
  47535. }
  47536. }
  47537. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47538. /**
  47539. * Interface representing an arc rotate camera inputs manager
  47540. */
  47541. interface ArcRotateCameraInputsManager {
  47542. /**
  47543. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47544. * @returns the camera inputs manager
  47545. */
  47546. addGamepad(): ArcRotateCameraInputsManager;
  47547. }
  47548. }
  47549. /**
  47550. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47551. */
  47552. export class GamepadSystemSceneComponent implements ISceneComponent {
  47553. /**
  47554. * The component name helpfull to identify the component in the list of scene components.
  47555. */
  47556. readonly name: string;
  47557. /**
  47558. * The scene the component belongs to.
  47559. */
  47560. scene: Scene;
  47561. /**
  47562. * Creates a new instance of the component for the given scene
  47563. * @param scene Defines the scene to register the component in
  47564. */
  47565. constructor(scene: Scene);
  47566. /**
  47567. * Registers the component in a given scene
  47568. */
  47569. register(): void;
  47570. /**
  47571. * Rebuilds the elements related to this component in case of
  47572. * context lost for instance.
  47573. */
  47574. rebuild(): void;
  47575. /**
  47576. * Disposes the component and the associated ressources
  47577. */
  47578. dispose(): void;
  47579. private _beforeCameraUpdate;
  47580. }
  47581. }
  47582. declare module "babylonjs/Cameras/universalCamera" {
  47583. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47584. import { Scene } from "babylonjs/scene";
  47585. import { Vector3 } from "babylonjs/Maths/math.vector";
  47586. import "babylonjs/Gamepads/gamepadSceneComponent";
  47587. /**
  47588. * 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,
  47589. * which still works and will still be found in many Playgrounds.
  47590. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47591. */
  47592. export class UniversalCamera extends TouchCamera {
  47593. /**
  47594. * Defines the gamepad rotation sensiblity.
  47595. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47596. */
  47597. get gamepadAngularSensibility(): number;
  47598. set gamepadAngularSensibility(value: number);
  47599. /**
  47600. * Defines the gamepad move sensiblity.
  47601. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47602. */
  47603. get gamepadMoveSensibility(): number;
  47604. set gamepadMoveSensibility(value: number);
  47605. /**
  47606. * 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,
  47607. * which still works and will still be found in many Playgrounds.
  47608. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47609. * @param name Define the name of the camera in the scene
  47610. * @param position Define the start position of the camera in the scene
  47611. * @param scene Define the scene the camera belongs to
  47612. */
  47613. constructor(name: string, position: Vector3, scene: Scene);
  47614. /**
  47615. * Gets the current object class name.
  47616. * @return the class name
  47617. */
  47618. getClassName(): string;
  47619. }
  47620. }
  47621. declare module "babylonjs/Cameras/gamepadCamera" {
  47622. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47623. import { Scene } from "babylonjs/scene";
  47624. import { Vector3 } from "babylonjs/Maths/math.vector";
  47625. /**
  47626. * This represents a FPS type of camera. This is only here for back compat purpose.
  47627. * Please use the UniversalCamera instead as both are identical.
  47628. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47629. */
  47630. export class GamepadCamera extends UniversalCamera {
  47631. /**
  47632. * Instantiates a new Gamepad Camera
  47633. * This represents a FPS type of camera. This is only here for back compat purpose.
  47634. * Please use the UniversalCamera instead as both are identical.
  47635. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47636. * @param name Define the name of the camera in the scene
  47637. * @param position Define the start position of the camera in the scene
  47638. * @param scene Define the scene the camera belongs to
  47639. */
  47640. constructor(name: string, position: Vector3, scene: Scene);
  47641. /**
  47642. * Gets the current object class name.
  47643. * @return the class name
  47644. */
  47645. getClassName(): string;
  47646. }
  47647. }
  47648. declare module "babylonjs/Shaders/pass.fragment" {
  47649. /** @hidden */
  47650. export var passPixelShader: {
  47651. name: string;
  47652. shader: string;
  47653. };
  47654. }
  47655. declare module "babylonjs/Shaders/passCube.fragment" {
  47656. /** @hidden */
  47657. export var passCubePixelShader: {
  47658. name: string;
  47659. shader: string;
  47660. };
  47661. }
  47662. declare module "babylonjs/PostProcesses/passPostProcess" {
  47663. import { Nullable } from "babylonjs/types";
  47664. import { Camera } from "babylonjs/Cameras/camera";
  47665. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47666. import { Engine } from "babylonjs/Engines/engine";
  47667. import "babylonjs/Shaders/pass.fragment";
  47668. import "babylonjs/Shaders/passCube.fragment";
  47669. import { Scene } from "babylonjs/scene";
  47670. /**
  47671. * PassPostProcess which produces an output the same as it's input
  47672. */
  47673. export class PassPostProcess extends PostProcess {
  47674. /**
  47675. * Gets a string identifying the name of the class
  47676. * @returns "PassPostProcess" string
  47677. */
  47678. getClassName(): string;
  47679. /**
  47680. * Creates the PassPostProcess
  47681. * @param name The name of the effect.
  47682. * @param options The required width/height ratio to downsize to before computing the render pass.
  47683. * @param camera The camera to apply the render pass to.
  47684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47685. * @param engine The engine which the post process will be applied. (default: current engine)
  47686. * @param reusable If the post process can be reused on the same frame. (default: false)
  47687. * @param textureType The type of texture to be used when performing the post processing.
  47688. * @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)
  47689. */
  47690. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47691. /** @hidden */
  47692. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47693. }
  47694. /**
  47695. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47696. */
  47697. export class PassCubePostProcess extends PostProcess {
  47698. private _face;
  47699. /**
  47700. * Gets or sets the cube face to display.
  47701. * * 0 is +X
  47702. * * 1 is -X
  47703. * * 2 is +Y
  47704. * * 3 is -Y
  47705. * * 4 is +Z
  47706. * * 5 is -Z
  47707. */
  47708. get face(): number;
  47709. set face(value: number);
  47710. /**
  47711. * Gets a string identifying the name of the class
  47712. * @returns "PassCubePostProcess" string
  47713. */
  47714. getClassName(): string;
  47715. /**
  47716. * Creates the PassCubePostProcess
  47717. * @param name The name of the effect.
  47718. * @param options The required width/height ratio to downsize to before computing the render pass.
  47719. * @param camera The camera to apply the render pass to.
  47720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47721. * @param engine The engine which the post process will be applied. (default: current engine)
  47722. * @param reusable If the post process can be reused on the same frame. (default: false)
  47723. * @param textureType The type of texture to be used when performing the post processing.
  47724. * @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)
  47725. */
  47726. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47727. /** @hidden */
  47728. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  47729. }
  47730. }
  47731. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47732. /** @hidden */
  47733. export var anaglyphPixelShader: {
  47734. name: string;
  47735. shader: string;
  47736. };
  47737. }
  47738. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47739. import { Engine } from "babylonjs/Engines/engine";
  47740. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47741. import { Camera } from "babylonjs/Cameras/camera";
  47742. import "babylonjs/Shaders/anaglyph.fragment";
  47743. /**
  47744. * Postprocess used to generate anaglyphic rendering
  47745. */
  47746. export class AnaglyphPostProcess extends PostProcess {
  47747. private _passedProcess;
  47748. /**
  47749. * Gets a string identifying the name of the class
  47750. * @returns "AnaglyphPostProcess" string
  47751. */
  47752. getClassName(): string;
  47753. /**
  47754. * Creates a new AnaglyphPostProcess
  47755. * @param name defines postprocess name
  47756. * @param options defines creation options or target ratio scale
  47757. * @param rigCameras defines cameras using this postprocess
  47758. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47759. * @param engine defines hosting engine
  47760. * @param reusable defines if the postprocess will be reused multiple times per frame
  47761. */
  47762. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47763. }
  47764. }
  47765. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47766. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47767. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47768. import { Scene } from "babylonjs/scene";
  47769. import { Vector3 } from "babylonjs/Maths/math.vector";
  47770. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47771. /**
  47772. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47773. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47774. */
  47775. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47776. /**
  47777. * Creates a new AnaglyphArcRotateCamera
  47778. * @param name defines camera name
  47779. * @param alpha defines alpha angle (in radians)
  47780. * @param beta defines beta angle (in radians)
  47781. * @param radius defines radius
  47782. * @param target defines camera target
  47783. * @param interaxialDistance defines distance between each color axis
  47784. * @param scene defines the hosting scene
  47785. */
  47786. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47787. /**
  47788. * Gets camera class name
  47789. * @returns AnaglyphArcRotateCamera
  47790. */
  47791. getClassName(): string;
  47792. }
  47793. }
  47794. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47795. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47796. import { Scene } from "babylonjs/scene";
  47797. import { Vector3 } from "babylonjs/Maths/math.vector";
  47798. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47799. /**
  47800. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47801. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47802. */
  47803. export class AnaglyphFreeCamera extends FreeCamera {
  47804. /**
  47805. * Creates a new AnaglyphFreeCamera
  47806. * @param name defines camera name
  47807. * @param position defines initial position
  47808. * @param interaxialDistance defines distance between each color axis
  47809. * @param scene defines the hosting scene
  47810. */
  47811. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47812. /**
  47813. * Gets camera class name
  47814. * @returns AnaglyphFreeCamera
  47815. */
  47816. getClassName(): string;
  47817. }
  47818. }
  47819. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47820. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47821. import { Scene } from "babylonjs/scene";
  47822. import { Vector3 } from "babylonjs/Maths/math.vector";
  47823. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47824. /**
  47825. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47826. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47827. */
  47828. export class AnaglyphGamepadCamera extends GamepadCamera {
  47829. /**
  47830. * Creates a new AnaglyphGamepadCamera
  47831. * @param name defines camera name
  47832. * @param position defines initial position
  47833. * @param interaxialDistance defines distance between each color axis
  47834. * @param scene defines the hosting scene
  47835. */
  47836. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47837. /**
  47838. * Gets camera class name
  47839. * @returns AnaglyphGamepadCamera
  47840. */
  47841. getClassName(): string;
  47842. }
  47843. }
  47844. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  47845. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47846. import { Scene } from "babylonjs/scene";
  47847. import { Vector3 } from "babylonjs/Maths/math.vector";
  47848. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47849. /**
  47850. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  47851. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47852. */
  47853. export class AnaglyphUniversalCamera extends UniversalCamera {
  47854. /**
  47855. * Creates a new AnaglyphUniversalCamera
  47856. * @param name defines camera name
  47857. * @param position defines initial position
  47858. * @param interaxialDistance defines distance between each color axis
  47859. * @param scene defines the hosting scene
  47860. */
  47861. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47862. /**
  47863. * Gets camera class name
  47864. * @returns AnaglyphUniversalCamera
  47865. */
  47866. getClassName(): string;
  47867. }
  47868. }
  47869. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  47870. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  47871. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47872. import { Scene } from "babylonjs/scene";
  47873. import { Vector3 } from "babylonjs/Maths/math.vector";
  47874. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47875. /**
  47876. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  47877. * @see https://doc.babylonjs.com/features/cameras
  47878. */
  47879. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  47880. /**
  47881. * Creates a new StereoscopicArcRotateCamera
  47882. * @param name defines camera name
  47883. * @param alpha defines alpha angle (in radians)
  47884. * @param beta defines beta angle (in radians)
  47885. * @param radius defines radius
  47886. * @param target defines camera target
  47887. * @param interaxialDistance defines distance between each color axis
  47888. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47889. * @param scene defines the hosting scene
  47890. */
  47891. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47892. /**
  47893. * Gets camera class name
  47894. * @returns StereoscopicArcRotateCamera
  47895. */
  47896. getClassName(): string;
  47897. }
  47898. }
  47899. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  47900. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47901. import { Scene } from "babylonjs/scene";
  47902. import { Vector3 } from "babylonjs/Maths/math.vector";
  47903. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47904. /**
  47905. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  47906. * @see https://doc.babylonjs.com/features/cameras
  47907. */
  47908. export class StereoscopicFreeCamera extends FreeCamera {
  47909. /**
  47910. * Creates a new StereoscopicFreeCamera
  47911. * @param name defines camera name
  47912. * @param position defines initial position
  47913. * @param interaxialDistance defines distance between each color axis
  47914. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47915. * @param scene defines the hosting scene
  47916. */
  47917. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47918. /**
  47919. * Gets camera class name
  47920. * @returns StereoscopicFreeCamera
  47921. */
  47922. getClassName(): string;
  47923. }
  47924. }
  47925. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  47926. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47927. import { Scene } from "babylonjs/scene";
  47928. import { Vector3 } from "babylonjs/Maths/math.vector";
  47929. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47930. /**
  47931. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  47932. * @see https://doc.babylonjs.com/features/cameras
  47933. */
  47934. export class StereoscopicGamepadCamera extends GamepadCamera {
  47935. /**
  47936. * Creates a new StereoscopicGamepadCamera
  47937. * @param name defines camera name
  47938. * @param position defines initial position
  47939. * @param interaxialDistance defines distance between each color axis
  47940. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47941. * @param scene defines the hosting scene
  47942. */
  47943. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47944. /**
  47945. * Gets camera class name
  47946. * @returns StereoscopicGamepadCamera
  47947. */
  47948. getClassName(): string;
  47949. }
  47950. }
  47951. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  47952. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47953. import { Scene } from "babylonjs/scene";
  47954. import { Vector3 } from "babylonjs/Maths/math.vector";
  47955. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47956. /**
  47957. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  47958. * @see https://doc.babylonjs.com/features/cameras
  47959. */
  47960. export class StereoscopicUniversalCamera extends UniversalCamera {
  47961. /**
  47962. * Creates a new StereoscopicUniversalCamera
  47963. * @param name defines camera name
  47964. * @param position defines initial position
  47965. * @param interaxialDistance defines distance between each color axis
  47966. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47967. * @param scene defines the hosting scene
  47968. */
  47969. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47970. /**
  47971. * Gets camera class name
  47972. * @returns StereoscopicUniversalCamera
  47973. */
  47974. getClassName(): string;
  47975. }
  47976. }
  47977. declare module "babylonjs/Cameras/Stereoscopic/index" {
  47978. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  47979. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  47980. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  47981. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  47982. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  47983. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  47984. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  47985. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  47986. }
  47987. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  47988. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47989. import { Scene } from "babylonjs/scene";
  47990. import { Vector3 } from "babylonjs/Maths/math.vector";
  47991. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47992. /**
  47993. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  47994. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47995. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47996. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47997. */
  47998. export class VirtualJoysticksCamera extends FreeCamera {
  47999. /**
  48000. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  48001. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48002. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48003. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48004. * @param name Define the name of the camera in the scene
  48005. * @param position Define the start position of the camera in the scene
  48006. * @param scene Define the scene the camera belongs to
  48007. */
  48008. constructor(name: string, position: Vector3, scene: Scene);
  48009. /**
  48010. * Gets the current object class name.
  48011. * @return the class name
  48012. */
  48013. getClassName(): string;
  48014. }
  48015. }
  48016. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  48017. import { Matrix } from "babylonjs/Maths/math.vector";
  48018. /**
  48019. * This represents all the required metrics to create a VR camera.
  48020. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  48021. */
  48022. export class VRCameraMetrics {
  48023. /**
  48024. * Define the horizontal resolution off the screen.
  48025. */
  48026. hResolution: number;
  48027. /**
  48028. * Define the vertical resolution off the screen.
  48029. */
  48030. vResolution: number;
  48031. /**
  48032. * Define the horizontal screen size.
  48033. */
  48034. hScreenSize: number;
  48035. /**
  48036. * Define the vertical screen size.
  48037. */
  48038. vScreenSize: number;
  48039. /**
  48040. * Define the vertical screen center position.
  48041. */
  48042. vScreenCenter: number;
  48043. /**
  48044. * Define the distance of the eyes to the screen.
  48045. */
  48046. eyeToScreenDistance: number;
  48047. /**
  48048. * Define the distance between both lenses
  48049. */
  48050. lensSeparationDistance: number;
  48051. /**
  48052. * Define the distance between both viewer's eyes.
  48053. */
  48054. interpupillaryDistance: number;
  48055. /**
  48056. * Define the distortion factor of the VR postprocess.
  48057. * Please, touch with care.
  48058. */
  48059. distortionK: number[];
  48060. /**
  48061. * Define the chromatic aberration correction factors for the VR post process.
  48062. */
  48063. chromaAbCorrection: number[];
  48064. /**
  48065. * Define the scale factor of the post process.
  48066. * The smaller the better but the slower.
  48067. */
  48068. postProcessScaleFactor: number;
  48069. /**
  48070. * Define an offset for the lens center.
  48071. */
  48072. lensCenterOffset: number;
  48073. /**
  48074. * Define if the current vr camera should compensate the distortion of the lense or not.
  48075. */
  48076. compensateDistortion: boolean;
  48077. /**
  48078. * Defines if multiview should be enabled when rendering (Default: false)
  48079. */
  48080. multiviewEnabled: boolean;
  48081. /**
  48082. * Gets the rendering aspect ratio based on the provided resolutions.
  48083. */
  48084. get aspectRatio(): number;
  48085. /**
  48086. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48087. */
  48088. get aspectRatioFov(): number;
  48089. /**
  48090. * @hidden
  48091. */
  48092. get leftHMatrix(): Matrix;
  48093. /**
  48094. * @hidden
  48095. */
  48096. get rightHMatrix(): Matrix;
  48097. /**
  48098. * @hidden
  48099. */
  48100. get leftPreViewMatrix(): Matrix;
  48101. /**
  48102. * @hidden
  48103. */
  48104. get rightPreViewMatrix(): Matrix;
  48105. /**
  48106. * Get the default VRMetrics based on the most generic setup.
  48107. * @returns the default vr metrics
  48108. */
  48109. static GetDefault(): VRCameraMetrics;
  48110. }
  48111. }
  48112. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48113. /** @hidden */
  48114. export var vrDistortionCorrectionPixelShader: {
  48115. name: string;
  48116. shader: string;
  48117. };
  48118. }
  48119. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48120. import { Camera } from "babylonjs/Cameras/camera";
  48121. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48122. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48123. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48124. /**
  48125. * VRDistortionCorrectionPostProcess used for mobile VR
  48126. */
  48127. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48128. private _isRightEye;
  48129. private _distortionFactors;
  48130. private _postProcessScaleFactor;
  48131. private _lensCenterOffset;
  48132. private _scaleIn;
  48133. private _scaleFactor;
  48134. private _lensCenter;
  48135. /**
  48136. * Gets a string identifying the name of the class
  48137. * @returns "VRDistortionCorrectionPostProcess" string
  48138. */
  48139. getClassName(): string;
  48140. /**
  48141. * Initializes the VRDistortionCorrectionPostProcess
  48142. * @param name The name of the effect.
  48143. * @param camera The camera to apply the render pass to.
  48144. * @param isRightEye If this is for the right eye distortion
  48145. * @param vrMetrics All the required metrics for the VR camera
  48146. */
  48147. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48148. }
  48149. }
  48150. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48151. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48152. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48153. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48154. import { Scene } from "babylonjs/scene";
  48155. import { Vector3 } from "babylonjs/Maths/math.vector";
  48156. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48157. import "babylonjs/Cameras/RigModes/vrRigMode";
  48158. /**
  48159. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48160. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48161. */
  48162. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48163. /**
  48164. * Creates a new VRDeviceOrientationArcRotateCamera
  48165. * @param name defines camera name
  48166. * @param alpha defines the camera rotation along the logitudinal axis
  48167. * @param beta defines the camera rotation along the latitudinal axis
  48168. * @param radius defines the camera distance from its target
  48169. * @param target defines the camera target
  48170. * @param scene defines the scene the camera belongs to
  48171. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48172. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48173. */
  48174. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48175. /**
  48176. * Gets camera class name
  48177. * @returns VRDeviceOrientationArcRotateCamera
  48178. */
  48179. getClassName(): string;
  48180. }
  48181. }
  48182. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48183. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48184. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48185. import { Scene } from "babylonjs/scene";
  48186. import { Vector3 } from "babylonjs/Maths/math.vector";
  48187. import "babylonjs/Cameras/RigModes/vrRigMode";
  48188. /**
  48189. * Camera used to simulate VR rendering (based on FreeCamera)
  48190. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48191. */
  48192. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48193. /**
  48194. * Creates a new VRDeviceOrientationFreeCamera
  48195. * @param name defines camera name
  48196. * @param position defines the start position of the camera
  48197. * @param scene defines the scene the camera belongs to
  48198. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48199. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48200. */
  48201. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48202. /**
  48203. * Gets camera class name
  48204. * @returns VRDeviceOrientationFreeCamera
  48205. */
  48206. getClassName(): string;
  48207. }
  48208. }
  48209. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48210. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48211. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48212. import { Scene } from "babylonjs/scene";
  48213. import { Vector3 } from "babylonjs/Maths/math.vector";
  48214. import "babylonjs/Gamepads/gamepadSceneComponent";
  48215. /**
  48216. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48217. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48218. */
  48219. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48220. /**
  48221. * Creates a new VRDeviceOrientationGamepadCamera
  48222. * @param name defines camera name
  48223. * @param position defines the start position of the camera
  48224. * @param scene defines the scene the camera belongs to
  48225. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48226. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48227. */
  48228. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48229. /**
  48230. * Gets camera class name
  48231. * @returns VRDeviceOrientationGamepadCamera
  48232. */
  48233. getClassName(): string;
  48234. }
  48235. }
  48236. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48237. import { Scene } from "babylonjs/scene";
  48238. import { Texture } from "babylonjs/Materials/Textures/texture";
  48239. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48240. /**
  48241. * A class extending Texture allowing drawing on a texture
  48242. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48243. */
  48244. export class DynamicTexture extends Texture {
  48245. private _generateMipMaps;
  48246. private _canvas;
  48247. private _context;
  48248. /**
  48249. * Creates a DynamicTexture
  48250. * @param name defines the name of the texture
  48251. * @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
  48252. * @param scene defines the scene where you want the texture
  48253. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48254. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48255. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48256. */
  48257. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48258. /**
  48259. * Get the current class name of the texture useful for serialization or dynamic coding.
  48260. * @returns "DynamicTexture"
  48261. */
  48262. getClassName(): string;
  48263. /**
  48264. * Gets the current state of canRescale
  48265. */
  48266. get canRescale(): boolean;
  48267. private _recreate;
  48268. /**
  48269. * Scales the texture
  48270. * @param ratio the scale factor to apply to both width and height
  48271. */
  48272. scale(ratio: number): void;
  48273. /**
  48274. * Resizes the texture
  48275. * @param width the new width
  48276. * @param height the new height
  48277. */
  48278. scaleTo(width: number, height: number): void;
  48279. /**
  48280. * Gets the context of the canvas used by the texture
  48281. * @returns the canvas context of the dynamic texture
  48282. */
  48283. getContext(): CanvasRenderingContext2D;
  48284. /**
  48285. * Clears the texture
  48286. */
  48287. clear(): void;
  48288. /**
  48289. * Updates the texture
  48290. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48291. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48292. */
  48293. update(invertY?: boolean, premulAlpha?: boolean): void;
  48294. /**
  48295. * Draws text onto the texture
  48296. * @param text defines the text to be drawn
  48297. * @param x defines the placement of the text from the left
  48298. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48299. * @param font defines the font to be used with font-style, font-size, font-name
  48300. * @param color defines the color used for the text
  48301. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48302. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48303. * @param update defines whether texture is immediately update (default is true)
  48304. */
  48305. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48306. /**
  48307. * Clones the texture
  48308. * @returns the clone of the texture.
  48309. */
  48310. clone(): DynamicTexture;
  48311. /**
  48312. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48313. * @returns a serialized dynamic texture object
  48314. */
  48315. serialize(): any;
  48316. private _IsCanvasElement;
  48317. /** @hidden */
  48318. _rebuild(): void;
  48319. }
  48320. }
  48321. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48322. import { Scene } from "babylonjs/scene";
  48323. import { Color3 } from "babylonjs/Maths/math.color";
  48324. import { Mesh } from "babylonjs/Meshes/mesh";
  48325. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48326. import { Nullable } from "babylonjs/types";
  48327. /**
  48328. * Class containing static functions to help procedurally build meshes
  48329. */
  48330. export class GroundBuilder {
  48331. /**
  48332. * Creates a ground mesh
  48333. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48334. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48336. * @param name defines the name of the mesh
  48337. * @param options defines the options used to create the mesh
  48338. * @param scene defines the hosting scene
  48339. * @returns the ground mesh
  48340. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48341. */
  48342. static CreateGround(name: string, options: {
  48343. width?: number;
  48344. height?: number;
  48345. subdivisions?: number;
  48346. subdivisionsX?: number;
  48347. subdivisionsY?: number;
  48348. updatable?: boolean;
  48349. }, scene: any): Mesh;
  48350. /**
  48351. * Creates a tiled ground mesh
  48352. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48353. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48354. * * 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
  48355. * * 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
  48356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48357. * @param name defines the name of the mesh
  48358. * @param options defines the options used to create the mesh
  48359. * @param scene defines the hosting scene
  48360. * @returns the tiled ground mesh
  48361. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48362. */
  48363. static CreateTiledGround(name: string, options: {
  48364. xmin: number;
  48365. zmin: number;
  48366. xmax: number;
  48367. zmax: number;
  48368. subdivisions?: {
  48369. w: number;
  48370. h: number;
  48371. };
  48372. precision?: {
  48373. w: number;
  48374. h: number;
  48375. };
  48376. updatable?: boolean;
  48377. }, scene?: Nullable<Scene>): Mesh;
  48378. /**
  48379. * Creates a ground mesh from a height map
  48380. * * The parameter `url` sets the URL of the height map image resource.
  48381. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48382. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48383. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48384. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48385. * * 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.
  48386. * * 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).
  48387. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48389. * @param name defines the name of the mesh
  48390. * @param url defines the url to the height map
  48391. * @param options defines the options used to create the mesh
  48392. * @param scene defines the hosting scene
  48393. * @returns the ground mesh
  48394. * @see https://doc.babylonjs.com/babylon101/height_map
  48395. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48396. */
  48397. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48398. width?: number;
  48399. height?: number;
  48400. subdivisions?: number;
  48401. minHeight?: number;
  48402. maxHeight?: number;
  48403. colorFilter?: Color3;
  48404. alphaFilter?: number;
  48405. updatable?: boolean;
  48406. onReady?: (mesh: GroundMesh) => void;
  48407. }, scene?: Nullable<Scene>): GroundMesh;
  48408. }
  48409. }
  48410. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48411. import { Vector4 } from "babylonjs/Maths/math.vector";
  48412. import { Mesh } from "babylonjs/Meshes/mesh";
  48413. /**
  48414. * Class containing static functions to help procedurally build meshes
  48415. */
  48416. export class TorusBuilder {
  48417. /**
  48418. * Creates a torus mesh
  48419. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48420. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48421. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48425. * @param name defines the name of the mesh
  48426. * @param options defines the options used to create the mesh
  48427. * @param scene defines the hosting scene
  48428. * @returns the torus mesh
  48429. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48430. */
  48431. static CreateTorus(name: string, options: {
  48432. diameter?: number;
  48433. thickness?: number;
  48434. tessellation?: number;
  48435. updatable?: boolean;
  48436. sideOrientation?: number;
  48437. frontUVs?: Vector4;
  48438. backUVs?: Vector4;
  48439. }, scene: any): Mesh;
  48440. }
  48441. }
  48442. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48443. import { Vector4 } from "babylonjs/Maths/math.vector";
  48444. import { Color4 } from "babylonjs/Maths/math.color";
  48445. import { Mesh } from "babylonjs/Meshes/mesh";
  48446. /**
  48447. * Class containing static functions to help procedurally build meshes
  48448. */
  48449. export class CylinderBuilder {
  48450. /**
  48451. * Creates a cylinder or a cone mesh
  48452. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48453. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48454. * * 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.
  48455. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48456. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48457. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48458. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48459. * * 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).
  48460. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48461. * * 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).
  48462. * * 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
  48463. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48464. * * 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
  48465. * * 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.
  48466. * * If `enclose` is false, a ring surface is one element.
  48467. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48468. * * 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
  48469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48470. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48472. * @param name defines the name of the mesh
  48473. * @param options defines the options used to create the mesh
  48474. * @param scene defines the hosting scene
  48475. * @returns the cylinder mesh
  48476. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48477. */
  48478. static CreateCylinder(name: string, options: {
  48479. height?: number;
  48480. diameterTop?: number;
  48481. diameterBottom?: number;
  48482. diameter?: number;
  48483. tessellation?: number;
  48484. subdivisions?: number;
  48485. arc?: number;
  48486. faceColors?: Color4[];
  48487. faceUV?: Vector4[];
  48488. updatable?: boolean;
  48489. hasRings?: boolean;
  48490. enclose?: boolean;
  48491. cap?: number;
  48492. sideOrientation?: number;
  48493. frontUVs?: Vector4;
  48494. backUVs?: Vector4;
  48495. }, scene: any): Mesh;
  48496. }
  48497. }
  48498. declare module "babylonjs/XR/webXRTypes" {
  48499. import { Nullable } from "babylonjs/types";
  48500. import { IDisposable } from "babylonjs/scene";
  48501. /**
  48502. * States of the webXR experience
  48503. */
  48504. export enum WebXRState {
  48505. /**
  48506. * Transitioning to being in XR mode
  48507. */
  48508. ENTERING_XR = 0,
  48509. /**
  48510. * Transitioning to non XR mode
  48511. */
  48512. EXITING_XR = 1,
  48513. /**
  48514. * In XR mode and presenting
  48515. */
  48516. IN_XR = 2,
  48517. /**
  48518. * Not entered XR mode
  48519. */
  48520. NOT_IN_XR = 3
  48521. }
  48522. /**
  48523. * Abstraction of the XR render target
  48524. */
  48525. export interface WebXRRenderTarget extends IDisposable {
  48526. /**
  48527. * xrpresent context of the canvas which can be used to display/mirror xr content
  48528. */
  48529. canvasContext: WebGLRenderingContext;
  48530. /**
  48531. * xr layer for the canvas
  48532. */
  48533. xrLayer: Nullable<XRWebGLLayer>;
  48534. /**
  48535. * Initializes the xr layer for the session
  48536. * @param xrSession xr session
  48537. * @returns a promise that will resolve once the XR Layer has been created
  48538. */
  48539. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48540. }
  48541. }
  48542. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48543. import { Nullable } from "babylonjs/types";
  48544. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  48545. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48546. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48547. import { Observable } from "babylonjs/Misc/observable";
  48548. /**
  48549. * COnfiguration object for WebXR output canvas
  48550. */
  48551. export class WebXRManagedOutputCanvasOptions {
  48552. /**
  48553. * An optional canvas in case you wish to create it yourself and provide it here.
  48554. * If not provided, a new canvas will be created
  48555. */
  48556. canvasElement?: HTMLCanvasElement;
  48557. /**
  48558. * Options for this XR Layer output
  48559. */
  48560. canvasOptions?: XRWebGLLayerOptions;
  48561. /**
  48562. * CSS styling for a newly created canvas (if not provided)
  48563. */
  48564. newCanvasCssStyle?: string;
  48565. /**
  48566. * Get the default values of the configuration object
  48567. * @param engine defines the engine to use (can be null)
  48568. * @returns default values of this configuration object
  48569. */
  48570. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  48571. }
  48572. /**
  48573. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48574. */
  48575. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48576. private _options;
  48577. private _canvas;
  48578. private _engine;
  48579. private _originalCanvasSize;
  48580. /**
  48581. * Rendering context of the canvas which can be used to display/mirror xr content
  48582. */
  48583. canvasContext: WebGLRenderingContext;
  48584. /**
  48585. * xr layer for the canvas
  48586. */
  48587. xrLayer: Nullable<XRWebGLLayer>;
  48588. /**
  48589. * Obseervers registered here will be triggered when the xr layer was initialized
  48590. */
  48591. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48592. /**
  48593. * Initializes the canvas to be added/removed upon entering/exiting xr
  48594. * @param _xrSessionManager The XR Session manager
  48595. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48596. */
  48597. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48598. /**
  48599. * Disposes of the object
  48600. */
  48601. dispose(): void;
  48602. /**
  48603. * Initializes the xr layer for the session
  48604. * @param xrSession xr session
  48605. * @returns a promise that will resolve once the XR Layer has been created
  48606. */
  48607. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48608. private _addCanvas;
  48609. private _removeCanvas;
  48610. private _setCanvasSize;
  48611. private _setManagedOutputCanvas;
  48612. }
  48613. }
  48614. declare module "babylonjs/XR/webXRSessionManager" {
  48615. import { Observable } from "babylonjs/Misc/observable";
  48616. import { Nullable } from "babylonjs/types";
  48617. import { IDisposable, Scene } from "babylonjs/scene";
  48618. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48619. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48620. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48621. /**
  48622. * Manages an XRSession to work with Babylon's engine
  48623. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48624. */
  48625. export class WebXRSessionManager implements IDisposable {
  48626. /** The scene which the session should be created for */
  48627. scene: Scene;
  48628. private _referenceSpace;
  48629. private _rttProvider;
  48630. private _sessionEnded;
  48631. private _xrNavigator;
  48632. private baseLayer;
  48633. /**
  48634. * The base reference space from which the session started. good if you want to reset your
  48635. * reference space
  48636. */
  48637. baseReferenceSpace: XRReferenceSpace;
  48638. /**
  48639. * Current XR frame
  48640. */
  48641. currentFrame: Nullable<XRFrame>;
  48642. /** WebXR timestamp updated every frame */
  48643. currentTimestamp: number;
  48644. /**
  48645. * Used just in case of a failure to initialize an immersive session.
  48646. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48647. */
  48648. defaultHeightCompensation: number;
  48649. /**
  48650. * Fires every time a new xrFrame arrives which can be used to update the camera
  48651. */
  48652. onXRFrameObservable: Observable<XRFrame>;
  48653. /**
  48654. * Fires when the reference space changed
  48655. */
  48656. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48657. /**
  48658. * Fires when the xr session is ended either by the device or manually done
  48659. */
  48660. onXRSessionEnded: Observable<any>;
  48661. /**
  48662. * Fires when the xr session is ended either by the device or manually done
  48663. */
  48664. onXRSessionInit: Observable<XRSession>;
  48665. /**
  48666. * Underlying xr session
  48667. */
  48668. session: XRSession;
  48669. /**
  48670. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48671. * or get the offset the player is currently at.
  48672. */
  48673. viewerReferenceSpace: XRReferenceSpace;
  48674. /**
  48675. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48676. * @param scene The scene which the session should be created for
  48677. */
  48678. constructor(
  48679. /** The scene which the session should be created for */
  48680. scene: Scene);
  48681. /**
  48682. * The current reference space used in this session. This reference space can constantly change!
  48683. * It is mainly used to offset the camera's position.
  48684. */
  48685. get referenceSpace(): XRReferenceSpace;
  48686. /**
  48687. * Set a new reference space and triggers the observable
  48688. */
  48689. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48690. /**
  48691. * Disposes of the session manager
  48692. */
  48693. dispose(): void;
  48694. /**
  48695. * Stops the xrSession and restores the render loop
  48696. * @returns Promise which resolves after it exits XR
  48697. */
  48698. exitXRAsync(): Promise<void>;
  48699. /**
  48700. * Gets the correct render target texture to be rendered this frame for this eye
  48701. * @param eye the eye for which to get the render target
  48702. * @returns the render target for the specified eye
  48703. */
  48704. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48705. /**
  48706. * Creates a WebXRRenderTarget object for the XR session
  48707. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48708. * @param options optional options to provide when creating a new render target
  48709. * @returns a WebXR render target to which the session can render
  48710. */
  48711. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48712. /**
  48713. * Initializes the manager
  48714. * After initialization enterXR can be called to start an XR session
  48715. * @returns Promise which resolves after it is initialized
  48716. */
  48717. initializeAsync(): Promise<void>;
  48718. /**
  48719. * Initializes an xr session
  48720. * @param xrSessionMode mode to initialize
  48721. * @param xrSessionInit defines optional and required values to pass to the session builder
  48722. * @returns a promise which will resolve once the session has been initialized
  48723. */
  48724. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48725. /**
  48726. * Checks if a session would be supported for the creation options specified
  48727. * @param sessionMode session mode to check if supported eg. immersive-vr
  48728. * @returns A Promise that resolves to true if supported and false if not
  48729. */
  48730. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48731. /**
  48732. * Resets the reference space to the one started the session
  48733. */
  48734. resetReferenceSpace(): void;
  48735. /**
  48736. * Starts rendering to the xr layer
  48737. */
  48738. runXRRenderLoop(): void;
  48739. /**
  48740. * Sets the reference space on the xr session
  48741. * @param referenceSpaceType space to set
  48742. * @returns a promise that will resolve once the reference space has been set
  48743. */
  48744. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48745. /**
  48746. * Updates the render state of the session
  48747. * @param state state to set
  48748. * @returns a promise that resolves once the render state has been updated
  48749. */
  48750. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48751. /**
  48752. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48753. * @param sessionMode defines the session to test
  48754. * @returns a promise with boolean as final value
  48755. */
  48756. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48757. private _createRenderTargetTexture;
  48758. }
  48759. }
  48760. declare module "babylonjs/XR/webXRCamera" {
  48761. import { Vector3 } from "babylonjs/Maths/math.vector";
  48762. import { Scene } from "babylonjs/scene";
  48763. import { Camera } from "babylonjs/Cameras/camera";
  48764. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48765. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48766. import { Observable } from "babylonjs/Misc/observable";
  48767. /**
  48768. * WebXR Camera which holds the views for the xrSession
  48769. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48770. */
  48771. export class WebXRCamera extends FreeCamera {
  48772. private _xrSessionManager;
  48773. private _firstFrame;
  48774. private _referenceQuaternion;
  48775. private _referencedPosition;
  48776. private _xrInvPositionCache;
  48777. private _xrInvQuaternionCache;
  48778. /**
  48779. * Observable raised before camera teleportation
  48780. */
  48781. onBeforeCameraTeleport: Observable<Vector3>;
  48782. /**
  48783. * Observable raised after camera teleportation
  48784. */
  48785. onAfterCameraTeleport: Observable<Vector3>;
  48786. /**
  48787. * Should position compensation execute on first frame.
  48788. * This is used when copying the position from a native (non XR) camera
  48789. */
  48790. compensateOnFirstFrame: boolean;
  48791. /**
  48792. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48793. * @param name the name of the camera
  48794. * @param scene the scene to add the camera to
  48795. * @param _xrSessionManager a constructed xr session manager
  48796. */
  48797. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48798. /**
  48799. * Return the user's height, unrelated to the current ground.
  48800. * This will be the y position of this camera, when ground level is 0.
  48801. */
  48802. get realWorldHeight(): number;
  48803. /** @hidden */
  48804. _updateForDualEyeDebugging(): void;
  48805. /**
  48806. * Sets this camera's transformation based on a non-vr camera
  48807. * @param otherCamera the non-vr camera to copy the transformation from
  48808. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48809. */
  48810. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48811. /**
  48812. * Gets the current instance class name ("WebXRCamera").
  48813. * @returns the class name
  48814. */
  48815. getClassName(): string;
  48816. private _rotate180;
  48817. private _updateFromXRSession;
  48818. private _updateNumberOfRigCameras;
  48819. private _updateReferenceSpace;
  48820. private _updateReferenceSpaceOffset;
  48821. }
  48822. }
  48823. declare module "babylonjs/XR/webXRFeaturesManager" {
  48824. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48825. import { IDisposable } from "babylonjs/scene";
  48826. /**
  48827. * Defining the interface required for a (webxr) feature
  48828. */
  48829. export interface IWebXRFeature extends IDisposable {
  48830. /**
  48831. * Is this feature attached
  48832. */
  48833. attached: boolean;
  48834. /**
  48835. * Should auto-attach be disabled?
  48836. */
  48837. disableAutoAttach: boolean;
  48838. /**
  48839. * Attach the feature to the session
  48840. * Will usually be called by the features manager
  48841. *
  48842. * @param force should attachment be forced (even when already attached)
  48843. * @returns true if successful.
  48844. */
  48845. attach(force?: boolean): boolean;
  48846. /**
  48847. * Detach the feature from the session
  48848. * Will usually be called by the features manager
  48849. *
  48850. * @returns true if successful.
  48851. */
  48852. detach(): boolean;
  48853. /**
  48854. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48855. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48856. *
  48857. * @returns whether or not the feature is compatible in this environment
  48858. */
  48859. isCompatible(): boolean;
  48860. /**
  48861. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  48862. */
  48863. xrNativeFeatureName?: string;
  48864. /**
  48865. * A list of (Babylon WebXR) features this feature depends on
  48866. */
  48867. dependsOn?: string[];
  48868. }
  48869. /**
  48870. * A list of the currently available features without referencing them
  48871. */
  48872. export class WebXRFeatureName {
  48873. /**
  48874. * The name of the anchor system feature
  48875. */
  48876. static readonly ANCHOR_SYSTEM: string;
  48877. /**
  48878. * The name of the background remover feature
  48879. */
  48880. static readonly BACKGROUND_REMOVER: string;
  48881. /**
  48882. * The name of the hit test feature
  48883. */
  48884. static readonly HIT_TEST: string;
  48885. /**
  48886. * physics impostors for xr controllers feature
  48887. */
  48888. static readonly PHYSICS_CONTROLLERS: string;
  48889. /**
  48890. * The name of the plane detection feature
  48891. */
  48892. static readonly PLANE_DETECTION: string;
  48893. /**
  48894. * The name of the pointer selection feature
  48895. */
  48896. static readonly POINTER_SELECTION: string;
  48897. /**
  48898. * The name of the teleportation feature
  48899. */
  48900. static readonly TELEPORTATION: string;
  48901. /**
  48902. * The name of the feature points feature.
  48903. */
  48904. static readonly FEATURE_POINTS: string;
  48905. /**
  48906. * The name of the hand tracking feature.
  48907. */
  48908. static readonly HAND_TRACKING: string;
  48909. }
  48910. /**
  48911. * Defining the constructor of a feature. Used to register the modules.
  48912. */
  48913. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  48914. /**
  48915. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48916. * It is mainly used in AR sessions.
  48917. *
  48918. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48919. */
  48920. export class WebXRFeaturesManager implements IDisposable {
  48921. private _xrSessionManager;
  48922. private static readonly _AvailableFeatures;
  48923. private _features;
  48924. /**
  48925. * constructs a new features manages.
  48926. *
  48927. * @param _xrSessionManager an instance of WebXRSessionManager
  48928. */
  48929. constructor(_xrSessionManager: WebXRSessionManager);
  48930. /**
  48931. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48932. * Mainly used internally.
  48933. *
  48934. * @param featureName the name of the feature to register
  48935. * @param constructorFunction the function used to construct the module
  48936. * @param version the (babylon) version of the module
  48937. * @param stable is that a stable version of this module
  48938. */
  48939. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48940. /**
  48941. * Returns a constructor of a specific feature.
  48942. *
  48943. * @param featureName the name of the feature to construct
  48944. * @param version the version of the feature to load
  48945. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48946. * @param options optional options provided to the module.
  48947. * @returns a function that, when called, will return a new instance of this feature
  48948. */
  48949. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  48950. /**
  48951. * Can be used to return the list of features currently registered
  48952. *
  48953. * @returns an Array of available features
  48954. */
  48955. static GetAvailableFeatures(): string[];
  48956. /**
  48957. * Gets the versions available for a specific feature
  48958. * @param featureName the name of the feature
  48959. * @returns an array with the available versions
  48960. */
  48961. static GetAvailableVersions(featureName: string): string[];
  48962. /**
  48963. * Return the latest unstable version of this feature
  48964. * @param featureName the name of the feature to search
  48965. * @returns the version number. if not found will return -1
  48966. */
  48967. static GetLatestVersionOfFeature(featureName: string): number;
  48968. /**
  48969. * Return the latest stable version of this feature
  48970. * @param featureName the name of the feature to search
  48971. * @returns the version number. if not found will return -1
  48972. */
  48973. static GetStableVersionOfFeature(featureName: string): number;
  48974. /**
  48975. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  48976. * Can be used during a session to start a feature
  48977. * @param featureName the name of feature to attach
  48978. */
  48979. attachFeature(featureName: string): void;
  48980. /**
  48981. * Can be used inside a session or when the session ends to detach a specific feature
  48982. * @param featureName the name of the feature to detach
  48983. */
  48984. detachFeature(featureName: string): void;
  48985. /**
  48986. * Used to disable an already-enabled feature
  48987. * The feature will be disposed and will be recreated once enabled.
  48988. * @param featureName the feature to disable
  48989. * @returns true if disable was successful
  48990. */
  48991. disableFeature(featureName: string | {
  48992. Name: string;
  48993. }): boolean;
  48994. /**
  48995. * dispose this features manager
  48996. */
  48997. dispose(): void;
  48998. /**
  48999. * 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.
  49000. * 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.
  49001. *
  49002. * @param featureName the name of the feature to load or the class of the feature
  49003. * @param version optional version to load. if not provided the latest version will be enabled
  49004. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  49005. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  49006. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  49007. * @returns a new constructed feature or throws an error if feature not found.
  49008. */
  49009. enableFeature(featureName: string | {
  49010. Name: string;
  49011. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  49012. /**
  49013. * get the implementation of an enabled feature.
  49014. * @param featureName the name of the feature to load
  49015. * @returns the feature class, if found
  49016. */
  49017. getEnabledFeature(featureName: string): IWebXRFeature;
  49018. /**
  49019. * Get the list of enabled features
  49020. * @returns an array of enabled features
  49021. */
  49022. getEnabledFeatures(): string[];
  49023. /**
  49024. * This function will exten the session creation configuration object with enabled features.
  49025. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  49026. * according to the defined "required" variable, provided during enableFeature call
  49027. * @param xrSessionInit the xr Session init object to extend
  49028. *
  49029. * @returns an extended XRSessionInit object
  49030. */
  49031. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  49032. }
  49033. }
  49034. declare module "babylonjs/XR/webXRExperienceHelper" {
  49035. import { Observable } from "babylonjs/Misc/observable";
  49036. import { IDisposable, Scene } from "babylonjs/scene";
  49037. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49038. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49039. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49040. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49041. /**
  49042. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49043. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49044. */
  49045. export class WebXRExperienceHelper implements IDisposable {
  49046. private scene;
  49047. private _nonVRCamera;
  49048. private _originalSceneAutoClear;
  49049. private _supported;
  49050. /**
  49051. * Camera used to render xr content
  49052. */
  49053. camera: WebXRCamera;
  49054. /** A features manager for this xr session */
  49055. featuresManager: WebXRFeaturesManager;
  49056. /**
  49057. * Observers registered here will be triggered after the camera's initial transformation is set
  49058. * This can be used to set a different ground level or an extra rotation.
  49059. *
  49060. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49061. * to the position set after this observable is done executing.
  49062. */
  49063. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49064. /**
  49065. * Fires when the state of the experience helper has changed
  49066. */
  49067. onStateChangedObservable: Observable<WebXRState>;
  49068. /** Session manager used to keep track of xr session */
  49069. sessionManager: WebXRSessionManager;
  49070. /**
  49071. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49072. */
  49073. state: WebXRState;
  49074. /**
  49075. * Creates a WebXRExperienceHelper
  49076. * @param scene The scene the helper should be created in
  49077. */
  49078. private constructor();
  49079. /**
  49080. * Creates the experience helper
  49081. * @param scene the scene to attach the experience helper to
  49082. * @returns a promise for the experience helper
  49083. */
  49084. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49085. /**
  49086. * Disposes of the experience helper
  49087. */
  49088. dispose(): void;
  49089. /**
  49090. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49091. * @param sessionMode options for the XR session
  49092. * @param referenceSpaceType frame of reference of the XR session
  49093. * @param renderTarget the output canvas that will be used to enter XR mode
  49094. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49095. * @returns promise that resolves after xr mode has entered
  49096. */
  49097. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49098. /**
  49099. * Exits XR mode and returns the scene to its original state
  49100. * @returns promise that resolves after xr mode has exited
  49101. */
  49102. exitXRAsync(): Promise<void>;
  49103. private _nonXRToXRCamera;
  49104. private _setState;
  49105. }
  49106. }
  49107. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49108. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49109. import { Observable } from "babylonjs/Misc/observable";
  49110. import { IDisposable } from "babylonjs/scene";
  49111. /**
  49112. * X-Y values for axes in WebXR
  49113. */
  49114. export interface IWebXRMotionControllerAxesValue {
  49115. /**
  49116. * The value of the x axis
  49117. */
  49118. x: number;
  49119. /**
  49120. * The value of the y-axis
  49121. */
  49122. y: number;
  49123. }
  49124. /**
  49125. * changed / previous values for the values of this component
  49126. */
  49127. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49128. /**
  49129. * current (this frame) value
  49130. */
  49131. current: T;
  49132. /**
  49133. * previous (last change) value
  49134. */
  49135. previous: T;
  49136. }
  49137. /**
  49138. * Represents changes in the component between current frame and last values recorded
  49139. */
  49140. export interface IWebXRMotionControllerComponentChanges {
  49141. /**
  49142. * will be populated with previous and current values if axes changed
  49143. */
  49144. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49145. /**
  49146. * will be populated with previous and current values if pressed changed
  49147. */
  49148. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49149. /**
  49150. * will be populated with previous and current values if touched changed
  49151. */
  49152. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49153. /**
  49154. * will be populated with previous and current values if value changed
  49155. */
  49156. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49157. }
  49158. /**
  49159. * This class represents a single component (for example button or thumbstick) of a motion controller
  49160. */
  49161. export class WebXRControllerComponent implements IDisposable {
  49162. /**
  49163. * the id of this component
  49164. */
  49165. id: string;
  49166. /**
  49167. * the type of the component
  49168. */
  49169. type: MotionControllerComponentType;
  49170. private _buttonIndex;
  49171. private _axesIndices;
  49172. private _axes;
  49173. private _changes;
  49174. private _currentValue;
  49175. private _hasChanges;
  49176. private _pressed;
  49177. private _touched;
  49178. /**
  49179. * button component type
  49180. */
  49181. static BUTTON_TYPE: MotionControllerComponentType;
  49182. /**
  49183. * squeeze component type
  49184. */
  49185. static SQUEEZE_TYPE: MotionControllerComponentType;
  49186. /**
  49187. * Thumbstick component type
  49188. */
  49189. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49190. /**
  49191. * Touchpad component type
  49192. */
  49193. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49194. /**
  49195. * trigger component type
  49196. */
  49197. static TRIGGER_TYPE: MotionControllerComponentType;
  49198. /**
  49199. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49200. * the axes data changes
  49201. */
  49202. onAxisValueChangedObservable: Observable<{
  49203. x: number;
  49204. y: number;
  49205. }>;
  49206. /**
  49207. * Observers registered here will be triggered when the state of a button changes
  49208. * State change is either pressed / touched / value
  49209. */
  49210. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49211. /**
  49212. * Creates a new component for a motion controller.
  49213. * It is created by the motion controller itself
  49214. *
  49215. * @param id the id of this component
  49216. * @param type the type of the component
  49217. * @param _buttonIndex index in the buttons array of the gamepad
  49218. * @param _axesIndices indices of the values in the axes array of the gamepad
  49219. */
  49220. constructor(
  49221. /**
  49222. * the id of this component
  49223. */
  49224. id: string,
  49225. /**
  49226. * the type of the component
  49227. */
  49228. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49229. /**
  49230. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49231. */
  49232. get axes(): IWebXRMotionControllerAxesValue;
  49233. /**
  49234. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49235. */
  49236. get changes(): IWebXRMotionControllerComponentChanges;
  49237. /**
  49238. * Return whether or not the component changed the last frame
  49239. */
  49240. get hasChanges(): boolean;
  49241. /**
  49242. * is the button currently pressed
  49243. */
  49244. get pressed(): boolean;
  49245. /**
  49246. * is the button currently touched
  49247. */
  49248. get touched(): boolean;
  49249. /**
  49250. * Get the current value of this component
  49251. */
  49252. get value(): number;
  49253. /**
  49254. * Dispose this component
  49255. */
  49256. dispose(): void;
  49257. /**
  49258. * Are there axes correlating to this component
  49259. * @return true is axes data is available
  49260. */
  49261. isAxes(): boolean;
  49262. /**
  49263. * Is this component a button (hence - pressable)
  49264. * @returns true if can be pressed
  49265. */
  49266. isButton(): boolean;
  49267. /**
  49268. * update this component using the gamepad object it is in. Called on every frame
  49269. * @param nativeController the native gamepad controller object
  49270. */
  49271. update(nativeController: IMinimalMotionControllerObject): void;
  49272. }
  49273. }
  49274. declare module "babylonjs/Loading/sceneLoader" {
  49275. import { Observable } from "babylonjs/Misc/observable";
  49276. import { Nullable } from "babylonjs/types";
  49277. import { Scene } from "babylonjs/scene";
  49278. import { Engine } from "babylonjs/Engines/engine";
  49279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49280. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49281. import { AssetContainer } from "babylonjs/assetContainer";
  49282. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49283. import { Skeleton } from "babylonjs/Bones/skeleton";
  49284. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49285. import { WebRequest } from "babylonjs/Misc/webRequest";
  49286. /**
  49287. * Interface used to represent data loading progression
  49288. */
  49289. export interface ISceneLoaderProgressEvent {
  49290. /**
  49291. * Defines if data length to load can be evaluated
  49292. */
  49293. readonly lengthComputable: boolean;
  49294. /**
  49295. * Defines the loaded data length
  49296. */
  49297. readonly loaded: number;
  49298. /**
  49299. * Defines the data length to load
  49300. */
  49301. readonly total: number;
  49302. }
  49303. /**
  49304. * Interface used by SceneLoader plugins to define supported file extensions
  49305. */
  49306. export interface ISceneLoaderPluginExtensions {
  49307. /**
  49308. * Defines the list of supported extensions
  49309. */
  49310. [extension: string]: {
  49311. isBinary: boolean;
  49312. };
  49313. }
  49314. /**
  49315. * Interface used by SceneLoader plugin factory
  49316. */
  49317. export interface ISceneLoaderPluginFactory {
  49318. /**
  49319. * Defines the name of the factory
  49320. */
  49321. name: string;
  49322. /**
  49323. * Function called to create a new plugin
  49324. * @return the new plugin
  49325. */
  49326. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49327. /**
  49328. * The callback that returns true if the data can be directly loaded.
  49329. * @param data string containing the file data
  49330. * @returns if the data can be loaded directly
  49331. */
  49332. canDirectLoad?(data: string): boolean;
  49333. }
  49334. /**
  49335. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49336. */
  49337. export interface ISceneLoaderPluginBase {
  49338. /**
  49339. * The friendly name of this plugin.
  49340. */
  49341. name: string;
  49342. /**
  49343. * The file extensions supported by this plugin.
  49344. */
  49345. extensions: string | ISceneLoaderPluginExtensions;
  49346. /**
  49347. * The callback called when loading from a url.
  49348. * @param scene scene loading this url
  49349. * @param url url to load
  49350. * @param onSuccess callback called when the file successfully loads
  49351. * @param onProgress callback called while file is loading (if the server supports this mode)
  49352. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49353. * @param onError callback called when the file fails to load
  49354. * @returns a file request object
  49355. */
  49356. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49357. /**
  49358. * The callback called when loading from a file object.
  49359. * @param scene scene loading this file
  49360. * @param file defines the file to load
  49361. * @param onSuccess defines the callback to call when data is loaded
  49362. * @param onProgress defines the callback to call during loading process
  49363. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49364. * @param onError defines the callback to call when an error occurs
  49365. * @returns a file request object
  49366. */
  49367. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49368. /**
  49369. * The callback that returns true if the data can be directly loaded.
  49370. * @param data string containing the file data
  49371. * @returns if the data can be loaded directly
  49372. */
  49373. canDirectLoad?(data: string): boolean;
  49374. /**
  49375. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49376. * @param scene scene loading this data
  49377. * @param data string containing the data
  49378. * @returns data to pass to the plugin
  49379. */
  49380. directLoad?(scene: Scene, data: string): any;
  49381. /**
  49382. * The callback that allows custom handling of the root url based on the response url.
  49383. * @param rootUrl the original root url
  49384. * @param responseURL the response url if available
  49385. * @returns the new root url
  49386. */
  49387. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49388. }
  49389. /**
  49390. * Interface used to define a SceneLoader plugin
  49391. */
  49392. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49393. /**
  49394. * Import meshes into a scene.
  49395. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49396. * @param scene The scene to import into
  49397. * @param data The data to import
  49398. * @param rootUrl The root url for scene and resources
  49399. * @param meshes The meshes array to import into
  49400. * @param particleSystems The particle systems array to import into
  49401. * @param skeletons The skeletons array to import into
  49402. * @param onError The callback when import fails
  49403. * @returns True if successful or false otherwise
  49404. */
  49405. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49406. /**
  49407. * Load into a scene.
  49408. * @param scene The scene to load into
  49409. * @param data The data to import
  49410. * @param rootUrl The root url for scene and resources
  49411. * @param onError The callback when import fails
  49412. * @returns True if successful or false otherwise
  49413. */
  49414. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49415. /**
  49416. * Load into an asset container.
  49417. * @param scene The scene to load into
  49418. * @param data The data to import
  49419. * @param rootUrl The root url for scene and resources
  49420. * @param onError The callback when import fails
  49421. * @returns The loaded asset container
  49422. */
  49423. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49424. }
  49425. /**
  49426. * Interface used to define an async SceneLoader plugin
  49427. */
  49428. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49429. /**
  49430. * Import meshes into a scene.
  49431. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49432. * @param scene The scene to import into
  49433. * @param data The data to import
  49434. * @param rootUrl The root url for scene and resources
  49435. * @param onProgress The callback when the load progresses
  49436. * @param fileName Defines the name of the file to load
  49437. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49438. */
  49439. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49440. meshes: AbstractMesh[];
  49441. particleSystems: IParticleSystem[];
  49442. skeletons: Skeleton[];
  49443. animationGroups: AnimationGroup[];
  49444. }>;
  49445. /**
  49446. * Load into a scene.
  49447. * @param scene The scene to load into
  49448. * @param data The data to import
  49449. * @param rootUrl The root url for scene and resources
  49450. * @param onProgress The callback when the load progresses
  49451. * @param fileName Defines the name of the file to load
  49452. * @returns Nothing
  49453. */
  49454. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49455. /**
  49456. * Load into an asset container.
  49457. * @param scene The scene to load into
  49458. * @param data The data to import
  49459. * @param rootUrl The root url for scene and resources
  49460. * @param onProgress The callback when the load progresses
  49461. * @param fileName Defines the name of the file to load
  49462. * @returns The loaded asset container
  49463. */
  49464. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49465. }
  49466. /**
  49467. * Mode that determines how to handle old animation groups before loading new ones.
  49468. */
  49469. export enum SceneLoaderAnimationGroupLoadingMode {
  49470. /**
  49471. * Reset all old animations to initial state then dispose them.
  49472. */
  49473. Clean = 0,
  49474. /**
  49475. * Stop all old animations.
  49476. */
  49477. Stop = 1,
  49478. /**
  49479. * Restart old animations from first frame.
  49480. */
  49481. Sync = 2,
  49482. /**
  49483. * Old animations remains untouched.
  49484. */
  49485. NoSync = 3
  49486. }
  49487. /**
  49488. * Defines a plugin registered by the SceneLoader
  49489. */
  49490. interface IRegisteredPlugin {
  49491. /**
  49492. * Defines the plugin to use
  49493. */
  49494. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49495. /**
  49496. * Defines if the plugin supports binary data
  49497. */
  49498. isBinary: boolean;
  49499. }
  49500. /**
  49501. * Class used to load scene from various file formats using registered plugins
  49502. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49503. */
  49504. export class SceneLoader {
  49505. /**
  49506. * No logging while loading
  49507. */
  49508. static readonly NO_LOGGING: number;
  49509. /**
  49510. * Minimal logging while loading
  49511. */
  49512. static readonly MINIMAL_LOGGING: number;
  49513. /**
  49514. * Summary logging while loading
  49515. */
  49516. static readonly SUMMARY_LOGGING: number;
  49517. /**
  49518. * Detailled logging while loading
  49519. */
  49520. static readonly DETAILED_LOGGING: number;
  49521. /**
  49522. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49523. */
  49524. static get ForceFullSceneLoadingForIncremental(): boolean;
  49525. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49526. /**
  49527. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49528. */
  49529. static get ShowLoadingScreen(): boolean;
  49530. static set ShowLoadingScreen(value: boolean);
  49531. /**
  49532. * Defines the current logging level (while loading the scene)
  49533. * @ignorenaming
  49534. */
  49535. static get loggingLevel(): number;
  49536. static set loggingLevel(value: number);
  49537. /**
  49538. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49539. */
  49540. static get CleanBoneMatrixWeights(): boolean;
  49541. static set CleanBoneMatrixWeights(value: boolean);
  49542. /**
  49543. * Event raised when a plugin is used to load a scene
  49544. */
  49545. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49546. private static _registeredPlugins;
  49547. private static _showingLoadingScreen;
  49548. /**
  49549. * Gets the default plugin (used to load Babylon files)
  49550. * @returns the .babylon plugin
  49551. */
  49552. static GetDefaultPlugin(): IRegisteredPlugin;
  49553. private static _GetPluginForExtension;
  49554. private static _GetPluginForDirectLoad;
  49555. private static _GetPluginForFilename;
  49556. private static _GetDirectLoad;
  49557. private static _LoadData;
  49558. private static _GetFileInfo;
  49559. /**
  49560. * Gets a plugin that can load the given extension
  49561. * @param extension defines the extension to load
  49562. * @returns a plugin or null if none works
  49563. */
  49564. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49565. /**
  49566. * Gets a boolean indicating that the given extension can be loaded
  49567. * @param extension defines the extension to load
  49568. * @returns true if the extension is supported
  49569. */
  49570. static IsPluginForExtensionAvailable(extension: string): boolean;
  49571. /**
  49572. * Adds a new plugin to the list of registered plugins
  49573. * @param plugin defines the plugin to add
  49574. */
  49575. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49576. /**
  49577. * Import meshes into a scene
  49578. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49579. * @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)
  49580. * @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)
  49581. * @param scene the instance of BABYLON.Scene to append to
  49582. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49583. * @param onProgress a callback with a progress event for each file being loaded
  49584. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49585. * @param pluginExtension the extension used to determine the plugin
  49586. * @returns The loaded plugin
  49587. */
  49588. 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>;
  49589. /**
  49590. * Import meshes into a scene
  49591. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  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 scene the instance of BABYLON.Scene to append to
  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 list of imported meshes, particle systems, skeletons, and animation groups
  49598. */
  49599. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49600. meshes: AbstractMesh[];
  49601. particleSystems: IParticleSystem[];
  49602. skeletons: Skeleton[];
  49603. animationGroups: AnimationGroup[];
  49604. }>;
  49605. /**
  49606. * Load a scene
  49607. * @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)
  49608. * @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)
  49609. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49610. * @param onSuccess a callback with the scene when import succeeds
  49611. * @param onProgress a callback with a progress event for each file being loaded
  49612. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49613. * @param pluginExtension the extension used to determine the plugin
  49614. * @returns The loaded plugin
  49615. */
  49616. 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>;
  49617. /**
  49618. * Load a scene
  49619. * @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)
  49620. * @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)
  49621. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49622. * @param onProgress a callback with a progress event for each file being loaded
  49623. * @param pluginExtension the extension used to determine the plugin
  49624. * @returns The loaded scene
  49625. */
  49626. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49627. /**
  49628. * Append a scene
  49629. * @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)
  49630. * @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)
  49631. * @param scene is the instance of BABYLON.Scene to append to
  49632. * @param onSuccess a callback with the scene when import succeeds
  49633. * @param onProgress a callback with a progress event for each file being loaded
  49634. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49635. * @param pluginExtension the extension used to determine the plugin
  49636. * @returns The loaded plugin
  49637. */
  49638. 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>;
  49639. /**
  49640. * Append a scene
  49641. * @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)
  49642. * @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)
  49643. * @param scene is the instance of BABYLON.Scene to append to
  49644. * @param onProgress a callback with a progress event for each file being loaded
  49645. * @param pluginExtension the extension used to determine the plugin
  49646. * @returns The given scene
  49647. */
  49648. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49649. /**
  49650. * Load a scene into an asset container
  49651. * @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)
  49652. * @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)
  49653. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49654. * @param onSuccess a callback with the scene when import succeeds
  49655. * @param onProgress a callback with a progress event for each file being loaded
  49656. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49657. * @param pluginExtension the extension used to determine the plugin
  49658. * @returns The loaded plugin
  49659. */
  49660. 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>;
  49661. /**
  49662. * Load a scene into an asset container
  49663. * @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)
  49664. * @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)
  49665. * @param scene is the instance of Scene to append to
  49666. * @param onProgress a callback with a progress event for each file being loaded
  49667. * @param pluginExtension the extension used to determine the plugin
  49668. * @returns The loaded asset container
  49669. */
  49670. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49671. /**
  49672. * Import animations from a file into a scene
  49673. * @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)
  49674. * @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)
  49675. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49676. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49677. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49678. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49679. * @param onSuccess a callback with the scene when import succeeds
  49680. * @param onProgress a callback with a progress event for each file being loaded
  49681. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49682. * @param pluginExtension the extension used to determine the plugin
  49683. */
  49684. 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;
  49685. /**
  49686. * Import animations from a file into a scene
  49687. * @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)
  49688. * @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)
  49689. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49690. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49691. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49692. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49693. * @param onSuccess a callback with the scene when import succeeds
  49694. * @param onProgress a callback with a progress event for each file being loaded
  49695. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49696. * @param pluginExtension the extension used to determine the plugin
  49697. * @returns the updated scene with imported animations
  49698. */
  49699. 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>;
  49700. }
  49701. }
  49702. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49703. import { IDisposable, Scene } from "babylonjs/scene";
  49704. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49705. import { Observable } from "babylonjs/Misc/observable";
  49706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49707. import { Nullable } from "babylonjs/types";
  49708. /**
  49709. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49710. */
  49711. export type MotionControllerHandedness = "none" | "left" | "right";
  49712. /**
  49713. * The type of components available in motion controllers.
  49714. * This is not the name of the component.
  49715. */
  49716. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49717. /**
  49718. * The state of a controller component
  49719. */
  49720. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49721. /**
  49722. * The schema of motion controller layout.
  49723. * No object will be initialized using this interface
  49724. * This is used just to define the profile.
  49725. */
  49726. export interface IMotionControllerLayout {
  49727. /**
  49728. * Path to load the assets. Usually relative to the base path
  49729. */
  49730. assetPath: string;
  49731. /**
  49732. * Available components (unsorted)
  49733. */
  49734. components: {
  49735. /**
  49736. * A map of component Ids
  49737. */
  49738. [componentId: string]: {
  49739. /**
  49740. * The type of input the component outputs
  49741. */
  49742. type: MotionControllerComponentType;
  49743. /**
  49744. * The indices of this component in the gamepad object
  49745. */
  49746. gamepadIndices: {
  49747. /**
  49748. * Index of button
  49749. */
  49750. button?: number;
  49751. /**
  49752. * If available, index of x-axis
  49753. */
  49754. xAxis?: number;
  49755. /**
  49756. * If available, index of y-axis
  49757. */
  49758. yAxis?: number;
  49759. };
  49760. /**
  49761. * The mesh's root node name
  49762. */
  49763. rootNodeName: string;
  49764. /**
  49765. * Animation definitions for this model
  49766. */
  49767. visualResponses: {
  49768. [stateKey: string]: {
  49769. /**
  49770. * What property will be animated
  49771. */
  49772. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49773. /**
  49774. * What states influence this visual response
  49775. */
  49776. states: MotionControllerComponentStateType[];
  49777. /**
  49778. * Type of animation - movement or visibility
  49779. */
  49780. valueNodeProperty: "transform" | "visibility";
  49781. /**
  49782. * Base node name to move. Its position will be calculated according to the min and max nodes
  49783. */
  49784. valueNodeName?: string;
  49785. /**
  49786. * Minimum movement node
  49787. */
  49788. minNodeName?: string;
  49789. /**
  49790. * Max movement node
  49791. */
  49792. maxNodeName?: string;
  49793. };
  49794. };
  49795. /**
  49796. * If touch enabled, what is the name of node to display user feedback
  49797. */
  49798. touchPointNodeName?: string;
  49799. };
  49800. };
  49801. /**
  49802. * Is it xr standard mapping or not
  49803. */
  49804. gamepadMapping: "" | "xr-standard";
  49805. /**
  49806. * Base root node of this entire model
  49807. */
  49808. rootNodeName: string;
  49809. /**
  49810. * Defines the main button component id
  49811. */
  49812. selectComponentId: string;
  49813. }
  49814. /**
  49815. * A definition for the layout map in the input profile
  49816. */
  49817. export interface IMotionControllerLayoutMap {
  49818. /**
  49819. * Layouts with handedness type as a key
  49820. */
  49821. [handedness: string]: IMotionControllerLayout;
  49822. }
  49823. /**
  49824. * The XR Input profile schema
  49825. * Profiles can be found here:
  49826. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49827. */
  49828. export interface IMotionControllerProfile {
  49829. /**
  49830. * fallback profiles for this profileId
  49831. */
  49832. fallbackProfileIds: string[];
  49833. /**
  49834. * The layout map, with handedness as key
  49835. */
  49836. layouts: IMotionControllerLayoutMap;
  49837. /**
  49838. * The id of this profile
  49839. * correlates to the profile(s) in the xrInput.profiles array
  49840. */
  49841. profileId: string;
  49842. }
  49843. /**
  49844. * A helper-interface for the 3 meshes needed for controller button animation
  49845. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  49846. */
  49847. export interface IMotionControllerButtonMeshMap {
  49848. /**
  49849. * the mesh that defines the pressed value mesh position.
  49850. * This is used to find the max-position of this button
  49851. */
  49852. pressedMesh: AbstractMesh;
  49853. /**
  49854. * the mesh that defines the unpressed value mesh position.
  49855. * This is used to find the min (or initial) position of this button
  49856. */
  49857. unpressedMesh: AbstractMesh;
  49858. /**
  49859. * The mesh that will be changed when value changes
  49860. */
  49861. valueMesh: AbstractMesh;
  49862. }
  49863. /**
  49864. * A helper-interface for the 3 meshes needed for controller axis animation.
  49865. * This will be expanded when touchpad animations are fully supported
  49866. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  49867. */
  49868. export interface IMotionControllerMeshMap {
  49869. /**
  49870. * the mesh that defines the maximum value mesh position.
  49871. */
  49872. maxMesh?: AbstractMesh;
  49873. /**
  49874. * the mesh that defines the minimum value mesh position.
  49875. */
  49876. minMesh?: AbstractMesh;
  49877. /**
  49878. * The mesh that will be changed when axis value changes
  49879. */
  49880. valueMesh?: AbstractMesh;
  49881. }
  49882. /**
  49883. * The elements needed for change-detection of the gamepad objects in motion controllers
  49884. */
  49885. export interface IMinimalMotionControllerObject {
  49886. /**
  49887. * Available axes of this controller
  49888. */
  49889. axes: number[];
  49890. /**
  49891. * An array of available buttons
  49892. */
  49893. buttons: Array<{
  49894. /**
  49895. * Value of the button/trigger
  49896. */
  49897. value: number;
  49898. /**
  49899. * If the button/trigger is currently touched
  49900. */
  49901. touched: boolean;
  49902. /**
  49903. * If the button/trigger is currently pressed
  49904. */
  49905. pressed: boolean;
  49906. }>;
  49907. /**
  49908. * EXPERIMENTAL haptic support.
  49909. */
  49910. hapticActuators?: Array<{
  49911. pulse: (value: number, duration: number) => Promise<boolean>;
  49912. }>;
  49913. }
  49914. /**
  49915. * An Abstract Motion controller
  49916. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49917. * Each component has an observable to check for changes in value and state
  49918. */
  49919. export abstract class WebXRAbstractMotionController implements IDisposable {
  49920. protected scene: Scene;
  49921. protected layout: IMotionControllerLayout;
  49922. /**
  49923. * The gamepad object correlating to this controller
  49924. */
  49925. gamepadObject: IMinimalMotionControllerObject;
  49926. /**
  49927. * handedness (left/right/none) of this controller
  49928. */
  49929. handedness: MotionControllerHandedness;
  49930. private _initComponent;
  49931. private _modelReady;
  49932. /**
  49933. * A map of components (WebXRControllerComponent) in this motion controller
  49934. * Components have a ComponentType and can also have both button and axis definitions
  49935. */
  49936. readonly components: {
  49937. [id: string]: WebXRControllerComponent;
  49938. };
  49939. /**
  49940. * Disable the model's animation. Can be set at any time.
  49941. */
  49942. disableAnimation: boolean;
  49943. /**
  49944. * Observers registered here will be triggered when the model of this controller is done loading
  49945. */
  49946. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49947. /**
  49948. * The profile id of this motion controller
  49949. */
  49950. abstract profileId: string;
  49951. /**
  49952. * The root mesh of the model. It is null if the model was not yet initialized
  49953. */
  49954. rootMesh: Nullable<AbstractMesh>;
  49955. /**
  49956. * constructs a new abstract motion controller
  49957. * @param scene the scene to which the model of the controller will be added
  49958. * @param layout The profile layout to load
  49959. * @param gamepadObject The gamepad object correlating to this controller
  49960. * @param handedness handedness (left/right/none) of this controller
  49961. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49962. */
  49963. constructor(scene: Scene, layout: IMotionControllerLayout,
  49964. /**
  49965. * The gamepad object correlating to this controller
  49966. */
  49967. gamepadObject: IMinimalMotionControllerObject,
  49968. /**
  49969. * handedness (left/right/none) of this controller
  49970. */
  49971. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  49972. /**
  49973. * Dispose this controller, the model mesh and all its components
  49974. */
  49975. dispose(): void;
  49976. /**
  49977. * Returns all components of specific type
  49978. * @param type the type to search for
  49979. * @return an array of components with this type
  49980. */
  49981. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  49982. /**
  49983. * get a component based an its component id as defined in layout.components
  49984. * @param id the id of the component
  49985. * @returns the component correlates to the id or undefined if not found
  49986. */
  49987. getComponent(id: string): WebXRControllerComponent;
  49988. /**
  49989. * Get the list of components available in this motion controller
  49990. * @returns an array of strings correlating to available components
  49991. */
  49992. getComponentIds(): string[];
  49993. /**
  49994. * Get the first component of specific type
  49995. * @param type type of component to find
  49996. * @return a controller component or null if not found
  49997. */
  49998. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  49999. /**
  50000. * Get the main (Select) component of this controller as defined in the layout
  50001. * @returns the main component of this controller
  50002. */
  50003. getMainComponent(): WebXRControllerComponent;
  50004. /**
  50005. * Loads the model correlating to this controller
  50006. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  50007. * @returns A promise fulfilled with the result of the model loading
  50008. */
  50009. loadModel(): Promise<boolean>;
  50010. /**
  50011. * Update this model using the current XRFrame
  50012. * @param xrFrame the current xr frame to use and update the model
  50013. */
  50014. updateFromXRFrame(xrFrame: XRFrame): void;
  50015. /**
  50016. * Backwards compatibility due to a deeply-integrated typo
  50017. */
  50018. get handness(): XREye;
  50019. /**
  50020. * Pulse (vibrate) this controller
  50021. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  50022. * Consecutive calls to this function will cancel the last pulse call
  50023. *
  50024. * @param value the strength of the pulse in 0.0...1.0 range
  50025. * @param duration Duration of the pulse in milliseconds
  50026. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  50027. * @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
  50028. */
  50029. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  50030. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50031. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50032. /**
  50033. * Moves the axis on the controller mesh based on its current state
  50034. * @param axis the index of the axis
  50035. * @param axisValue the value of the axis which determines the meshes new position
  50036. * @hidden
  50037. */
  50038. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  50039. /**
  50040. * Update the model itself with the current frame data
  50041. * @param xrFrame the frame to use for updating the model mesh
  50042. */
  50043. protected updateModel(xrFrame: XRFrame): void;
  50044. /**
  50045. * Get the filename and path for this controller's model
  50046. * @returns a map of filename and path
  50047. */
  50048. protected abstract _getFilenameAndPath(): {
  50049. filename: string;
  50050. path: string;
  50051. };
  50052. /**
  50053. * This function is called before the mesh is loaded. It checks for loading constraints.
  50054. * For example, this function can check if the GLB loader is available
  50055. * If this function returns false, the generic controller will be loaded instead
  50056. * @returns Is the client ready to load the mesh
  50057. */
  50058. protected abstract _getModelLoadingConstraints(): boolean;
  50059. /**
  50060. * This function will be called after the model was successfully loaded and can be used
  50061. * for mesh transformations before it is available for the user
  50062. * @param meshes the loaded meshes
  50063. */
  50064. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50065. /**
  50066. * Set the root mesh for this controller. Important for the WebXR controller class
  50067. * @param meshes the loaded meshes
  50068. */
  50069. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50070. /**
  50071. * A function executed each frame that updates the mesh (if needed)
  50072. * @param xrFrame the current xrFrame
  50073. */
  50074. protected abstract _updateModel(xrFrame: XRFrame): void;
  50075. private _getGenericFilenameAndPath;
  50076. private _getGenericParentMesh;
  50077. }
  50078. }
  50079. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50080. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50082. import { Scene } from "babylonjs/scene";
  50083. /**
  50084. * A generic trigger-only motion controller for WebXR
  50085. */
  50086. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50087. /**
  50088. * Static version of the profile id of this controller
  50089. */
  50090. static ProfileId: string;
  50091. profileId: string;
  50092. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50093. protected _getFilenameAndPath(): {
  50094. filename: string;
  50095. path: string;
  50096. };
  50097. protected _getModelLoadingConstraints(): boolean;
  50098. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50099. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50100. protected _updateModel(): void;
  50101. }
  50102. }
  50103. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50104. import { Vector4 } from "babylonjs/Maths/math.vector";
  50105. import { Mesh } from "babylonjs/Meshes/mesh";
  50106. import { Scene } from "babylonjs/scene";
  50107. import { Nullable } from "babylonjs/types";
  50108. /**
  50109. * Class containing static functions to help procedurally build meshes
  50110. */
  50111. export class SphereBuilder {
  50112. /**
  50113. * Creates a sphere mesh
  50114. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50115. * * 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`)
  50116. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50117. * * 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
  50118. * * 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)
  50119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50120. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50122. * @param name defines the name of the mesh
  50123. * @param options defines the options used to create the mesh
  50124. * @param scene defines the hosting scene
  50125. * @returns the sphere mesh
  50126. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50127. */
  50128. static CreateSphere(name: string, options: {
  50129. segments?: number;
  50130. diameter?: number;
  50131. diameterX?: number;
  50132. diameterY?: number;
  50133. diameterZ?: number;
  50134. arc?: number;
  50135. slice?: number;
  50136. sideOrientation?: number;
  50137. frontUVs?: Vector4;
  50138. backUVs?: Vector4;
  50139. updatable?: boolean;
  50140. }, scene?: Nullable<Scene>): Mesh;
  50141. }
  50142. }
  50143. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50145. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50146. import { Scene } from "babylonjs/scene";
  50147. /**
  50148. * A profiled motion controller has its profile loaded from an online repository.
  50149. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50150. */
  50151. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50152. private _repositoryUrl;
  50153. private _buttonMeshMapping;
  50154. private _touchDots;
  50155. /**
  50156. * The profile ID of this controller. Will be populated when the controller initializes.
  50157. */
  50158. profileId: string;
  50159. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50160. dispose(): void;
  50161. protected _getFilenameAndPath(): {
  50162. filename: string;
  50163. path: string;
  50164. };
  50165. protected _getModelLoadingConstraints(): boolean;
  50166. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50167. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50168. protected _updateModel(_xrFrame: XRFrame): void;
  50169. }
  50170. }
  50171. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50172. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50173. import { Scene } from "babylonjs/scene";
  50174. /**
  50175. * A construction function type to create a new controller based on an xrInput object
  50176. */
  50177. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50178. /**
  50179. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50180. *
  50181. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50182. * it should be replaced with auto-loaded controllers.
  50183. *
  50184. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50185. */
  50186. export class WebXRMotionControllerManager {
  50187. private static _AvailableControllers;
  50188. private static _Fallbacks;
  50189. private static _ProfileLoadingPromises;
  50190. private static _ProfilesList;
  50191. /**
  50192. * The base URL of the online controller repository. Can be changed at any time.
  50193. */
  50194. static BaseRepositoryUrl: string;
  50195. /**
  50196. * Which repository gets priority - local or online
  50197. */
  50198. static PrioritizeOnlineRepository: boolean;
  50199. /**
  50200. * Use the online repository, or use only locally-defined controllers
  50201. */
  50202. static UseOnlineRepository: boolean;
  50203. /**
  50204. * Clear the cache used for profile loading and reload when requested again
  50205. */
  50206. static ClearProfilesCache(): void;
  50207. /**
  50208. * Register the default fallbacks.
  50209. * This function is called automatically when this file is imported.
  50210. */
  50211. static DefaultFallbacks(): void;
  50212. /**
  50213. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50214. * @param profileId the profile to which a fallback needs to be found
  50215. * @return an array with corresponding fallback profiles
  50216. */
  50217. static FindFallbackWithProfileId(profileId: string): string[];
  50218. /**
  50219. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50220. * The order of search:
  50221. *
  50222. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50223. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50224. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50225. * 4) return the generic trigger controller if none were found
  50226. *
  50227. * @param xrInput the xrInput to which a new controller is initialized
  50228. * @param scene the scene to which the model will be added
  50229. * @param forceProfile force a certain profile for this controller
  50230. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50231. */
  50232. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50233. /**
  50234. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50235. *
  50236. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50237. *
  50238. * @param type the profile type to register
  50239. * @param constructFunction the function to be called when loading this profile
  50240. */
  50241. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50242. /**
  50243. * Register a fallback to a specific profile.
  50244. * @param profileId the profileId that will receive the fallbacks
  50245. * @param fallbacks A list of fallback profiles
  50246. */
  50247. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50248. /**
  50249. * Will update the list of profiles available in the repository
  50250. * @return a promise that resolves to a map of profiles available online
  50251. */
  50252. static UpdateProfilesList(): Promise<{
  50253. [profile: string]: string;
  50254. }>;
  50255. private static _LoadProfileFromRepository;
  50256. private static _LoadProfilesFromAvailableControllers;
  50257. }
  50258. }
  50259. declare module "babylonjs/XR/webXRInputSource" {
  50260. import { Observable } from "babylonjs/Misc/observable";
  50261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50262. import { Ray } from "babylonjs/Culling/ray";
  50263. import { Scene } from "babylonjs/scene";
  50264. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50265. /**
  50266. * Configuration options for the WebXR controller creation
  50267. */
  50268. export interface IWebXRControllerOptions {
  50269. /**
  50270. * Should the controller mesh be animated when a user interacts with it
  50271. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50272. */
  50273. disableMotionControllerAnimation?: boolean;
  50274. /**
  50275. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50276. */
  50277. doNotLoadControllerMesh?: boolean;
  50278. /**
  50279. * Force a specific controller type for this controller.
  50280. * This can be used when creating your own profile or when testing different controllers
  50281. */
  50282. forceControllerProfile?: string;
  50283. /**
  50284. * Defines a rendering group ID for meshes that will be loaded.
  50285. * This is for the default controllers only.
  50286. */
  50287. renderingGroupId?: number;
  50288. }
  50289. /**
  50290. * Represents an XR controller
  50291. */
  50292. export class WebXRInputSource {
  50293. private _scene;
  50294. /** The underlying input source for the controller */
  50295. inputSource: XRInputSource;
  50296. private _options;
  50297. private _tmpVector;
  50298. private _uniqueId;
  50299. private _disposed;
  50300. /**
  50301. * 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
  50302. */
  50303. grip?: AbstractMesh;
  50304. /**
  50305. * If available, this is the gamepad object related to this controller.
  50306. * Using this object it is possible to get click events and trackpad changes of the
  50307. * webxr controller that is currently being used.
  50308. */
  50309. motionController?: WebXRAbstractMotionController;
  50310. /**
  50311. * Event that fires when the controller is removed/disposed.
  50312. * The object provided as event data is this controller, after associated assets were disposed.
  50313. * uniqueId is still available.
  50314. */
  50315. onDisposeObservable: Observable<WebXRInputSource>;
  50316. /**
  50317. * Will be triggered when the mesh associated with the motion controller is done loading.
  50318. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50319. * A shortened version of controller -> motion controller -> on mesh loaded.
  50320. */
  50321. onMeshLoadedObservable: Observable<AbstractMesh>;
  50322. /**
  50323. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50324. */
  50325. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50326. /**
  50327. * Pointer which can be used to select objects or attach a visible laser to
  50328. */
  50329. pointer: AbstractMesh;
  50330. /**
  50331. * Creates the input source object
  50332. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50333. * @param _scene the scene which the controller should be associated to
  50334. * @param inputSource the underlying input source for the controller
  50335. * @param _options options for this controller creation
  50336. */
  50337. constructor(_scene: Scene,
  50338. /** The underlying input source for the controller */
  50339. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50340. /**
  50341. * Get this controllers unique id
  50342. */
  50343. get uniqueId(): string;
  50344. /**
  50345. * Disposes of the object
  50346. */
  50347. dispose(): void;
  50348. /**
  50349. * Gets a world space ray coming from the pointer or grip
  50350. * @param result the resulting ray
  50351. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50352. */
  50353. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50354. /**
  50355. * Updates the controller pose based on the given XRFrame
  50356. * @param xrFrame xr frame to update the pose with
  50357. * @param referenceSpace reference space to use
  50358. */
  50359. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50360. }
  50361. }
  50362. declare module "babylonjs/XR/webXRInput" {
  50363. import { Observable } from "babylonjs/Misc/observable";
  50364. import { IDisposable } from "babylonjs/scene";
  50365. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50366. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50367. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50368. /**
  50369. * The schema for initialization options of the XR Input class
  50370. */
  50371. export interface IWebXRInputOptions {
  50372. /**
  50373. * If set to true no model will be automatically loaded
  50374. */
  50375. doNotLoadControllerMeshes?: boolean;
  50376. /**
  50377. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50378. * If not found, the xr input profile data will be used.
  50379. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50380. */
  50381. forceInputProfile?: string;
  50382. /**
  50383. * Do not send a request to the controller repository to load the profile.
  50384. *
  50385. * Instead, use the controllers available in babylon itself.
  50386. */
  50387. disableOnlineControllerRepository?: boolean;
  50388. /**
  50389. * A custom URL for the controllers repository
  50390. */
  50391. customControllersRepositoryURL?: string;
  50392. /**
  50393. * Should the controller model's components not move according to the user input
  50394. */
  50395. disableControllerAnimation?: boolean;
  50396. /**
  50397. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50398. */
  50399. controllerOptions?: IWebXRControllerOptions;
  50400. }
  50401. /**
  50402. * XR input used to track XR inputs such as controllers/rays
  50403. */
  50404. export class WebXRInput implements IDisposable {
  50405. /**
  50406. * the xr session manager for this session
  50407. */
  50408. xrSessionManager: WebXRSessionManager;
  50409. /**
  50410. * the WebXR camera for this session. Mainly used for teleportation
  50411. */
  50412. xrCamera: WebXRCamera;
  50413. private readonly options;
  50414. /**
  50415. * XR controllers being tracked
  50416. */
  50417. controllers: Array<WebXRInputSource>;
  50418. private _frameObserver;
  50419. private _sessionEndedObserver;
  50420. private _sessionInitObserver;
  50421. /**
  50422. * Event when a controller has been connected/added
  50423. */
  50424. onControllerAddedObservable: Observable<WebXRInputSource>;
  50425. /**
  50426. * Event when a controller has been removed/disconnected
  50427. */
  50428. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50429. /**
  50430. * Initializes the WebXRInput
  50431. * @param xrSessionManager the xr session manager for this session
  50432. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50433. * @param options = initialization options for this xr input
  50434. */
  50435. constructor(
  50436. /**
  50437. * the xr session manager for this session
  50438. */
  50439. xrSessionManager: WebXRSessionManager,
  50440. /**
  50441. * the WebXR camera for this session. Mainly used for teleportation
  50442. */
  50443. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50444. private _onInputSourcesChange;
  50445. private _addAndRemoveControllers;
  50446. /**
  50447. * Disposes of the object
  50448. */
  50449. dispose(): void;
  50450. }
  50451. }
  50452. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50453. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50454. import { Observable, EventState } from "babylonjs/Misc/observable";
  50455. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50456. /**
  50457. * This is the base class for all WebXR features.
  50458. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50459. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50460. */
  50461. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50462. protected _xrSessionManager: WebXRSessionManager;
  50463. private _attached;
  50464. private _removeOnDetach;
  50465. /**
  50466. * Should auto-attach be disabled?
  50467. */
  50468. disableAutoAttach: boolean;
  50469. /**
  50470. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50471. */
  50472. xrNativeFeatureName: string;
  50473. /**
  50474. * Construct a new (abstract) WebXR feature
  50475. * @param _xrSessionManager the xr session manager for this feature
  50476. */
  50477. constructor(_xrSessionManager: WebXRSessionManager);
  50478. /**
  50479. * Is this feature attached
  50480. */
  50481. get attached(): boolean;
  50482. /**
  50483. * attach this feature
  50484. *
  50485. * @param force should attachment be forced (even when already attached)
  50486. * @returns true if successful, false is failed or already attached
  50487. */
  50488. attach(force?: boolean): boolean;
  50489. /**
  50490. * detach this feature.
  50491. *
  50492. * @returns true if successful, false if failed or already detached
  50493. */
  50494. detach(): boolean;
  50495. /**
  50496. * Dispose this feature and all of the resources attached
  50497. */
  50498. dispose(): void;
  50499. /**
  50500. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50501. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50502. *
  50503. * @returns whether or not the feature is compatible in this environment
  50504. */
  50505. isCompatible(): boolean;
  50506. /**
  50507. * This is used to register callbacks that will automatically be removed when detach is called.
  50508. * @param observable the observable to which the observer will be attached
  50509. * @param callback the callback to register
  50510. */
  50511. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50512. /**
  50513. * Code in this function will be executed on each xrFrame received from the browser.
  50514. * This function will not execute after the feature is detached.
  50515. * @param _xrFrame the current frame
  50516. */
  50517. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50518. }
  50519. }
  50520. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50521. import { IDisposable, Scene } from "babylonjs/scene";
  50522. import { Nullable } from "babylonjs/types";
  50523. import { Observable } from "babylonjs/Misc/observable";
  50524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50525. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50526. import { Camera } from "babylonjs/Cameras/camera";
  50527. /**
  50528. * Renders a layer on top of an existing scene
  50529. */
  50530. export class UtilityLayerRenderer implements IDisposable {
  50531. /** the original scene that will be rendered on top of */
  50532. originalScene: Scene;
  50533. private _pointerCaptures;
  50534. private _lastPointerEvents;
  50535. private static _DefaultUtilityLayer;
  50536. private static _DefaultKeepDepthUtilityLayer;
  50537. private _sharedGizmoLight;
  50538. private _renderCamera;
  50539. /**
  50540. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50541. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50542. * @returns the camera that is used when rendering the utility layer
  50543. */
  50544. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50545. /**
  50546. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50547. * @param cam the camera that should be used when rendering the utility layer
  50548. */
  50549. setRenderCamera(cam: Nullable<Camera>): void;
  50550. /**
  50551. * @hidden
  50552. * Light which used by gizmos to get light shading
  50553. */
  50554. _getSharedGizmoLight(): HemisphericLight;
  50555. /**
  50556. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50557. */
  50558. pickUtilitySceneFirst: boolean;
  50559. /**
  50560. * 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)
  50561. */
  50562. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50563. /**
  50564. * 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)
  50565. */
  50566. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50567. /**
  50568. * The scene that is rendered on top of the original scene
  50569. */
  50570. utilityLayerScene: Scene;
  50571. /**
  50572. * If the utility layer should automatically be rendered on top of existing scene
  50573. */
  50574. shouldRender: boolean;
  50575. /**
  50576. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50577. */
  50578. onlyCheckPointerDownEvents: boolean;
  50579. /**
  50580. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50581. */
  50582. processAllEvents: boolean;
  50583. /**
  50584. * Observable raised when the pointer move from the utility layer scene to the main scene
  50585. */
  50586. onPointerOutObservable: Observable<number>;
  50587. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50588. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50589. private _afterRenderObserver;
  50590. private _sceneDisposeObserver;
  50591. private _originalPointerObserver;
  50592. /**
  50593. * Instantiates a UtilityLayerRenderer
  50594. * @param originalScene the original scene that will be rendered on top of
  50595. * @param handleEvents boolean indicating if the utility layer should handle events
  50596. */
  50597. constructor(
  50598. /** the original scene that will be rendered on top of */
  50599. originalScene: Scene, handleEvents?: boolean);
  50600. private _notifyObservers;
  50601. /**
  50602. * Renders the utility layers scene on top of the original scene
  50603. */
  50604. render(): void;
  50605. /**
  50606. * Disposes of the renderer
  50607. */
  50608. dispose(): void;
  50609. private _updateCamera;
  50610. }
  50611. }
  50612. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50613. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50615. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50616. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50617. import { Scene } from "babylonjs/scene";
  50618. import { Nullable } from "babylonjs/types";
  50619. import { Color3 } from "babylonjs/Maths/math.color";
  50620. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50621. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50622. /**
  50623. * Options interface for the pointer selection module
  50624. */
  50625. export interface IWebXRControllerPointerSelectionOptions {
  50626. /**
  50627. * if provided, this scene will be used to render meshes.
  50628. */
  50629. customUtilityLayerScene?: Scene;
  50630. /**
  50631. * 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)
  50632. * If not disabled, the last picked point will be used to execute a pointer up event
  50633. * If disabled, pointer up event will be triggered right after the pointer down event.
  50634. * Used in screen and gaze target ray mode only
  50635. */
  50636. disablePointerUpOnTouchOut: boolean;
  50637. /**
  50638. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50639. */
  50640. forceGazeMode: boolean;
  50641. /**
  50642. * 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
  50643. * to start a new countdown to the pointer down event.
  50644. * Defaults to 1.
  50645. */
  50646. gazeModePointerMovedFactor?: number;
  50647. /**
  50648. * Different button type to use instead of the main component
  50649. */
  50650. overrideButtonId?: string;
  50651. /**
  50652. * use this rendering group id for the meshes (optional)
  50653. */
  50654. renderingGroupId?: number;
  50655. /**
  50656. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50657. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50658. * 3000 means 3 seconds between pointing at something and selecting it
  50659. */
  50660. timeToSelect?: number;
  50661. /**
  50662. * Should meshes created here be added to a utility layer or the main scene
  50663. */
  50664. useUtilityLayer?: boolean;
  50665. /**
  50666. * Optional WebXR camera to be used for gaze selection
  50667. */
  50668. gazeCamera?: WebXRCamera;
  50669. /**
  50670. * the xr input to use with this pointer selection
  50671. */
  50672. xrInput: WebXRInput;
  50673. }
  50674. /**
  50675. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50676. */
  50677. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50678. private readonly _options;
  50679. private static _idCounter;
  50680. private _attachController;
  50681. private _controllers;
  50682. private _scene;
  50683. private _tmpVectorForPickCompare;
  50684. /**
  50685. * The module's name
  50686. */
  50687. static readonly Name: string;
  50688. /**
  50689. * The (Babylon) version of this module.
  50690. * This is an integer representing the implementation version.
  50691. * This number does not correspond to the WebXR specs version
  50692. */
  50693. static readonly Version: number;
  50694. /**
  50695. * Disable lighting on the laser pointer (so it will always be visible)
  50696. */
  50697. disablePointerLighting: boolean;
  50698. /**
  50699. * Disable lighting on the selection mesh (so it will always be visible)
  50700. */
  50701. disableSelectionMeshLighting: boolean;
  50702. /**
  50703. * Should the laser pointer be displayed
  50704. */
  50705. displayLaserPointer: boolean;
  50706. /**
  50707. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50708. */
  50709. displaySelectionMesh: boolean;
  50710. /**
  50711. * This color will be set to the laser pointer when selection is triggered
  50712. */
  50713. laserPointerPickedColor: Color3;
  50714. /**
  50715. * Default color of the laser pointer
  50716. */
  50717. laserPointerDefaultColor: Color3;
  50718. /**
  50719. * default color of the selection ring
  50720. */
  50721. selectionMeshDefaultColor: Color3;
  50722. /**
  50723. * This color will be applied to the selection ring when selection is triggered
  50724. */
  50725. selectionMeshPickedColor: Color3;
  50726. /**
  50727. * Optional filter to be used for ray selection. This predicate shares behavior with
  50728. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50729. */
  50730. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50731. /**
  50732. * constructs a new background remover module
  50733. * @param _xrSessionManager the session manager for this module
  50734. * @param _options read-only options to be used in this module
  50735. */
  50736. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50737. /**
  50738. * attach this feature
  50739. * Will usually be called by the features manager
  50740. *
  50741. * @returns true if successful.
  50742. */
  50743. attach(): boolean;
  50744. /**
  50745. * detach this feature.
  50746. * Will usually be called by the features manager
  50747. *
  50748. * @returns true if successful.
  50749. */
  50750. detach(): boolean;
  50751. /**
  50752. * Will get the mesh under a specific pointer.
  50753. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50754. * @param controllerId the controllerId to check
  50755. * @returns The mesh under pointer or null if no mesh is under the pointer
  50756. */
  50757. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50758. /**
  50759. * Get the xr controller that correlates to the pointer id in the pointer event
  50760. *
  50761. * @param id the pointer id to search for
  50762. * @returns the controller that correlates to this id or null if not found
  50763. */
  50764. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50765. protected _onXRFrame(_xrFrame: XRFrame): void;
  50766. private _attachGazeMode;
  50767. private _attachScreenRayMode;
  50768. private _attachTrackedPointerRayMode;
  50769. private _convertNormalToDirectionOfRay;
  50770. private _detachController;
  50771. private _generateNewMeshPair;
  50772. private _pickingMoved;
  50773. private _updatePointerDistance;
  50774. /** @hidden */
  50775. get lasterPointerDefaultColor(): Color3;
  50776. }
  50777. }
  50778. declare module "babylonjs/XR/webXREnterExitUI" {
  50779. import { Nullable } from "babylonjs/types";
  50780. import { Observable } from "babylonjs/Misc/observable";
  50781. import { IDisposable, Scene } from "babylonjs/scene";
  50782. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50783. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50784. /**
  50785. * Button which can be used to enter a different mode of XR
  50786. */
  50787. export class WebXREnterExitUIButton {
  50788. /** button element */
  50789. element: HTMLElement;
  50790. /** XR initialization options for the button */
  50791. sessionMode: XRSessionMode;
  50792. /** Reference space type */
  50793. referenceSpaceType: XRReferenceSpaceType;
  50794. /**
  50795. * Creates a WebXREnterExitUIButton
  50796. * @param element button element
  50797. * @param sessionMode XR initialization session mode
  50798. * @param referenceSpaceType the type of reference space to be used
  50799. */
  50800. constructor(
  50801. /** button element */
  50802. element: HTMLElement,
  50803. /** XR initialization options for the button */
  50804. sessionMode: XRSessionMode,
  50805. /** Reference space type */
  50806. referenceSpaceType: XRReferenceSpaceType);
  50807. /**
  50808. * Extendable function which can be used to update the button's visuals when the state changes
  50809. * @param activeButton the current active button in the UI
  50810. */
  50811. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50812. }
  50813. /**
  50814. * Options to create the webXR UI
  50815. */
  50816. export class WebXREnterExitUIOptions {
  50817. /**
  50818. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50819. */
  50820. customButtons?: Array<WebXREnterExitUIButton>;
  50821. /**
  50822. * A reference space type to use when creating the default button.
  50823. * Default is local-floor
  50824. */
  50825. referenceSpaceType?: XRReferenceSpaceType;
  50826. /**
  50827. * Context to enter xr with
  50828. */
  50829. renderTarget?: Nullable<WebXRRenderTarget>;
  50830. /**
  50831. * A session mode to use when creating the default button.
  50832. * Default is immersive-vr
  50833. */
  50834. sessionMode?: XRSessionMode;
  50835. /**
  50836. * A list of optional features to init the session with
  50837. */
  50838. optionalFeatures?: string[];
  50839. /**
  50840. * A list of optional features to init the session with
  50841. */
  50842. requiredFeatures?: string[];
  50843. }
  50844. /**
  50845. * UI to allow the user to enter/exit XR mode
  50846. */
  50847. export class WebXREnterExitUI implements IDisposable {
  50848. private scene;
  50849. /** version of the options passed to this UI */
  50850. options: WebXREnterExitUIOptions;
  50851. private _activeButton;
  50852. private _buttons;
  50853. /**
  50854. * The HTML Div Element to which buttons are added.
  50855. */
  50856. readonly overlay: HTMLDivElement;
  50857. /**
  50858. * Fired every time the active button is changed.
  50859. *
  50860. * When xr is entered via a button that launches xr that button will be the callback parameter
  50861. *
  50862. * When exiting xr the callback parameter will be null)
  50863. */
  50864. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  50865. /**
  50866. *
  50867. * @param scene babylon scene object to use
  50868. * @param options (read-only) version of the options passed to this UI
  50869. */
  50870. private constructor();
  50871. /**
  50872. * Creates UI to allow the user to enter/exit XR mode
  50873. * @param scene the scene to add the ui to
  50874. * @param helper the xr experience helper to enter/exit xr with
  50875. * @param options options to configure the UI
  50876. * @returns the created ui
  50877. */
  50878. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  50879. /**
  50880. * Disposes of the XR UI component
  50881. */
  50882. dispose(): void;
  50883. private _updateButtons;
  50884. }
  50885. }
  50886. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  50887. import { Vector3 } from "babylonjs/Maths/math.vector";
  50888. import { Color4 } from "babylonjs/Maths/math.color";
  50889. import { Nullable } from "babylonjs/types";
  50890. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50891. import { Scene } from "babylonjs/scene";
  50892. /**
  50893. * Class containing static functions to help procedurally build meshes
  50894. */
  50895. export class LinesBuilder {
  50896. /**
  50897. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50898. * * 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
  50899. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50900. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50901. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50902. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50903. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50904. * * 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
  50905. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50908. * @param name defines the name of the new line system
  50909. * @param options defines the options used to create the line system
  50910. * @param scene defines the hosting scene
  50911. * @returns a new line system mesh
  50912. */
  50913. static CreateLineSystem(name: string, options: {
  50914. lines: Vector3[][];
  50915. updatable?: boolean;
  50916. instance?: Nullable<LinesMesh>;
  50917. colors?: Nullable<Color4[][]>;
  50918. useVertexAlpha?: boolean;
  50919. }, scene: Nullable<Scene>): LinesMesh;
  50920. /**
  50921. * Creates a line mesh
  50922. * 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
  50923. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50924. * * The parameter `points` is an array successive Vector3
  50925. * * 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
  50926. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50927. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50928. * * When updating an instance, remember that only point positions can change, not the number of points
  50929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50930. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50931. * @param name defines the name of the new line system
  50932. * @param options defines the options used to create the line system
  50933. * @param scene defines the hosting scene
  50934. * @returns a new line mesh
  50935. */
  50936. static CreateLines(name: string, options: {
  50937. points: Vector3[];
  50938. updatable?: boolean;
  50939. instance?: Nullable<LinesMesh>;
  50940. colors?: Color4[];
  50941. useVertexAlpha?: boolean;
  50942. }, scene?: Nullable<Scene>): LinesMesh;
  50943. /**
  50944. * Creates a dashed line mesh
  50945. * * 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
  50946. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50947. * * The parameter `points` is an array successive Vector3
  50948. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50949. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50950. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50951. * * 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
  50952. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50953. * * When updating an instance, remember that only point positions can change, not the number of points
  50954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50955. * @param name defines the name of the mesh
  50956. * @param options defines the options used to create the mesh
  50957. * @param scene defines the hosting scene
  50958. * @returns the dashed line mesh
  50959. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50960. */
  50961. static CreateDashedLines(name: string, options: {
  50962. points: Vector3[];
  50963. dashSize?: number;
  50964. gapSize?: number;
  50965. dashNb?: number;
  50966. updatable?: boolean;
  50967. instance?: LinesMesh;
  50968. useVertexAlpha?: boolean;
  50969. }, scene?: Nullable<Scene>): LinesMesh;
  50970. }
  50971. }
  50972. declare module "babylonjs/Misc/timer" {
  50973. import { Observable, Observer } from "babylonjs/Misc/observable";
  50974. import { Nullable } from "babylonjs/types";
  50975. import { IDisposable } from "babylonjs/scene";
  50976. /**
  50977. * Construction options for a timer
  50978. */
  50979. export interface ITimerOptions<T> {
  50980. /**
  50981. * Time-to-end
  50982. */
  50983. timeout: number;
  50984. /**
  50985. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  50986. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  50987. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  50988. */
  50989. contextObservable: Observable<T>;
  50990. /**
  50991. * Optional parameters when adding an observer to the observable
  50992. */
  50993. observableParameters?: {
  50994. mask?: number;
  50995. insertFirst?: boolean;
  50996. scope?: any;
  50997. };
  50998. /**
  50999. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  51000. */
  51001. breakCondition?: (data?: ITimerData<T>) => boolean;
  51002. /**
  51003. * Will be triggered when the time condition has met
  51004. */
  51005. onEnded?: (data: ITimerData<any>) => void;
  51006. /**
  51007. * Will be triggered when the break condition has met (prematurely ended)
  51008. */
  51009. onAborted?: (data: ITimerData<any>) => void;
  51010. /**
  51011. * Optional function to execute on each tick (or count)
  51012. */
  51013. onTick?: (data: ITimerData<any>) => void;
  51014. }
  51015. /**
  51016. * An interface defining the data sent by the timer
  51017. */
  51018. export interface ITimerData<T> {
  51019. /**
  51020. * When did it start
  51021. */
  51022. startTime: number;
  51023. /**
  51024. * Time now
  51025. */
  51026. currentTime: number;
  51027. /**
  51028. * Time passed since started
  51029. */
  51030. deltaTime: number;
  51031. /**
  51032. * How much is completed, in [0.0...1.0].
  51033. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  51034. */
  51035. completeRate: number;
  51036. /**
  51037. * What the registered observable sent in the last count
  51038. */
  51039. payload: T;
  51040. }
  51041. /**
  51042. * The current state of the timer
  51043. */
  51044. export enum TimerState {
  51045. /**
  51046. * Timer initialized, not yet started
  51047. */
  51048. INIT = 0,
  51049. /**
  51050. * Timer started and counting
  51051. */
  51052. STARTED = 1,
  51053. /**
  51054. * Timer ended (whether aborted or time reached)
  51055. */
  51056. ENDED = 2
  51057. }
  51058. /**
  51059. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51060. *
  51061. * @param options options with which to initialize this timer
  51062. */
  51063. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51064. /**
  51065. * An advanced implementation of a timer class
  51066. */
  51067. export class AdvancedTimer<T = any> implements IDisposable {
  51068. /**
  51069. * Will notify each time the timer calculates the remaining time
  51070. */
  51071. onEachCountObservable: Observable<ITimerData<T>>;
  51072. /**
  51073. * Will trigger when the timer was aborted due to the break condition
  51074. */
  51075. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51076. /**
  51077. * Will trigger when the timer ended successfully
  51078. */
  51079. onTimerEndedObservable: Observable<ITimerData<T>>;
  51080. /**
  51081. * Will trigger when the timer state has changed
  51082. */
  51083. onStateChangedObservable: Observable<TimerState>;
  51084. private _observer;
  51085. private _contextObservable;
  51086. private _observableParameters;
  51087. private _startTime;
  51088. private _timer;
  51089. private _state;
  51090. private _breakCondition;
  51091. private _timeToEnd;
  51092. private _breakOnNextTick;
  51093. /**
  51094. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51095. * @param options construction options for this advanced timer
  51096. */
  51097. constructor(options: ITimerOptions<T>);
  51098. /**
  51099. * set a breaking condition for this timer. Default is to never break during count
  51100. * @param predicate the new break condition. Returns true to break, false otherwise
  51101. */
  51102. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51103. /**
  51104. * Reset ALL associated observables in this advanced timer
  51105. */
  51106. clearObservables(): void;
  51107. /**
  51108. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51109. *
  51110. * @param timeToEnd how much time to measure until timer ended
  51111. */
  51112. start(timeToEnd?: number): void;
  51113. /**
  51114. * Will force a stop on the next tick.
  51115. */
  51116. stop(): void;
  51117. /**
  51118. * Dispose this timer, clearing all resources
  51119. */
  51120. dispose(): void;
  51121. private _setState;
  51122. private _tick;
  51123. private _stop;
  51124. }
  51125. }
  51126. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51127. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51128. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51129. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51131. import { Vector3 } from "babylonjs/Maths/math.vector";
  51132. import { Material } from "babylonjs/Materials/material";
  51133. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51134. import { Scene } from "babylonjs/scene";
  51135. /**
  51136. * The options container for the teleportation module
  51137. */
  51138. export interface IWebXRTeleportationOptions {
  51139. /**
  51140. * if provided, this scene will be used to render meshes.
  51141. */
  51142. customUtilityLayerScene?: Scene;
  51143. /**
  51144. * Values to configure the default target mesh
  51145. */
  51146. defaultTargetMeshOptions?: {
  51147. /**
  51148. * Fill color of the teleportation area
  51149. */
  51150. teleportationFillColor?: string;
  51151. /**
  51152. * Border color for the teleportation area
  51153. */
  51154. teleportationBorderColor?: string;
  51155. /**
  51156. * Disable the mesh's animation sequence
  51157. */
  51158. disableAnimation?: boolean;
  51159. /**
  51160. * Disable lighting on the material or the ring and arrow
  51161. */
  51162. disableLighting?: boolean;
  51163. /**
  51164. * Override the default material of the torus and arrow
  51165. */
  51166. torusArrowMaterial?: Material;
  51167. };
  51168. /**
  51169. * A list of meshes to use as floor meshes.
  51170. * Meshes can be added and removed after initializing the feature using the
  51171. * addFloorMesh and removeFloorMesh functions
  51172. * If empty, rotation will still work
  51173. */
  51174. floorMeshes?: AbstractMesh[];
  51175. /**
  51176. * use this rendering group id for the meshes (optional)
  51177. */
  51178. renderingGroupId?: number;
  51179. /**
  51180. * Should teleportation move only to snap points
  51181. */
  51182. snapPointsOnly?: boolean;
  51183. /**
  51184. * An array of points to which the teleportation will snap to.
  51185. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51186. */
  51187. snapPositions?: Vector3[];
  51188. /**
  51189. * How close should the teleportation ray be in order to snap to position.
  51190. * Default to 0.8 units (meters)
  51191. */
  51192. snapToPositionRadius?: number;
  51193. /**
  51194. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51195. * If you want to support rotation, make sure your mesh has a direction indicator.
  51196. *
  51197. * When left untouched, the default mesh will be initialized.
  51198. */
  51199. teleportationTargetMesh?: AbstractMesh;
  51200. /**
  51201. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51202. */
  51203. timeToTeleport?: number;
  51204. /**
  51205. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51206. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51207. */
  51208. useMainComponentOnly?: boolean;
  51209. /**
  51210. * Should meshes created here be added to a utility layer or the main scene
  51211. */
  51212. useUtilityLayer?: boolean;
  51213. /**
  51214. * Babylon XR Input class for controller
  51215. */
  51216. xrInput: WebXRInput;
  51217. }
  51218. /**
  51219. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51220. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51221. * the input of the attached controllers.
  51222. */
  51223. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51224. private _options;
  51225. private _controllers;
  51226. private _currentTeleportationControllerId;
  51227. private _floorMeshes;
  51228. private _quadraticBezierCurve;
  51229. private _selectionFeature;
  51230. private _snapToPositions;
  51231. private _snappedToPoint;
  51232. private _teleportationRingMaterial?;
  51233. private _tmpRay;
  51234. private _tmpVector;
  51235. /**
  51236. * The module's name
  51237. */
  51238. static readonly Name: string;
  51239. /**
  51240. * The (Babylon) version of this module.
  51241. * This is an integer representing the implementation version.
  51242. * This number does not correspond to the webxr specs version
  51243. */
  51244. static readonly Version: number;
  51245. /**
  51246. * Is movement backwards enabled
  51247. */
  51248. backwardsMovementEnabled: boolean;
  51249. /**
  51250. * Distance to travel when moving backwards
  51251. */
  51252. backwardsTeleportationDistance: number;
  51253. /**
  51254. * The distance from the user to the inspection point in the direction of the controller
  51255. * A higher number will allow the user to move further
  51256. * defaults to 5 (meters, in xr units)
  51257. */
  51258. parabolicCheckRadius: number;
  51259. /**
  51260. * Should the module support parabolic ray on top of direct ray
  51261. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51262. * Very helpful when moving between floors / different heights
  51263. */
  51264. parabolicRayEnabled: boolean;
  51265. /**
  51266. * How much rotation should be applied when rotating right and left
  51267. */
  51268. rotationAngle: number;
  51269. /**
  51270. * Is rotation enabled when moving forward?
  51271. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51272. */
  51273. rotationEnabled: boolean;
  51274. /**
  51275. * constructs a new anchor system
  51276. * @param _xrSessionManager an instance of WebXRSessionManager
  51277. * @param _options configuration object for this feature
  51278. */
  51279. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51280. /**
  51281. * Get the snapPointsOnly flag
  51282. */
  51283. get snapPointsOnly(): boolean;
  51284. /**
  51285. * Sets the snapPointsOnly flag
  51286. * @param snapToPoints should teleportation be exclusively to snap points
  51287. */
  51288. set snapPointsOnly(snapToPoints: boolean);
  51289. /**
  51290. * Add a new mesh to the floor meshes array
  51291. * @param mesh the mesh to use as floor mesh
  51292. */
  51293. addFloorMesh(mesh: AbstractMesh): void;
  51294. /**
  51295. * Add a new snap-to point to fix teleportation to this position
  51296. * @param newSnapPoint The new Snap-To point
  51297. */
  51298. addSnapPoint(newSnapPoint: Vector3): void;
  51299. attach(): boolean;
  51300. detach(): boolean;
  51301. dispose(): void;
  51302. /**
  51303. * Remove a mesh from the floor meshes array
  51304. * @param mesh the mesh to remove
  51305. */
  51306. removeFloorMesh(mesh: AbstractMesh): void;
  51307. /**
  51308. * Remove a mesh from the floor meshes array using its name
  51309. * @param name the mesh name to remove
  51310. */
  51311. removeFloorMeshByName(name: string): void;
  51312. /**
  51313. * 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
  51314. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51315. * @returns was the point found and removed or not
  51316. */
  51317. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51318. /**
  51319. * This function sets a selection feature that will be disabled when
  51320. * the forward ray is shown and will be reattached when hidden.
  51321. * This is used to remove the selection rays when moving.
  51322. * @param selectionFeature the feature to disable when forward movement is enabled
  51323. */
  51324. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  51325. protected _onXRFrame(_xrFrame: XRFrame): void;
  51326. private _attachController;
  51327. private _createDefaultTargetMesh;
  51328. private _detachController;
  51329. private _findClosestSnapPointWithRadius;
  51330. private _setTargetMeshPosition;
  51331. private _setTargetMeshVisibility;
  51332. private _showParabolicPath;
  51333. private _teleportForward;
  51334. }
  51335. }
  51336. declare module "babylonjs/XR/webXRDefaultExperience" {
  51337. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51338. import { Scene } from "babylonjs/scene";
  51339. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51340. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51341. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51342. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51344. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51345. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51346. /**
  51347. * Options for the default xr helper
  51348. */
  51349. export class WebXRDefaultExperienceOptions {
  51350. /**
  51351. * Enable or disable default UI to enter XR
  51352. */
  51353. disableDefaultUI?: boolean;
  51354. /**
  51355. * Should teleportation not initialize. defaults to false.
  51356. */
  51357. disableTeleportation?: boolean;
  51358. /**
  51359. * Floor meshes that will be used for teleport
  51360. */
  51361. floorMeshes?: Array<AbstractMesh>;
  51362. /**
  51363. * If set to true, the first frame will not be used to reset position
  51364. * The first frame is mainly used when copying transformation from the old camera
  51365. * Mainly used in AR
  51366. */
  51367. ignoreNativeCameraTransformation?: boolean;
  51368. /**
  51369. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51370. */
  51371. inputOptions?: IWebXRInputOptions;
  51372. /**
  51373. * optional configuration for the output canvas
  51374. */
  51375. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51376. /**
  51377. * optional UI options. This can be used among other to change session mode and reference space type
  51378. */
  51379. uiOptions?: WebXREnterExitUIOptions;
  51380. /**
  51381. * When loading teleportation and pointer select, use stable versions instead of latest.
  51382. */
  51383. useStablePlugins?: boolean;
  51384. /**
  51385. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51386. */
  51387. renderingGroupId?: number;
  51388. /**
  51389. * A list of optional features to init the session with
  51390. * If set to true, all features we support will be added
  51391. */
  51392. optionalFeatures?: boolean | string[];
  51393. }
  51394. /**
  51395. * Default experience which provides a similar setup to the previous webVRExperience
  51396. */
  51397. export class WebXRDefaultExperience {
  51398. /**
  51399. * Base experience
  51400. */
  51401. baseExperience: WebXRExperienceHelper;
  51402. /**
  51403. * Enables ui for entering/exiting xr
  51404. */
  51405. enterExitUI: WebXREnterExitUI;
  51406. /**
  51407. * Input experience extension
  51408. */
  51409. input: WebXRInput;
  51410. /**
  51411. * Enables laser pointer and selection
  51412. */
  51413. pointerSelection: WebXRControllerPointerSelection;
  51414. /**
  51415. * Default target xr should render to
  51416. */
  51417. renderTarget: WebXRRenderTarget;
  51418. /**
  51419. * Enables teleportation
  51420. */
  51421. teleportation: WebXRMotionControllerTeleportation;
  51422. private constructor();
  51423. /**
  51424. * Creates the default xr experience
  51425. * @param scene scene
  51426. * @param options options for basic configuration
  51427. * @returns resulting WebXRDefaultExperience
  51428. */
  51429. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51430. /**
  51431. * DIsposes of the experience helper
  51432. */
  51433. dispose(): void;
  51434. }
  51435. }
  51436. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51437. import { Observable } from "babylonjs/Misc/observable";
  51438. import { Nullable } from "babylonjs/types";
  51439. import { Camera } from "babylonjs/Cameras/camera";
  51440. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51441. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51442. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51443. import { Scene } from "babylonjs/scene";
  51444. import { Vector3 } from "babylonjs/Maths/math.vector";
  51445. import { Color3 } from "babylonjs/Maths/math.color";
  51446. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51448. import { Mesh } from "babylonjs/Meshes/mesh";
  51449. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51450. import { EasingFunction } from "babylonjs/Animations/easing";
  51451. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51452. import "babylonjs/Meshes/Builders/groundBuilder";
  51453. import "babylonjs/Meshes/Builders/torusBuilder";
  51454. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51455. import "babylonjs/Gamepads/gamepadSceneComponent";
  51456. import "babylonjs/Animations/animatable";
  51457. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51458. /**
  51459. * Options to modify the vr teleportation behavior.
  51460. */
  51461. export interface VRTeleportationOptions {
  51462. /**
  51463. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51464. */
  51465. floorMeshName?: string;
  51466. /**
  51467. * A list of meshes to be used as the teleportation floor. (default: empty)
  51468. */
  51469. floorMeshes?: Mesh[];
  51470. /**
  51471. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51472. */
  51473. teleportationMode?: number;
  51474. /**
  51475. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51476. */
  51477. teleportationTime?: number;
  51478. /**
  51479. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51480. */
  51481. teleportationSpeed?: number;
  51482. /**
  51483. * The easing function used in the animation or null for Linear. (default CircleEase)
  51484. */
  51485. easingFunction?: EasingFunction;
  51486. }
  51487. /**
  51488. * Options to modify the vr experience helper's behavior.
  51489. */
  51490. export interface VRExperienceHelperOptions extends WebVROptions {
  51491. /**
  51492. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51493. */
  51494. createDeviceOrientationCamera?: boolean;
  51495. /**
  51496. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51497. */
  51498. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51499. /**
  51500. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51501. */
  51502. laserToggle?: boolean;
  51503. /**
  51504. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51505. */
  51506. floorMeshes?: Mesh[];
  51507. /**
  51508. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51509. */
  51510. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51511. /**
  51512. * Defines if WebXR should be used instead of WebVR (if available)
  51513. */
  51514. useXR?: boolean;
  51515. }
  51516. /**
  51517. * Event containing information after VR has been entered
  51518. */
  51519. export class OnAfterEnteringVRObservableEvent {
  51520. /**
  51521. * If entering vr was successful
  51522. */
  51523. success: boolean;
  51524. }
  51525. /**
  51526. * Helps to quickly add VR support to an existing scene.
  51527. * See https://doc.babylonjs.com/how_to/webvr_helper
  51528. */
  51529. export class VRExperienceHelper {
  51530. /** Options to modify the vr experience helper's behavior. */
  51531. webVROptions: VRExperienceHelperOptions;
  51532. private _scene;
  51533. private _position;
  51534. private _btnVR;
  51535. private _btnVRDisplayed;
  51536. private _webVRsupported;
  51537. private _webVRready;
  51538. private _webVRrequesting;
  51539. private _webVRpresenting;
  51540. private _hasEnteredVR;
  51541. private _fullscreenVRpresenting;
  51542. private _inputElement;
  51543. private _webVRCamera;
  51544. private _vrDeviceOrientationCamera;
  51545. private _deviceOrientationCamera;
  51546. private _existingCamera;
  51547. private _onKeyDown;
  51548. private _onVrDisplayPresentChange;
  51549. private _onVRDisplayChanged;
  51550. private _onVRRequestPresentStart;
  51551. private _onVRRequestPresentComplete;
  51552. /**
  51553. * 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)
  51554. */
  51555. enableGazeEvenWhenNoPointerLock: boolean;
  51556. /**
  51557. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51558. */
  51559. exitVROnDoubleTap: boolean;
  51560. /**
  51561. * Observable raised right before entering VR.
  51562. */
  51563. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51564. /**
  51565. * Observable raised when entering VR has completed.
  51566. */
  51567. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51568. /**
  51569. * Observable raised when exiting VR.
  51570. */
  51571. onExitingVRObservable: Observable<VRExperienceHelper>;
  51572. /**
  51573. * Observable raised when controller mesh is loaded.
  51574. */
  51575. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51576. /** Return this.onEnteringVRObservable
  51577. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51578. */
  51579. get onEnteringVR(): Observable<VRExperienceHelper>;
  51580. /** Return this.onExitingVRObservable
  51581. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51582. */
  51583. get onExitingVR(): Observable<VRExperienceHelper>;
  51584. /** Return this.onControllerMeshLoadedObservable
  51585. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51586. */
  51587. get onControllerMeshLoaded(): Observable<WebVRController>;
  51588. private _rayLength;
  51589. private _useCustomVRButton;
  51590. private _teleportationRequested;
  51591. private _teleportActive;
  51592. private _floorMeshName;
  51593. private _floorMeshesCollection;
  51594. private _teleportationMode;
  51595. private _teleportationTime;
  51596. private _teleportationSpeed;
  51597. private _teleportationEasing;
  51598. private _rotationAllowed;
  51599. private _teleportBackwardsVector;
  51600. private _teleportationTarget;
  51601. private _isDefaultTeleportationTarget;
  51602. private _postProcessMove;
  51603. private _teleportationFillColor;
  51604. private _teleportationBorderColor;
  51605. private _rotationAngle;
  51606. private _haloCenter;
  51607. private _cameraGazer;
  51608. private _padSensibilityUp;
  51609. private _padSensibilityDown;
  51610. private _leftController;
  51611. private _rightController;
  51612. private _gazeColor;
  51613. private _laserColor;
  51614. private _pickedLaserColor;
  51615. private _pickedGazeColor;
  51616. /**
  51617. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51618. */
  51619. onNewMeshSelected: Observable<AbstractMesh>;
  51620. /**
  51621. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51622. * This observable will provide the mesh and the controller used to select the mesh
  51623. */
  51624. onMeshSelectedWithController: Observable<{
  51625. mesh: AbstractMesh;
  51626. controller: WebVRController;
  51627. }>;
  51628. /**
  51629. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51630. */
  51631. onNewMeshPicked: Observable<PickingInfo>;
  51632. private _circleEase;
  51633. /**
  51634. * Observable raised before camera teleportation
  51635. */
  51636. onBeforeCameraTeleport: Observable<Vector3>;
  51637. /**
  51638. * Observable raised after camera teleportation
  51639. */
  51640. onAfterCameraTeleport: Observable<Vector3>;
  51641. /**
  51642. * Observable raised when current selected mesh gets unselected
  51643. */
  51644. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51645. private _raySelectionPredicate;
  51646. /**
  51647. * To be optionaly changed by user to define custom ray selection
  51648. */
  51649. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51650. /**
  51651. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51652. */
  51653. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51654. /**
  51655. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51656. */
  51657. teleportationEnabled: boolean;
  51658. private _defaultHeight;
  51659. private _teleportationInitialized;
  51660. private _interactionsEnabled;
  51661. private _interactionsRequested;
  51662. private _displayGaze;
  51663. private _displayLaserPointer;
  51664. /**
  51665. * The mesh used to display where the user is going to teleport.
  51666. */
  51667. get teleportationTarget(): Mesh;
  51668. /**
  51669. * Sets the mesh to be used to display where the user is going to teleport.
  51670. */
  51671. set teleportationTarget(value: Mesh);
  51672. /**
  51673. * 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
  51674. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51675. * See https://doc.babylonjs.com/resources/baking_transformations
  51676. */
  51677. get gazeTrackerMesh(): Mesh;
  51678. set gazeTrackerMesh(value: Mesh);
  51679. /**
  51680. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51681. */
  51682. updateGazeTrackerScale: boolean;
  51683. /**
  51684. * If the gaze trackers color should be updated when selecting meshes
  51685. */
  51686. updateGazeTrackerColor: boolean;
  51687. /**
  51688. * If the controller laser color should be updated when selecting meshes
  51689. */
  51690. updateControllerLaserColor: boolean;
  51691. /**
  51692. * The gaze tracking mesh corresponding to the left controller
  51693. */
  51694. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51695. /**
  51696. * The gaze tracking mesh corresponding to the right controller
  51697. */
  51698. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51699. /**
  51700. * If the ray of the gaze should be displayed.
  51701. */
  51702. get displayGaze(): boolean;
  51703. /**
  51704. * Sets if the ray of the gaze should be displayed.
  51705. */
  51706. set displayGaze(value: boolean);
  51707. /**
  51708. * If the ray of the LaserPointer should be displayed.
  51709. */
  51710. get displayLaserPointer(): boolean;
  51711. /**
  51712. * Sets if the ray of the LaserPointer should be displayed.
  51713. */
  51714. set displayLaserPointer(value: boolean);
  51715. /**
  51716. * The deviceOrientationCamera used as the camera when not in VR.
  51717. */
  51718. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51719. /**
  51720. * Based on the current WebVR support, returns the current VR camera used.
  51721. */
  51722. get currentVRCamera(): Nullable<Camera>;
  51723. /**
  51724. * The webVRCamera which is used when in VR.
  51725. */
  51726. get webVRCamera(): WebVRFreeCamera;
  51727. /**
  51728. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51729. */
  51730. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51731. /**
  51732. * The html button that is used to trigger entering into VR.
  51733. */
  51734. get vrButton(): Nullable<HTMLButtonElement>;
  51735. private get _teleportationRequestInitiated();
  51736. /**
  51737. * Defines whether or not Pointer lock should be requested when switching to
  51738. * full screen.
  51739. */
  51740. requestPointerLockOnFullScreen: boolean;
  51741. /**
  51742. * If asking to force XR, this will be populated with the default xr experience
  51743. */
  51744. xr: WebXRDefaultExperience;
  51745. /**
  51746. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51747. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51748. */
  51749. xrTestDone: boolean;
  51750. /**
  51751. * Instantiates a VRExperienceHelper.
  51752. * Helps to quickly add VR support to an existing scene.
  51753. * @param scene The scene the VRExperienceHelper belongs to.
  51754. * @param webVROptions Options to modify the vr experience helper's behavior.
  51755. */
  51756. constructor(scene: Scene,
  51757. /** Options to modify the vr experience helper's behavior. */
  51758. webVROptions?: VRExperienceHelperOptions);
  51759. private completeVRInit;
  51760. private _onDefaultMeshLoaded;
  51761. private _onResize;
  51762. private _onFullscreenChange;
  51763. /**
  51764. * Gets a value indicating if we are currently in VR mode.
  51765. */
  51766. get isInVRMode(): boolean;
  51767. private onVrDisplayPresentChange;
  51768. private onVRDisplayChanged;
  51769. private moveButtonToBottomRight;
  51770. private displayVRButton;
  51771. private updateButtonVisibility;
  51772. private _cachedAngularSensibility;
  51773. /**
  51774. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51775. * Otherwise, will use the fullscreen API.
  51776. */
  51777. enterVR(): void;
  51778. /**
  51779. * Attempt to exit VR, or fullscreen.
  51780. */
  51781. exitVR(): void;
  51782. /**
  51783. * The position of the vr experience helper.
  51784. */
  51785. get position(): Vector3;
  51786. /**
  51787. * Sets the position of the vr experience helper.
  51788. */
  51789. set position(value: Vector3);
  51790. /**
  51791. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51792. */
  51793. enableInteractions(): void;
  51794. private get _noControllerIsActive();
  51795. private beforeRender;
  51796. private _isTeleportationFloor;
  51797. /**
  51798. * Adds a floor mesh to be used for teleportation.
  51799. * @param floorMesh the mesh to be used for teleportation.
  51800. */
  51801. addFloorMesh(floorMesh: Mesh): void;
  51802. /**
  51803. * Removes a floor mesh from being used for teleportation.
  51804. * @param floorMesh the mesh to be removed.
  51805. */
  51806. removeFloorMesh(floorMesh: Mesh): void;
  51807. /**
  51808. * Enables interactions and teleportation using the VR controllers and gaze.
  51809. * @param vrTeleportationOptions options to modify teleportation behavior.
  51810. */
  51811. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51812. private _onNewGamepadConnected;
  51813. private _tryEnableInteractionOnController;
  51814. private _onNewGamepadDisconnected;
  51815. private _enableInteractionOnController;
  51816. private _checkTeleportWithRay;
  51817. private _checkRotate;
  51818. private _checkTeleportBackwards;
  51819. private _enableTeleportationOnController;
  51820. private _createTeleportationCircles;
  51821. private _displayTeleportationTarget;
  51822. private _hideTeleportationTarget;
  51823. private _rotateCamera;
  51824. private _moveTeleportationSelectorTo;
  51825. private _workingVector;
  51826. private _workingQuaternion;
  51827. private _workingMatrix;
  51828. /**
  51829. * Time Constant Teleportation Mode
  51830. */
  51831. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  51832. /**
  51833. * Speed Constant Teleportation Mode
  51834. */
  51835. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  51836. /**
  51837. * Teleports the users feet to the desired location
  51838. * @param location The location where the user's feet should be placed
  51839. */
  51840. teleportCamera(location: Vector3): void;
  51841. private _convertNormalToDirectionOfRay;
  51842. private _castRayAndSelectObject;
  51843. private _notifySelectedMeshUnselected;
  51844. /**
  51845. * Permanently set new colors for the laser pointer
  51846. * @param color the new laser color
  51847. * @param pickedColor the new laser color when picked mesh detected
  51848. */
  51849. setLaserColor(color: Color3, pickedColor?: Color3): void;
  51850. /**
  51851. * Set lighting enabled / disabled on the laser pointer of both controllers
  51852. * @param enabled should the lighting be enabled on the laser pointer
  51853. */
  51854. setLaserLightingState(enabled?: boolean): void;
  51855. /**
  51856. * Permanently set new colors for the gaze pointer
  51857. * @param color the new gaze color
  51858. * @param pickedColor the new gaze color when picked mesh detected
  51859. */
  51860. setGazeColor(color: Color3, pickedColor?: Color3): void;
  51861. /**
  51862. * Sets the color of the laser ray from the vr controllers.
  51863. * @param color new color for the ray.
  51864. */
  51865. changeLaserColor(color: Color3): void;
  51866. /**
  51867. * Sets the color of the ray from the vr headsets gaze.
  51868. * @param color new color for the ray.
  51869. */
  51870. changeGazeColor(color: Color3): void;
  51871. /**
  51872. * Exits VR and disposes of the vr experience helper
  51873. */
  51874. dispose(): void;
  51875. /**
  51876. * Gets the name of the VRExperienceHelper class
  51877. * @returns "VRExperienceHelper"
  51878. */
  51879. getClassName(): string;
  51880. }
  51881. }
  51882. declare module "babylonjs/Cameras/VR/index" {
  51883. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  51884. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  51885. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51886. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  51887. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  51888. export * from "babylonjs/Cameras/VR/webVRCamera";
  51889. }
  51890. declare module "babylonjs/Cameras/RigModes/index" {
  51891. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51892. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51893. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  51894. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  51895. }
  51896. declare module "babylonjs/Cameras/index" {
  51897. export * from "babylonjs/Cameras/Inputs/index";
  51898. export * from "babylonjs/Cameras/cameraInputsManager";
  51899. export * from "babylonjs/Cameras/camera";
  51900. export * from "babylonjs/Cameras/targetCamera";
  51901. export * from "babylonjs/Cameras/freeCamera";
  51902. export * from "babylonjs/Cameras/freeCameraInputsManager";
  51903. export * from "babylonjs/Cameras/touchCamera";
  51904. export * from "babylonjs/Cameras/arcRotateCamera";
  51905. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51906. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51907. export * from "babylonjs/Cameras/flyCamera";
  51908. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51909. export * from "babylonjs/Cameras/followCamera";
  51910. export * from "babylonjs/Cameras/followCameraInputsManager";
  51911. export * from "babylonjs/Cameras/gamepadCamera";
  51912. export * from "babylonjs/Cameras/Stereoscopic/index";
  51913. export * from "babylonjs/Cameras/universalCamera";
  51914. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51915. export * from "babylonjs/Cameras/VR/index";
  51916. export * from "babylonjs/Cameras/RigModes/index";
  51917. }
  51918. declare module "babylonjs/Collisions/index" {
  51919. export * from "babylonjs/Collisions/collider";
  51920. export * from "babylonjs/Collisions/collisionCoordinator";
  51921. export * from "babylonjs/Collisions/pickingInfo";
  51922. export * from "babylonjs/Collisions/intersectionInfo";
  51923. export * from "babylonjs/Collisions/meshCollisionData";
  51924. }
  51925. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51926. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51927. import { Vector3 } from "babylonjs/Maths/math.vector";
  51928. import { Ray } from "babylonjs/Culling/ray";
  51929. import { Plane } from "babylonjs/Maths/math.plane";
  51930. /**
  51931. * Contains an array of blocks representing the octree
  51932. */
  51933. export interface IOctreeContainer<T> {
  51934. /**
  51935. * Blocks within the octree
  51936. */
  51937. blocks: Array<OctreeBlock<T>>;
  51938. }
  51939. /**
  51940. * Class used to store a cell in an octree
  51941. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51942. */
  51943. export class OctreeBlock<T> {
  51944. /**
  51945. * Gets the content of the current block
  51946. */
  51947. entries: T[];
  51948. /**
  51949. * Gets the list of block children
  51950. */
  51951. blocks: Array<OctreeBlock<T>>;
  51952. private _depth;
  51953. private _maxDepth;
  51954. private _capacity;
  51955. private _minPoint;
  51956. private _maxPoint;
  51957. private _boundingVectors;
  51958. private _creationFunc;
  51959. /**
  51960. * Creates a new block
  51961. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  51962. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  51963. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51964. * @param depth defines the current depth of this block in the octree
  51965. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  51966. * @param creationFunc defines a callback to call when an element is added to the block
  51967. */
  51968. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  51969. /**
  51970. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51971. */
  51972. get capacity(): number;
  51973. /**
  51974. * Gets the minimum vector (in world space) of the block's bounding box
  51975. */
  51976. get minPoint(): Vector3;
  51977. /**
  51978. * Gets the maximum vector (in world space) of the block's bounding box
  51979. */
  51980. get maxPoint(): Vector3;
  51981. /**
  51982. * Add a new element to this block
  51983. * @param entry defines the element to add
  51984. */
  51985. addEntry(entry: T): void;
  51986. /**
  51987. * Remove an element from this block
  51988. * @param entry defines the element to remove
  51989. */
  51990. removeEntry(entry: T): void;
  51991. /**
  51992. * Add an array of elements to this block
  51993. * @param entries defines the array of elements to add
  51994. */
  51995. addEntries(entries: T[]): void;
  51996. /**
  51997. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  51998. * @param frustumPlanes defines the frustum planes to test
  51999. * @param selection defines the array to store current content if selection is positive
  52000. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52001. */
  52002. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52003. /**
  52004. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  52005. * @param sphereCenter defines the bounding sphere center
  52006. * @param sphereRadius defines the bounding sphere radius
  52007. * @param selection defines the array to store current content if selection is positive
  52008. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52009. */
  52010. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52011. /**
  52012. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  52013. * @param ray defines the ray to test with
  52014. * @param selection defines the array to store current content if selection is positive
  52015. */
  52016. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  52017. /**
  52018. * Subdivide the content into child blocks (this block will then be empty)
  52019. */
  52020. createInnerBlocks(): void;
  52021. /**
  52022. * @hidden
  52023. */
  52024. 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;
  52025. }
  52026. }
  52027. declare module "babylonjs/Culling/Octrees/octree" {
  52028. import { SmartArray } from "babylonjs/Misc/smartArray";
  52029. import { Vector3 } from "babylonjs/Maths/math.vector";
  52030. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52032. import { Ray } from "babylonjs/Culling/ray";
  52033. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  52034. import { Plane } from "babylonjs/Maths/math.plane";
  52035. /**
  52036. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  52037. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52038. */
  52039. export class Octree<T> {
  52040. /** 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.) */
  52041. maxDepth: number;
  52042. /**
  52043. * Blocks within the octree containing objects
  52044. */
  52045. blocks: Array<OctreeBlock<T>>;
  52046. /**
  52047. * Content stored in the octree
  52048. */
  52049. dynamicContent: T[];
  52050. private _maxBlockCapacity;
  52051. private _selectionContent;
  52052. private _creationFunc;
  52053. /**
  52054. * Creates a octree
  52055. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52056. * @param creationFunc function to be used to instatiate the octree
  52057. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52058. * @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.)
  52059. */
  52060. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52061. /** 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.) */
  52062. maxDepth?: number);
  52063. /**
  52064. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52065. * @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);
  52066. * @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);
  52067. * @param entries meshes to be added to the octree blocks
  52068. */
  52069. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52070. /**
  52071. * Adds a mesh to the octree
  52072. * @param entry Mesh to add to the octree
  52073. */
  52074. addMesh(entry: T): void;
  52075. /**
  52076. * Remove an element from the octree
  52077. * @param entry defines the element to remove
  52078. */
  52079. removeMesh(entry: T): void;
  52080. /**
  52081. * Selects an array of meshes within the frustum
  52082. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52083. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52084. * @returns array of meshes within the frustum
  52085. */
  52086. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52087. /**
  52088. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52089. * @param sphereCenter defines the bounding sphere center
  52090. * @param sphereRadius defines the bounding sphere radius
  52091. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52092. * @returns an array of objects that intersect the sphere
  52093. */
  52094. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52095. /**
  52096. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52097. * @param ray defines the ray to test with
  52098. * @returns array of intersected objects
  52099. */
  52100. intersectsRay(ray: Ray): SmartArray<T>;
  52101. /**
  52102. * Adds a mesh into the octree block if it intersects the block
  52103. */
  52104. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52105. /**
  52106. * Adds a submesh into the octree block if it intersects the block
  52107. */
  52108. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52109. }
  52110. }
  52111. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52112. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52113. import { Scene } from "babylonjs/scene";
  52114. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52116. import { Ray } from "babylonjs/Culling/ray";
  52117. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52118. import { Collider } from "babylonjs/Collisions/collider";
  52119. module "babylonjs/scene" {
  52120. interface Scene {
  52121. /**
  52122. * @hidden
  52123. * Backing Filed
  52124. */
  52125. _selectionOctree: Octree<AbstractMesh>;
  52126. /**
  52127. * Gets the octree used to boost mesh selection (picking)
  52128. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52129. */
  52130. selectionOctree: Octree<AbstractMesh>;
  52131. /**
  52132. * Creates or updates the octree used to boost selection (picking)
  52133. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52134. * @param maxCapacity defines the maximum capacity per leaf
  52135. * @param maxDepth defines the maximum depth of the octree
  52136. * @returns an octree of AbstractMesh
  52137. */
  52138. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52139. }
  52140. }
  52141. module "babylonjs/Meshes/abstractMesh" {
  52142. interface AbstractMesh {
  52143. /**
  52144. * @hidden
  52145. * Backing Field
  52146. */
  52147. _submeshesOctree: Octree<SubMesh>;
  52148. /**
  52149. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52150. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52151. * @param maxCapacity defines the maximum size of each block (64 by default)
  52152. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52153. * @returns the new octree
  52154. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52155. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52156. */
  52157. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52158. }
  52159. }
  52160. /**
  52161. * Defines the octree scene component responsible to manage any octrees
  52162. * in a given scene.
  52163. */
  52164. export class OctreeSceneComponent {
  52165. /**
  52166. * The component name help to identify the component in the list of scene components.
  52167. */
  52168. readonly name: string;
  52169. /**
  52170. * The scene the component belongs to.
  52171. */
  52172. scene: Scene;
  52173. /**
  52174. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52175. */
  52176. readonly checksIsEnabled: boolean;
  52177. /**
  52178. * Creates a new instance of the component for the given scene
  52179. * @param scene Defines the scene to register the component in
  52180. */
  52181. constructor(scene: Scene);
  52182. /**
  52183. * Registers the component in a given scene
  52184. */
  52185. register(): void;
  52186. /**
  52187. * Return the list of active meshes
  52188. * @returns the list of active meshes
  52189. */
  52190. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52191. /**
  52192. * Return the list of active sub meshes
  52193. * @param mesh The mesh to get the candidates sub meshes from
  52194. * @returns the list of active sub meshes
  52195. */
  52196. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52197. private _tempRay;
  52198. /**
  52199. * Return the list of sub meshes intersecting with a given local ray
  52200. * @param mesh defines the mesh to find the submesh for
  52201. * @param localRay defines the ray in local space
  52202. * @returns the list of intersecting sub meshes
  52203. */
  52204. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52205. /**
  52206. * Return the list of sub meshes colliding with a collider
  52207. * @param mesh defines the mesh to find the submesh for
  52208. * @param collider defines the collider to evaluate the collision against
  52209. * @returns the list of colliding sub meshes
  52210. */
  52211. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52212. /**
  52213. * Rebuilds the elements related to this component in case of
  52214. * context lost for instance.
  52215. */
  52216. rebuild(): void;
  52217. /**
  52218. * Disposes the component and the associated ressources.
  52219. */
  52220. dispose(): void;
  52221. }
  52222. }
  52223. declare module "babylonjs/Culling/Octrees/index" {
  52224. export * from "babylonjs/Culling/Octrees/octree";
  52225. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52226. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52227. }
  52228. declare module "babylonjs/Culling/index" {
  52229. export * from "babylonjs/Culling/boundingBox";
  52230. export * from "babylonjs/Culling/boundingInfo";
  52231. export * from "babylonjs/Culling/boundingSphere";
  52232. export * from "babylonjs/Culling/Octrees/index";
  52233. export * from "babylonjs/Culling/ray";
  52234. }
  52235. declare module "babylonjs/Gizmos/gizmo" {
  52236. import { Nullable } from "babylonjs/types";
  52237. import { IDisposable } from "babylonjs/scene";
  52238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52239. import { Mesh } from "babylonjs/Meshes/mesh";
  52240. import { Node } from "babylonjs/node";
  52241. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52242. /**
  52243. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52244. */
  52245. export class Gizmo implements IDisposable {
  52246. /** The utility layer the gizmo will be added to */
  52247. gizmoLayer: UtilityLayerRenderer;
  52248. /**
  52249. * The root mesh of the gizmo
  52250. */
  52251. _rootMesh: Mesh;
  52252. private _attachedMesh;
  52253. private _attachedNode;
  52254. /**
  52255. * Ratio for the scale of the gizmo (Default: 1)
  52256. */
  52257. scaleRatio: number;
  52258. /**
  52259. * If a custom mesh has been set (Default: false)
  52260. */
  52261. protected _customMeshSet: boolean;
  52262. /**
  52263. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52264. * * When set, interactions will be enabled
  52265. */
  52266. get attachedMesh(): Nullable<AbstractMesh>;
  52267. set attachedMesh(value: Nullable<AbstractMesh>);
  52268. /**
  52269. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52270. * * When set, interactions will be enabled
  52271. */
  52272. get attachedNode(): Nullable<Node>;
  52273. set attachedNode(value: Nullable<Node>);
  52274. /**
  52275. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52276. * @param mesh The mesh to replace the default mesh of the gizmo
  52277. */
  52278. setCustomMesh(mesh: Mesh): void;
  52279. /**
  52280. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52281. */
  52282. updateGizmoRotationToMatchAttachedMesh: boolean;
  52283. /**
  52284. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52285. */
  52286. updateGizmoPositionToMatchAttachedMesh: boolean;
  52287. /**
  52288. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52289. */
  52290. updateScale: boolean;
  52291. protected _interactionsEnabled: boolean;
  52292. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52293. private _beforeRenderObserver;
  52294. private _tempQuaternion;
  52295. private _tempVector;
  52296. private _tempVector2;
  52297. /**
  52298. * Creates a gizmo
  52299. * @param gizmoLayer The utility layer the gizmo will be added to
  52300. */
  52301. constructor(
  52302. /** The utility layer the gizmo will be added to */
  52303. gizmoLayer?: UtilityLayerRenderer);
  52304. /**
  52305. * Updates the gizmo to match the attached mesh's position/rotation
  52306. */
  52307. protected _update(): void;
  52308. /**
  52309. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52310. * @param value Node, TransformNode or mesh
  52311. */
  52312. protected _matrixChanged(): void;
  52313. /**
  52314. * Disposes of the gizmo
  52315. */
  52316. dispose(): void;
  52317. }
  52318. }
  52319. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52320. import { Observable } from "babylonjs/Misc/observable";
  52321. import { Nullable } from "babylonjs/types";
  52322. import { Vector3 } from "babylonjs/Maths/math.vector";
  52323. import { Color3 } from "babylonjs/Maths/math.color";
  52324. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52325. import { Node } from "babylonjs/node";
  52326. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52327. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52328. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52329. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52330. import { Scene } from "babylonjs/scene";
  52331. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52332. /**
  52333. * Single plane drag gizmo
  52334. */
  52335. export class PlaneDragGizmo extends Gizmo {
  52336. /**
  52337. * Drag behavior responsible for the gizmos dragging interactions
  52338. */
  52339. dragBehavior: PointerDragBehavior;
  52340. private _pointerObserver;
  52341. /**
  52342. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52343. */
  52344. snapDistance: number;
  52345. /**
  52346. * Event that fires each time the gizmo snaps to a new location.
  52347. * * snapDistance is the the change in distance
  52348. */
  52349. onSnapObservable: Observable<{
  52350. snapDistance: number;
  52351. }>;
  52352. private _plane;
  52353. private _coloredMaterial;
  52354. private _hoverMaterial;
  52355. private _isEnabled;
  52356. private _parent;
  52357. /** @hidden */
  52358. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52359. /** @hidden */
  52360. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52361. /**
  52362. * Creates a PlaneDragGizmo
  52363. * @param gizmoLayer The utility layer the gizmo will be added to
  52364. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52365. * @param color The color of the gizmo
  52366. */
  52367. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52368. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52369. /**
  52370. * If the gizmo is enabled
  52371. */
  52372. set isEnabled(value: boolean);
  52373. get isEnabled(): boolean;
  52374. /**
  52375. * Disposes of the gizmo
  52376. */
  52377. dispose(): void;
  52378. }
  52379. }
  52380. declare module "babylonjs/Gizmos/positionGizmo" {
  52381. import { Observable } from "babylonjs/Misc/observable";
  52382. import { Nullable } from "babylonjs/types";
  52383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52384. import { Node } from "babylonjs/node";
  52385. import { Mesh } from "babylonjs/Meshes/mesh";
  52386. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52387. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52388. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52389. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52390. /**
  52391. * Gizmo that enables dragging a mesh along 3 axis
  52392. */
  52393. export class PositionGizmo extends Gizmo {
  52394. /**
  52395. * Internal gizmo used for interactions on the x axis
  52396. */
  52397. xGizmo: AxisDragGizmo;
  52398. /**
  52399. * Internal gizmo used for interactions on the y axis
  52400. */
  52401. yGizmo: AxisDragGizmo;
  52402. /**
  52403. * Internal gizmo used for interactions on the z axis
  52404. */
  52405. zGizmo: AxisDragGizmo;
  52406. /**
  52407. * Internal gizmo used for interactions on the yz plane
  52408. */
  52409. xPlaneGizmo: PlaneDragGizmo;
  52410. /**
  52411. * Internal gizmo used for interactions on the xz plane
  52412. */
  52413. yPlaneGizmo: PlaneDragGizmo;
  52414. /**
  52415. * Internal gizmo used for interactions on the xy plane
  52416. */
  52417. zPlaneGizmo: PlaneDragGizmo;
  52418. /**
  52419. * private variables
  52420. */
  52421. private _meshAttached;
  52422. private _nodeAttached;
  52423. private _updateGizmoRotationToMatchAttachedMesh;
  52424. private _snapDistance;
  52425. private _scaleRatio;
  52426. /** Fires an event when any of it's sub gizmos are dragged */
  52427. onDragStartObservable: Observable<unknown>;
  52428. /** Fires an event when any of it's sub gizmos are released from dragging */
  52429. onDragEndObservable: Observable<unknown>;
  52430. /**
  52431. * If set to true, planar drag is enabled
  52432. */
  52433. private _planarGizmoEnabled;
  52434. get attachedMesh(): Nullable<AbstractMesh>;
  52435. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52436. get attachedNode(): Nullable<Node>;
  52437. set attachedNode(node: Nullable<Node>);
  52438. /**
  52439. * Creates a PositionGizmo
  52440. * @param gizmoLayer The utility layer the gizmo will be added to
  52441. @param thickness display gizmo axis thickness
  52442. */
  52443. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52444. /**
  52445. * If the planar drag gizmo is enabled
  52446. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52447. */
  52448. set planarGizmoEnabled(value: boolean);
  52449. get planarGizmoEnabled(): boolean;
  52450. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52451. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52452. /**
  52453. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52454. */
  52455. set snapDistance(value: number);
  52456. get snapDistance(): number;
  52457. /**
  52458. * Ratio for the scale of the gizmo (Default: 1)
  52459. */
  52460. set scaleRatio(value: number);
  52461. get scaleRatio(): number;
  52462. /**
  52463. * Disposes of the gizmo
  52464. */
  52465. dispose(): void;
  52466. /**
  52467. * CustomMeshes are not supported by this gizmo
  52468. * @param mesh The mesh to replace the default mesh of the gizmo
  52469. */
  52470. setCustomMesh(mesh: Mesh): void;
  52471. }
  52472. }
  52473. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52474. import { Observable } from "babylonjs/Misc/observable";
  52475. import { Nullable } from "babylonjs/types";
  52476. import { Vector3 } from "babylonjs/Maths/math.vector";
  52477. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52478. import { Node } from "babylonjs/node";
  52479. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52480. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52481. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52482. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52483. import { Scene } from "babylonjs/scene";
  52484. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52485. import { Color3 } from "babylonjs/Maths/math.color";
  52486. /**
  52487. * Single axis drag gizmo
  52488. */
  52489. export class AxisDragGizmo extends Gizmo {
  52490. /**
  52491. * Drag behavior responsible for the gizmos dragging interactions
  52492. */
  52493. dragBehavior: PointerDragBehavior;
  52494. private _pointerObserver;
  52495. /**
  52496. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52497. */
  52498. snapDistance: number;
  52499. /**
  52500. * Event that fires each time the gizmo snaps to a new location.
  52501. * * snapDistance is the the change in distance
  52502. */
  52503. onSnapObservable: Observable<{
  52504. snapDistance: number;
  52505. }>;
  52506. private _isEnabled;
  52507. private _parent;
  52508. private _arrow;
  52509. private _coloredMaterial;
  52510. private _hoverMaterial;
  52511. /** @hidden */
  52512. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52513. /** @hidden */
  52514. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52515. /**
  52516. * Creates an AxisDragGizmo
  52517. * @param gizmoLayer The utility layer the gizmo will be added to
  52518. * @param dragAxis The axis which the gizmo will be able to drag on
  52519. * @param color The color of the gizmo
  52520. * @param thickness display gizmo axis thickness
  52521. */
  52522. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52523. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52524. /**
  52525. * If the gizmo is enabled
  52526. */
  52527. set isEnabled(value: boolean);
  52528. get isEnabled(): boolean;
  52529. /**
  52530. * Disposes of the gizmo
  52531. */
  52532. dispose(): void;
  52533. }
  52534. }
  52535. declare module "babylonjs/Debug/axesViewer" {
  52536. import { Vector3 } from "babylonjs/Maths/math.vector";
  52537. import { Nullable } from "babylonjs/types";
  52538. import { Scene } from "babylonjs/scene";
  52539. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52540. /**
  52541. * The Axes viewer will show 3 axes in a specific point in space
  52542. */
  52543. export class AxesViewer {
  52544. private _xAxis;
  52545. private _yAxis;
  52546. private _zAxis;
  52547. private _scaleLinesFactor;
  52548. private _instanced;
  52549. /**
  52550. * Gets the hosting scene
  52551. */
  52552. scene: Scene;
  52553. /**
  52554. * Gets or sets a number used to scale line length
  52555. */
  52556. scaleLines: number;
  52557. /** Gets the node hierarchy used to render x-axis */
  52558. get xAxis(): TransformNode;
  52559. /** Gets the node hierarchy used to render y-axis */
  52560. get yAxis(): TransformNode;
  52561. /** Gets the node hierarchy used to render z-axis */
  52562. get zAxis(): TransformNode;
  52563. /**
  52564. * Creates a new AxesViewer
  52565. * @param scene defines the hosting scene
  52566. * @param scaleLines defines a number used to scale line length (1 by default)
  52567. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52568. * @param xAxis defines the node hierarchy used to render the x-axis
  52569. * @param yAxis defines the node hierarchy used to render the y-axis
  52570. * @param zAxis defines the node hierarchy used to render the z-axis
  52571. */
  52572. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52573. /**
  52574. * Force the viewer to update
  52575. * @param position defines the position of the viewer
  52576. * @param xaxis defines the x axis of the viewer
  52577. * @param yaxis defines the y axis of the viewer
  52578. * @param zaxis defines the z axis of the viewer
  52579. */
  52580. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52581. /**
  52582. * Creates an instance of this axes viewer.
  52583. * @returns a new axes viewer with instanced meshes
  52584. */
  52585. createInstance(): AxesViewer;
  52586. /** Releases resources */
  52587. dispose(): void;
  52588. private static _SetRenderingGroupId;
  52589. }
  52590. }
  52591. declare module "babylonjs/Debug/boneAxesViewer" {
  52592. import { Nullable } from "babylonjs/types";
  52593. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52594. import { Vector3 } from "babylonjs/Maths/math.vector";
  52595. import { Mesh } from "babylonjs/Meshes/mesh";
  52596. import { Bone } from "babylonjs/Bones/bone";
  52597. import { Scene } from "babylonjs/scene";
  52598. /**
  52599. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52600. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52601. */
  52602. export class BoneAxesViewer extends AxesViewer {
  52603. /**
  52604. * Gets or sets the target mesh where to display the axes viewer
  52605. */
  52606. mesh: Nullable<Mesh>;
  52607. /**
  52608. * Gets or sets the target bone where to display the axes viewer
  52609. */
  52610. bone: Nullable<Bone>;
  52611. /** Gets current position */
  52612. pos: Vector3;
  52613. /** Gets direction of X axis */
  52614. xaxis: Vector3;
  52615. /** Gets direction of Y axis */
  52616. yaxis: Vector3;
  52617. /** Gets direction of Z axis */
  52618. zaxis: Vector3;
  52619. /**
  52620. * Creates a new BoneAxesViewer
  52621. * @param scene defines the hosting scene
  52622. * @param bone defines the target bone
  52623. * @param mesh defines the target mesh
  52624. * @param scaleLines defines a scaling factor for line length (1 by default)
  52625. */
  52626. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52627. /**
  52628. * Force the viewer to update
  52629. */
  52630. update(): void;
  52631. /** Releases resources */
  52632. dispose(): void;
  52633. }
  52634. }
  52635. declare module "babylonjs/Debug/debugLayer" {
  52636. import { Scene } from "babylonjs/scene";
  52637. /**
  52638. * Interface used to define scene explorer extensibility option
  52639. */
  52640. export interface IExplorerExtensibilityOption {
  52641. /**
  52642. * Define the option label
  52643. */
  52644. label: string;
  52645. /**
  52646. * Defines the action to execute on click
  52647. */
  52648. action: (entity: any) => void;
  52649. }
  52650. /**
  52651. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52652. */
  52653. export interface IExplorerExtensibilityGroup {
  52654. /**
  52655. * Defines a predicate to test if a given type mut be extended
  52656. */
  52657. predicate: (entity: any) => boolean;
  52658. /**
  52659. * Gets the list of options added to a type
  52660. */
  52661. entries: IExplorerExtensibilityOption[];
  52662. }
  52663. /**
  52664. * Interface used to define the options to use to create the Inspector
  52665. */
  52666. export interface IInspectorOptions {
  52667. /**
  52668. * Display in overlay mode (default: false)
  52669. */
  52670. overlay?: boolean;
  52671. /**
  52672. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52673. */
  52674. globalRoot?: HTMLElement;
  52675. /**
  52676. * Display the Scene explorer
  52677. */
  52678. showExplorer?: boolean;
  52679. /**
  52680. * Display the property inspector
  52681. */
  52682. showInspector?: boolean;
  52683. /**
  52684. * Display in embed mode (both panes on the right)
  52685. */
  52686. embedMode?: boolean;
  52687. /**
  52688. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52689. */
  52690. handleResize?: boolean;
  52691. /**
  52692. * Allow the panes to popup (default: true)
  52693. */
  52694. enablePopup?: boolean;
  52695. /**
  52696. * Allow the panes to be closed by users (default: true)
  52697. */
  52698. enableClose?: boolean;
  52699. /**
  52700. * Optional list of extensibility entries
  52701. */
  52702. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52703. /**
  52704. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52705. */
  52706. inspectorURL?: string;
  52707. /**
  52708. * Optional initial tab (default to DebugLayerTab.Properties)
  52709. */
  52710. initialTab?: DebugLayerTab;
  52711. }
  52712. module "babylonjs/scene" {
  52713. interface Scene {
  52714. /**
  52715. * @hidden
  52716. * Backing field
  52717. */
  52718. _debugLayer: DebugLayer;
  52719. /**
  52720. * Gets the debug layer (aka Inspector) associated with the scene
  52721. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52722. */
  52723. debugLayer: DebugLayer;
  52724. }
  52725. }
  52726. /**
  52727. * Enum of inspector action tab
  52728. */
  52729. export enum DebugLayerTab {
  52730. /**
  52731. * Properties tag (default)
  52732. */
  52733. Properties = 0,
  52734. /**
  52735. * Debug tab
  52736. */
  52737. Debug = 1,
  52738. /**
  52739. * Statistics tab
  52740. */
  52741. Statistics = 2,
  52742. /**
  52743. * Tools tab
  52744. */
  52745. Tools = 3,
  52746. /**
  52747. * Settings tab
  52748. */
  52749. Settings = 4
  52750. }
  52751. /**
  52752. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52753. * what is happening in your scene
  52754. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52755. */
  52756. export class DebugLayer {
  52757. /**
  52758. * Define the url to get the inspector script from.
  52759. * By default it uses the babylonjs CDN.
  52760. * @ignoreNaming
  52761. */
  52762. static InspectorURL: string;
  52763. private _scene;
  52764. private BJSINSPECTOR;
  52765. private _onPropertyChangedObservable?;
  52766. /**
  52767. * Observable triggered when a property is changed through the inspector.
  52768. */
  52769. get onPropertyChangedObservable(): any;
  52770. /**
  52771. * Instantiates a new debug layer.
  52772. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52773. * what is happening in your scene
  52774. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52775. * @param scene Defines the scene to inspect
  52776. */
  52777. constructor(scene: Scene);
  52778. /** Creates the inspector window. */
  52779. private _createInspector;
  52780. /**
  52781. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52782. * @param entity defines the entity to select
  52783. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52784. */
  52785. select(entity: any, lineContainerTitles?: string | string[]): void;
  52786. /** Get the inspector from bundle or global */
  52787. private _getGlobalInspector;
  52788. /**
  52789. * Get if the inspector is visible or not.
  52790. * @returns true if visible otherwise, false
  52791. */
  52792. isVisible(): boolean;
  52793. /**
  52794. * Hide the inspector and close its window.
  52795. */
  52796. hide(): void;
  52797. /**
  52798. * Update the scene in the inspector
  52799. */
  52800. setAsActiveScene(): void;
  52801. /**
  52802. * Launch the debugLayer.
  52803. * @param config Define the configuration of the inspector
  52804. * @return a promise fulfilled when the debug layer is visible
  52805. */
  52806. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52807. }
  52808. }
  52809. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52810. import { Nullable } from "babylonjs/types";
  52811. import { Scene } from "babylonjs/scene";
  52812. import { Vector4 } from "babylonjs/Maths/math.vector";
  52813. import { Color4 } from "babylonjs/Maths/math.color";
  52814. import { Mesh } from "babylonjs/Meshes/mesh";
  52815. /**
  52816. * Class containing static functions to help procedurally build meshes
  52817. */
  52818. export class BoxBuilder {
  52819. /**
  52820. * Creates a box mesh
  52821. * * The parameter `size` sets the size (float) of each box side (default 1)
  52822. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52823. * * 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)
  52824. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52828. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52829. * @param name defines the name of the mesh
  52830. * @param options defines the options used to create the mesh
  52831. * @param scene defines the hosting scene
  52832. * @returns the box mesh
  52833. */
  52834. static CreateBox(name: string, options: {
  52835. size?: number;
  52836. width?: number;
  52837. height?: number;
  52838. depth?: number;
  52839. faceUV?: Vector4[];
  52840. faceColors?: Color4[];
  52841. sideOrientation?: number;
  52842. frontUVs?: Vector4;
  52843. backUVs?: Vector4;
  52844. wrap?: boolean;
  52845. topBaseAt?: number;
  52846. bottomBaseAt?: number;
  52847. updatable?: boolean;
  52848. }, scene?: Nullable<Scene>): Mesh;
  52849. }
  52850. }
  52851. declare module "babylonjs/Debug/physicsViewer" {
  52852. import { Nullable } from "babylonjs/types";
  52853. import { Scene } from "babylonjs/scene";
  52854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52855. import { Mesh } from "babylonjs/Meshes/mesh";
  52856. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52857. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52858. /**
  52859. * Used to show the physics impostor around the specific mesh
  52860. */
  52861. export class PhysicsViewer {
  52862. /** @hidden */
  52863. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  52864. /** @hidden */
  52865. protected _meshes: Array<Nullable<AbstractMesh>>;
  52866. /** @hidden */
  52867. protected _scene: Nullable<Scene>;
  52868. /** @hidden */
  52869. protected _numMeshes: number;
  52870. /** @hidden */
  52871. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  52872. private _renderFunction;
  52873. private _utilityLayer;
  52874. private _debugBoxMesh;
  52875. private _debugSphereMesh;
  52876. private _debugCylinderMesh;
  52877. private _debugMaterial;
  52878. private _debugMeshMeshes;
  52879. /**
  52880. * Creates a new PhysicsViewer
  52881. * @param scene defines the hosting scene
  52882. */
  52883. constructor(scene: Scene);
  52884. /** @hidden */
  52885. protected _updateDebugMeshes(): void;
  52886. /**
  52887. * Renders a specified physic impostor
  52888. * @param impostor defines the impostor to render
  52889. * @param targetMesh defines the mesh represented by the impostor
  52890. * @returns the new debug mesh used to render the impostor
  52891. */
  52892. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  52893. /**
  52894. * Hides a specified physic impostor
  52895. * @param impostor defines the impostor to hide
  52896. */
  52897. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  52898. private _getDebugMaterial;
  52899. private _getDebugBoxMesh;
  52900. private _getDebugSphereMesh;
  52901. private _getDebugCylinderMesh;
  52902. private _getDebugMeshMesh;
  52903. private _getDebugMesh;
  52904. /** Releases all resources */
  52905. dispose(): void;
  52906. }
  52907. }
  52908. declare module "babylonjs/Debug/rayHelper" {
  52909. import { Nullable } from "babylonjs/types";
  52910. import { Ray } from "babylonjs/Culling/ray";
  52911. import { Vector3 } from "babylonjs/Maths/math.vector";
  52912. import { Color3 } from "babylonjs/Maths/math.color";
  52913. import { Scene } from "babylonjs/scene";
  52914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52915. import "babylonjs/Meshes/Builders/linesBuilder";
  52916. /**
  52917. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52918. * in order to better appreciate the issue one might have.
  52919. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52920. */
  52921. export class RayHelper {
  52922. /**
  52923. * Defines the ray we are currently tryin to visualize.
  52924. */
  52925. ray: Nullable<Ray>;
  52926. private _renderPoints;
  52927. private _renderLine;
  52928. private _renderFunction;
  52929. private _scene;
  52930. private _onAfterRenderObserver;
  52931. private _onAfterStepObserver;
  52932. private _attachedToMesh;
  52933. private _meshSpaceDirection;
  52934. private _meshSpaceOrigin;
  52935. /**
  52936. * Helper function to create a colored helper in a scene in one line.
  52937. * @param ray Defines the ray we are currently tryin to visualize
  52938. * @param scene Defines the scene the ray is used in
  52939. * @param color Defines the color we want to see the ray in
  52940. * @returns The newly created ray helper.
  52941. */
  52942. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52943. /**
  52944. * Instantiate a new ray helper.
  52945. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52946. * in order to better appreciate the issue one might have.
  52947. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52948. * @param ray Defines the ray we are currently tryin to visualize
  52949. */
  52950. constructor(ray: Ray);
  52951. /**
  52952. * Shows the ray we are willing to debug.
  52953. * @param scene Defines the scene the ray needs to be rendered in
  52954. * @param color Defines the color the ray needs to be rendered in
  52955. */
  52956. show(scene: Scene, color?: Color3): void;
  52957. /**
  52958. * Hides the ray we are debugging.
  52959. */
  52960. hide(): void;
  52961. private _render;
  52962. /**
  52963. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  52964. * @param mesh Defines the mesh we want the helper attached to
  52965. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  52966. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  52967. * @param length Defines the length of the ray
  52968. */
  52969. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  52970. /**
  52971. * Detach the ray helper from the mesh it has previously been attached to.
  52972. */
  52973. detachFromMesh(): void;
  52974. private _updateToMesh;
  52975. /**
  52976. * Dispose the helper and release its associated resources.
  52977. */
  52978. dispose(): void;
  52979. }
  52980. }
  52981. declare module "babylonjs/Debug/ISkeletonViewer" {
  52982. /**
  52983. * Defines the options associated with the creation of a SkeletonViewer.
  52984. */
  52985. export interface ISkeletonViewerOptions {
  52986. /** Should the system pause animations before building the Viewer? */
  52987. pauseAnimations: boolean;
  52988. /** Should the system return the skeleton to rest before building? */
  52989. returnToRest: boolean;
  52990. /** public Display Mode of the Viewer */
  52991. displayMode: number;
  52992. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  52993. displayOptions: ISkeletonViewerDisplayOptions;
  52994. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  52995. computeBonesUsingShaders: boolean;
  52996. }
  52997. /**
  52998. * Defines how to display the various bone meshes for the viewer.
  52999. */
  53000. export interface ISkeletonViewerDisplayOptions {
  53001. /** How far down to start tapering the bone spurs */
  53002. midStep?: number;
  53003. /** How big is the midStep? */
  53004. midStepFactor?: number;
  53005. /** Base for the Sphere Size */
  53006. sphereBaseSize?: number;
  53007. /** The ratio of the sphere to the longest bone in units */
  53008. sphereScaleUnit?: number;
  53009. /** Ratio for the Sphere Size */
  53010. sphereFactor?: number;
  53011. }
  53012. }
  53013. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53014. import { Nullable } from "babylonjs/types";
  53015. import { Scene } from "babylonjs/scene";
  53016. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53017. import { Color4 } from "babylonjs/Maths/math.color";
  53018. import { Mesh } from "babylonjs/Meshes/mesh";
  53019. /**
  53020. * Class containing static functions to help procedurally build meshes
  53021. */
  53022. export class RibbonBuilder {
  53023. /**
  53024. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53025. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53026. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53027. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53028. * * 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
  53029. * * 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
  53030. * * 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
  53031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53032. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53033. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53034. * * 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
  53035. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53036. * * 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
  53037. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53039. * @param name defines the name of the mesh
  53040. * @param options defines the options used to create the mesh
  53041. * @param scene defines the hosting scene
  53042. * @returns the ribbon mesh
  53043. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53044. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53045. */
  53046. static CreateRibbon(name: string, options: {
  53047. pathArray: Vector3[][];
  53048. closeArray?: boolean;
  53049. closePath?: boolean;
  53050. offset?: number;
  53051. updatable?: boolean;
  53052. sideOrientation?: number;
  53053. frontUVs?: Vector4;
  53054. backUVs?: Vector4;
  53055. instance?: Mesh;
  53056. invertUV?: boolean;
  53057. uvs?: Vector2[];
  53058. colors?: Color4[];
  53059. }, scene?: Nullable<Scene>): Mesh;
  53060. }
  53061. }
  53062. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53063. import { Nullable } from "babylonjs/types";
  53064. import { Scene } from "babylonjs/scene";
  53065. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53066. import { Mesh } from "babylonjs/Meshes/mesh";
  53067. /**
  53068. * Class containing static functions to help procedurally build meshes
  53069. */
  53070. export class ShapeBuilder {
  53071. /**
  53072. * 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.
  53073. * * 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.
  53074. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53075. * * 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.
  53076. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53077. * * 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
  53078. * * 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
  53079. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53081. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53082. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53084. * @param name defines the name of the mesh
  53085. * @param options defines the options used to create the mesh
  53086. * @param scene defines the hosting scene
  53087. * @returns the extruded shape mesh
  53088. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53089. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53090. */
  53091. static ExtrudeShape(name: string, options: {
  53092. shape: Vector3[];
  53093. path: Vector3[];
  53094. scale?: number;
  53095. rotation?: number;
  53096. cap?: number;
  53097. updatable?: boolean;
  53098. sideOrientation?: number;
  53099. frontUVs?: Vector4;
  53100. backUVs?: Vector4;
  53101. instance?: Mesh;
  53102. invertUV?: boolean;
  53103. }, scene?: Nullable<Scene>): Mesh;
  53104. /**
  53105. * Creates an custom extruded shape mesh.
  53106. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53107. * * 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.
  53108. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53109. * * 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
  53110. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53111. * * 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
  53112. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53113. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53114. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53115. * * 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
  53116. * * 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
  53117. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53119. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53120. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53122. * @param name defines the name of the mesh
  53123. * @param options defines the options used to create the mesh
  53124. * @param scene defines the hosting scene
  53125. * @returns the custom extruded shape mesh
  53126. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53127. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53128. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53129. */
  53130. static ExtrudeShapeCustom(name: string, options: {
  53131. shape: Vector3[];
  53132. path: Vector3[];
  53133. scaleFunction?: any;
  53134. rotationFunction?: any;
  53135. ribbonCloseArray?: boolean;
  53136. ribbonClosePath?: boolean;
  53137. cap?: number;
  53138. updatable?: boolean;
  53139. sideOrientation?: number;
  53140. frontUVs?: Vector4;
  53141. backUVs?: Vector4;
  53142. instance?: Mesh;
  53143. invertUV?: boolean;
  53144. }, scene?: Nullable<Scene>): Mesh;
  53145. private static _ExtrudeShapeGeneric;
  53146. }
  53147. }
  53148. declare module "babylonjs/Debug/skeletonViewer" {
  53149. import { Color3 } from "babylonjs/Maths/math.color";
  53150. import { Scene } from "babylonjs/scene";
  53151. import { Nullable } from "babylonjs/types";
  53152. import { Skeleton } from "babylonjs/Bones/skeleton";
  53153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53154. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53155. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53156. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  53157. import { ISkeletonViewerOptions } from "babylonjs/Debug/ISkeletonViewer";
  53158. /**
  53159. * Class used to render a debug view of a given skeleton
  53160. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53161. */
  53162. export class SkeletonViewer {
  53163. /** defines the skeleton to render */
  53164. skeleton: Skeleton;
  53165. /** defines the mesh attached to the skeleton */
  53166. mesh: AbstractMesh;
  53167. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53168. autoUpdateBonesMatrices: boolean;
  53169. /** defines the rendering group id to use with the viewer */
  53170. renderingGroupId: number;
  53171. /** is the options for the viewer */
  53172. options: Partial<ISkeletonViewerOptions>;
  53173. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53174. static readonly DISPLAY_LINES: number;
  53175. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53176. static readonly DISPLAY_SPHERES: number;
  53177. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53178. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53179. /** If SkeletonViewer scene scope. */
  53180. private _scene;
  53181. /** Gets or sets the color used to render the skeleton */
  53182. color: Color3;
  53183. /** Array of the points of the skeleton fo the line view. */
  53184. private _debugLines;
  53185. /** The SkeletonViewers Mesh. */
  53186. private _debugMesh;
  53187. /** If SkeletonViewer is enabled. */
  53188. private _isEnabled;
  53189. /** If SkeletonViewer is ready. */
  53190. private _ready;
  53191. /** SkeletonViewer render observable. */
  53192. private _obs;
  53193. /** The Utility Layer to render the gizmos in. */
  53194. private _utilityLayer;
  53195. private _boneIndices;
  53196. /** Gets the Scene. */
  53197. get scene(): Scene;
  53198. /** Gets the utilityLayer. */
  53199. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53200. /** Checks Ready Status. */
  53201. get isReady(): Boolean;
  53202. /** Sets Ready Status. */
  53203. set ready(value: boolean);
  53204. /** Gets the debugMesh */
  53205. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53206. /** Sets the debugMesh */
  53207. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53208. /** Gets the material */
  53209. get material(): StandardMaterial;
  53210. /** Sets the material */
  53211. set material(value: StandardMaterial);
  53212. /** Gets the material */
  53213. get displayMode(): number;
  53214. /** Sets the material */
  53215. set displayMode(value: number);
  53216. /**
  53217. * Creates a new SkeletonViewer
  53218. * @param skeleton defines the skeleton to render
  53219. * @param mesh defines the mesh attached to the skeleton
  53220. * @param scene defines the hosting scene
  53221. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53222. * @param renderingGroupId defines the rendering group id to use with the viewer
  53223. * @param options All of the extra constructor options for the SkeletonViewer
  53224. */
  53225. constructor(
  53226. /** defines the skeleton to render */
  53227. skeleton: Skeleton,
  53228. /** defines the mesh attached to the skeleton */
  53229. mesh: AbstractMesh,
  53230. /** The Scene scope*/
  53231. scene: Scene,
  53232. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53233. autoUpdateBonesMatrices?: boolean,
  53234. /** defines the rendering group id to use with the viewer */
  53235. renderingGroupId?: number,
  53236. /** is the options for the viewer */
  53237. options?: Partial<ISkeletonViewerOptions>);
  53238. /** The Dynamic bindings for the update functions */
  53239. private _bindObs;
  53240. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53241. update(): void;
  53242. /** Gets or sets a boolean indicating if the viewer is enabled */
  53243. set isEnabled(value: boolean);
  53244. get isEnabled(): boolean;
  53245. private _getBonePosition;
  53246. private _getLinesForBonesWithLength;
  53247. private _getLinesForBonesNoLength;
  53248. /** function to revert the mesh and scene back to the initial state. */
  53249. private _revert;
  53250. /** function to build and bind sphere joint points and spur bone representations. */
  53251. private _buildSpheresAndSpurs;
  53252. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53253. private _displayLinesUpdate;
  53254. /** Changes the displayMode of the skeleton viewer
  53255. * @param mode The displayMode numerical value
  53256. */
  53257. changeDisplayMode(mode: number): void;
  53258. /** Changes the displayMode of the skeleton viewer
  53259. * @param option String of the option name
  53260. * @param value The numerical option value
  53261. */
  53262. changeDisplayOptions(option: string, value: number): void;
  53263. /** Release associated resources */
  53264. dispose(): void;
  53265. }
  53266. }
  53267. declare module "babylonjs/Debug/index" {
  53268. export * from "babylonjs/Debug/axesViewer";
  53269. export * from "babylonjs/Debug/boneAxesViewer";
  53270. export * from "babylonjs/Debug/debugLayer";
  53271. export * from "babylonjs/Debug/physicsViewer";
  53272. export * from "babylonjs/Debug/rayHelper";
  53273. export * from "babylonjs/Debug/skeletonViewer";
  53274. export * from "babylonjs/Debug/ISkeletonViewer";
  53275. }
  53276. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53277. /**
  53278. * Enum for Device Types
  53279. */
  53280. export enum DeviceType {
  53281. /** Generic */
  53282. Generic = 0,
  53283. /** Keyboard */
  53284. Keyboard = 1,
  53285. /** Mouse */
  53286. Mouse = 2,
  53287. /** Touch Pointers */
  53288. Touch = 3,
  53289. /** PS4 Dual Shock */
  53290. DualShock = 4,
  53291. /** Xbox */
  53292. Xbox = 5,
  53293. /** Switch Controller */
  53294. Switch = 6
  53295. }
  53296. /**
  53297. * Enum for All Pointers (Touch/Mouse)
  53298. */
  53299. export enum PointerInput {
  53300. /** Horizontal Axis */
  53301. Horizontal = 0,
  53302. /** Vertical Axis */
  53303. Vertical = 1,
  53304. /** Left Click or Touch */
  53305. LeftClick = 2,
  53306. /** Middle Click */
  53307. MiddleClick = 3,
  53308. /** Right Click */
  53309. RightClick = 4,
  53310. /** Browser Back */
  53311. BrowserBack = 5,
  53312. /** Browser Forward */
  53313. BrowserForward = 6
  53314. }
  53315. /**
  53316. * Enum for Dual Shock Gamepad
  53317. */
  53318. export enum DualShockInput {
  53319. /** Cross */
  53320. Cross = 0,
  53321. /** Circle */
  53322. Circle = 1,
  53323. /** Square */
  53324. Square = 2,
  53325. /** Triangle */
  53326. Triangle = 3,
  53327. /** L1 */
  53328. L1 = 4,
  53329. /** R1 */
  53330. R1 = 5,
  53331. /** L2 */
  53332. L2 = 6,
  53333. /** R2 */
  53334. R2 = 7,
  53335. /** Share */
  53336. Share = 8,
  53337. /** Options */
  53338. Options = 9,
  53339. /** L3 */
  53340. L3 = 10,
  53341. /** R3 */
  53342. R3 = 11,
  53343. /** DPadUp */
  53344. DPadUp = 12,
  53345. /** DPadDown */
  53346. DPadDown = 13,
  53347. /** DPadLeft */
  53348. DPadLeft = 14,
  53349. /** DRight */
  53350. DPadRight = 15,
  53351. /** Home */
  53352. Home = 16,
  53353. /** TouchPad */
  53354. TouchPad = 17,
  53355. /** LStickXAxis */
  53356. LStickXAxis = 18,
  53357. /** LStickYAxis */
  53358. LStickYAxis = 19,
  53359. /** RStickXAxis */
  53360. RStickXAxis = 20,
  53361. /** RStickYAxis */
  53362. RStickYAxis = 21
  53363. }
  53364. /**
  53365. * Enum for Xbox Gamepad
  53366. */
  53367. export enum XboxInput {
  53368. /** A */
  53369. A = 0,
  53370. /** B */
  53371. B = 1,
  53372. /** X */
  53373. X = 2,
  53374. /** Y */
  53375. Y = 3,
  53376. /** LB */
  53377. LB = 4,
  53378. /** RB */
  53379. RB = 5,
  53380. /** LT */
  53381. LT = 6,
  53382. /** RT */
  53383. RT = 7,
  53384. /** Back */
  53385. Back = 8,
  53386. /** Start */
  53387. Start = 9,
  53388. /** LS */
  53389. LS = 10,
  53390. /** RS */
  53391. RS = 11,
  53392. /** DPadUp */
  53393. DPadUp = 12,
  53394. /** DPadDown */
  53395. DPadDown = 13,
  53396. /** DPadLeft */
  53397. DPadLeft = 14,
  53398. /** DRight */
  53399. DPadRight = 15,
  53400. /** Home */
  53401. Home = 16,
  53402. /** LStickXAxis */
  53403. LStickXAxis = 17,
  53404. /** LStickYAxis */
  53405. LStickYAxis = 18,
  53406. /** RStickXAxis */
  53407. RStickXAxis = 19,
  53408. /** RStickYAxis */
  53409. RStickYAxis = 20
  53410. }
  53411. /**
  53412. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53413. */
  53414. export enum SwitchInput {
  53415. /** B */
  53416. B = 0,
  53417. /** A */
  53418. A = 1,
  53419. /** Y */
  53420. Y = 2,
  53421. /** X */
  53422. X = 3,
  53423. /** L */
  53424. L = 4,
  53425. /** R */
  53426. R = 5,
  53427. /** ZL */
  53428. ZL = 6,
  53429. /** ZR */
  53430. ZR = 7,
  53431. /** Minus */
  53432. Minus = 8,
  53433. /** Plus */
  53434. Plus = 9,
  53435. /** LS */
  53436. LS = 10,
  53437. /** RS */
  53438. RS = 11,
  53439. /** DPadUp */
  53440. DPadUp = 12,
  53441. /** DPadDown */
  53442. DPadDown = 13,
  53443. /** DPadLeft */
  53444. DPadLeft = 14,
  53445. /** DRight */
  53446. DPadRight = 15,
  53447. /** Home */
  53448. Home = 16,
  53449. /** Capture */
  53450. Capture = 17,
  53451. /** LStickXAxis */
  53452. LStickXAxis = 18,
  53453. /** LStickYAxis */
  53454. LStickYAxis = 19,
  53455. /** RStickXAxis */
  53456. RStickXAxis = 20,
  53457. /** RStickYAxis */
  53458. RStickYAxis = 21
  53459. }
  53460. }
  53461. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53462. import { Engine } from "babylonjs/Engines/engine";
  53463. import { IDisposable } from "babylonjs/scene";
  53464. import { Nullable } from "babylonjs/types";
  53465. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53466. /**
  53467. * This class will take all inputs from Keyboard, Pointer, and
  53468. * any Gamepads and provide a polling system that all devices
  53469. * will use. This class assumes that there will only be one
  53470. * pointer device and one keyboard.
  53471. */
  53472. export class DeviceInputSystem implements IDisposable {
  53473. /**
  53474. * Callback to be triggered when a device is connected
  53475. */
  53476. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53477. /**
  53478. * Callback to be triggered when a device is disconnected
  53479. */
  53480. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53481. /**
  53482. * Callback to be triggered when event driven input is updated
  53483. */
  53484. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53485. private _inputs;
  53486. private _gamepads;
  53487. private _keyboardActive;
  53488. private _pointerActive;
  53489. private _elementToAttachTo;
  53490. private _keyboardDownEvent;
  53491. private _keyboardUpEvent;
  53492. private _pointerMoveEvent;
  53493. private _pointerDownEvent;
  53494. private _pointerUpEvent;
  53495. private _gamepadConnectedEvent;
  53496. private _gamepadDisconnectedEvent;
  53497. private static _MAX_KEYCODES;
  53498. private static _MAX_POINTER_INPUTS;
  53499. private constructor();
  53500. /**
  53501. * Creates a new DeviceInputSystem instance
  53502. * @param engine Engine to pull input element from
  53503. * @returns The new instance
  53504. */
  53505. static Create(engine: Engine): DeviceInputSystem;
  53506. /**
  53507. * Checks for current device input value, given an id and input index
  53508. * @param deviceName Id of connected device
  53509. * @param inputIndex Index of device input
  53510. * @returns Current value of input
  53511. */
  53512. /**
  53513. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  53514. * @param deviceType Enum specifiying device type
  53515. * @param deviceSlot "Slot" or index that device is referenced in
  53516. * @param inputIndex Id of input to be checked
  53517. * @returns Current value of input
  53518. */
  53519. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  53520. /**
  53521. * Dispose of all the eventlisteners
  53522. */
  53523. dispose(): void;
  53524. /**
  53525. * Add device and inputs to device array
  53526. * @param deviceType Enum specifiying device type
  53527. * @param deviceSlot "Slot" or index that device is referenced in
  53528. * @param numberOfInputs Number of input entries to create for given device
  53529. */
  53530. private _registerDevice;
  53531. /**
  53532. * Given a specific device name, remove that device from the device map
  53533. * @param deviceType Enum specifiying device type
  53534. * @param deviceSlot "Slot" or index that device is referenced in
  53535. */
  53536. private _unregisterDevice;
  53537. /**
  53538. * Handle all actions that come from keyboard interaction
  53539. */
  53540. private _handleKeyActions;
  53541. /**
  53542. * Handle all actions that come from pointer interaction
  53543. */
  53544. private _handlePointerActions;
  53545. /**
  53546. * Handle all actions that come from gamepad interaction
  53547. */
  53548. private _handleGamepadActions;
  53549. /**
  53550. * Update all non-event based devices with each frame
  53551. * @param deviceType Enum specifiying device type
  53552. * @param deviceSlot "Slot" or index that device is referenced in
  53553. * @param inputIndex Id of input to be checked
  53554. */
  53555. private _updateDevice;
  53556. /**
  53557. * Gets DeviceType from the device name
  53558. * @param deviceName Name of Device from DeviceInputSystem
  53559. * @returns DeviceType enum value
  53560. */
  53561. private _getGamepadDeviceType;
  53562. }
  53563. }
  53564. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53565. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53566. /**
  53567. * Type to handle enforcement of inputs
  53568. */
  53569. 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;
  53570. }
  53571. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53572. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53573. import { Engine } from "babylonjs/Engines/engine";
  53574. import { IDisposable } from "babylonjs/scene";
  53575. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53576. import { Nullable } from "babylonjs/types";
  53577. import { Observable } from "babylonjs/Misc/observable";
  53578. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53579. /**
  53580. * Class that handles all input for a specific device
  53581. */
  53582. export class DeviceSource<T extends DeviceType> {
  53583. /** Type of device */
  53584. readonly deviceType: DeviceType;
  53585. /** "Slot" or index that device is referenced in */
  53586. readonly deviceSlot: number;
  53587. /**
  53588. * Observable to handle device input changes per device
  53589. */
  53590. readonly onInputChangedObservable: Observable<{
  53591. inputIndex: DeviceInput<T>;
  53592. previousState: Nullable<number>;
  53593. currentState: Nullable<number>;
  53594. }>;
  53595. private readonly _deviceInputSystem;
  53596. /**
  53597. * Default Constructor
  53598. * @param deviceInputSystem Reference to DeviceInputSystem
  53599. * @param deviceType Type of device
  53600. * @param deviceSlot "Slot" or index that device is referenced in
  53601. */
  53602. constructor(deviceInputSystem: DeviceInputSystem,
  53603. /** Type of device */
  53604. deviceType: DeviceType,
  53605. /** "Slot" or index that device is referenced in */
  53606. deviceSlot?: number);
  53607. /**
  53608. * Get input for specific input
  53609. * @param inputIndex index of specific input on device
  53610. * @returns Input value from DeviceInputSystem
  53611. */
  53612. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  53613. }
  53614. /**
  53615. * Class to keep track of devices
  53616. */
  53617. export class DeviceSourceManager implements IDisposable {
  53618. /**
  53619. * Observable to be triggered when before a device is connected
  53620. */
  53621. readonly onBeforeDeviceConnectedObservable: Observable<{
  53622. deviceType: DeviceType;
  53623. deviceSlot: number;
  53624. }>;
  53625. /**
  53626. * Observable to be triggered when before a device is disconnected
  53627. */
  53628. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53629. deviceType: DeviceType;
  53630. deviceSlot: number;
  53631. }>;
  53632. /**
  53633. * Observable to be triggered when after a device is connected
  53634. */
  53635. readonly onAfterDeviceConnectedObservable: Observable<{
  53636. deviceType: DeviceType;
  53637. deviceSlot: number;
  53638. }>;
  53639. /**
  53640. * Observable to be triggered when after a device is disconnected
  53641. */
  53642. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53643. deviceType: DeviceType;
  53644. deviceSlot: number;
  53645. }>;
  53646. private readonly _devices;
  53647. private readonly _firstDevice;
  53648. private readonly _deviceInputSystem;
  53649. /**
  53650. * Default Constructor
  53651. * @param engine engine to pull input element from
  53652. */
  53653. constructor(engine: Engine);
  53654. /**
  53655. * Gets a DeviceSource, given a type and slot
  53656. * @param deviceType Enum specifying device type
  53657. * @param deviceSlot "Slot" or index that device is referenced in
  53658. * @returns DeviceSource object
  53659. */
  53660. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53661. /**
  53662. * Gets an array of DeviceSource objects for a given device type
  53663. * @param deviceType Enum specifying device type
  53664. * @returns Array of DeviceSource objects
  53665. */
  53666. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53667. /**
  53668. * Dispose of DeviceInputSystem and other parts
  53669. */
  53670. dispose(): void;
  53671. /**
  53672. * Function to add device name to device list
  53673. * @param deviceType Enum specifying device type
  53674. * @param deviceSlot "Slot" or index that device is referenced in
  53675. */
  53676. private _addDevice;
  53677. /**
  53678. * Function to remove device name to device list
  53679. * @param deviceType Enum specifying device type
  53680. * @param deviceSlot "Slot" or index that device is referenced in
  53681. */
  53682. private _removeDevice;
  53683. /**
  53684. * Updates array storing first connected device of each type
  53685. * @param type Type of Device
  53686. */
  53687. private _updateFirstDevices;
  53688. }
  53689. }
  53690. declare module "babylonjs/DeviceInput/index" {
  53691. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53692. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53693. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53694. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53695. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53696. }
  53697. declare module "babylonjs/Engines/nullEngine" {
  53698. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53699. import { Engine } from "babylonjs/Engines/engine";
  53700. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53701. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53702. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53703. import { Effect } from "babylonjs/Materials/effect";
  53704. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53705. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53706. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53707. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53708. /**
  53709. * Options to create the null engine
  53710. */
  53711. export class NullEngineOptions {
  53712. /**
  53713. * Render width (Default: 512)
  53714. */
  53715. renderWidth: number;
  53716. /**
  53717. * Render height (Default: 256)
  53718. */
  53719. renderHeight: number;
  53720. /**
  53721. * Texture size (Default: 512)
  53722. */
  53723. textureSize: number;
  53724. /**
  53725. * If delta time between frames should be constant
  53726. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53727. */
  53728. deterministicLockstep: boolean;
  53729. /**
  53730. * Maximum about of steps between frames (Default: 4)
  53731. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53732. */
  53733. lockstepMaxSteps: number;
  53734. /**
  53735. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  53736. */
  53737. useHighPrecisionMatrix?: boolean;
  53738. }
  53739. /**
  53740. * The null engine class provides support for headless version of babylon.js.
  53741. * This can be used in server side scenario or for testing purposes
  53742. */
  53743. export class NullEngine extends Engine {
  53744. private _options;
  53745. /**
  53746. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  53747. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53748. * @returns true if engine is in deterministic lock step mode
  53749. */
  53750. isDeterministicLockStep(): boolean;
  53751. /**
  53752. * Gets the max steps when engine is running in deterministic lock step
  53753. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53754. * @returns the max steps
  53755. */
  53756. getLockstepMaxSteps(): number;
  53757. /**
  53758. * Gets the current hardware scaling level.
  53759. * By default the hardware scaling level is computed from the window device ratio.
  53760. * 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.
  53761. * @returns a number indicating the current hardware scaling level
  53762. */
  53763. getHardwareScalingLevel(): number;
  53764. constructor(options?: NullEngineOptions);
  53765. /**
  53766. * Creates a vertex buffer
  53767. * @param vertices the data for the vertex buffer
  53768. * @returns the new WebGL static buffer
  53769. */
  53770. createVertexBuffer(vertices: FloatArray): DataBuffer;
  53771. /**
  53772. * Creates a new index buffer
  53773. * @param indices defines the content of the index buffer
  53774. * @param updatable defines if the index buffer must be updatable
  53775. * @returns a new webGL buffer
  53776. */
  53777. createIndexBuffer(indices: IndicesArray): DataBuffer;
  53778. /**
  53779. * Clear the current render buffer or the current render target (if any is set up)
  53780. * @param color defines the color to use
  53781. * @param backBuffer defines if the back buffer must be cleared
  53782. * @param depth defines if the depth buffer must be cleared
  53783. * @param stencil defines if the stencil buffer must be cleared
  53784. */
  53785. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53786. /**
  53787. * Gets the current render width
  53788. * @param useScreen defines if screen size must be used (or the current render target if any)
  53789. * @returns a number defining the current render width
  53790. */
  53791. getRenderWidth(useScreen?: boolean): number;
  53792. /**
  53793. * Gets the current render height
  53794. * @param useScreen defines if screen size must be used (or the current render target if any)
  53795. * @returns a number defining the current render height
  53796. */
  53797. getRenderHeight(useScreen?: boolean): number;
  53798. /**
  53799. * Set the WebGL's viewport
  53800. * @param viewport defines the viewport element to be used
  53801. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  53802. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  53803. */
  53804. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  53805. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  53806. /**
  53807. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  53808. * @param pipelineContext defines the pipeline context to use
  53809. * @param uniformsNames defines the list of uniform names
  53810. * @returns an array of webGL uniform locations
  53811. */
  53812. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  53813. /**
  53814. * Gets the lsit of active attributes for a given webGL program
  53815. * @param pipelineContext defines the pipeline context to use
  53816. * @param attributesNames defines the list of attribute names to get
  53817. * @returns an array of indices indicating the offset of each attribute
  53818. */
  53819. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53820. /**
  53821. * Binds an effect to the webGL context
  53822. * @param effect defines the effect to bind
  53823. */
  53824. bindSamplers(effect: Effect): void;
  53825. /**
  53826. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  53827. * @param effect defines the effect to activate
  53828. */
  53829. enableEffect(effect: Effect): void;
  53830. /**
  53831. * Set various states to the webGL context
  53832. * @param culling defines backface culling state
  53833. * @param zOffset defines the value to apply to zOffset (0 by default)
  53834. * @param force defines if states must be applied even if cache is up to date
  53835. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  53836. */
  53837. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53838. /**
  53839. * Set the value of an uniform to an array of int32
  53840. * @param uniform defines the webGL uniform location where to store the value
  53841. * @param array defines the array of int32 to store
  53842. */
  53843. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53844. /**
  53845. * Set the value of an uniform to an array of int32 (stored as vec2)
  53846. * @param uniform defines the webGL uniform location where to store the value
  53847. * @param array defines the array of int32 to store
  53848. */
  53849. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53850. /**
  53851. * Set the value of an uniform to an array of int32 (stored as vec3)
  53852. * @param uniform defines the webGL uniform location where to store the value
  53853. * @param array defines the array of int32 to store
  53854. */
  53855. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53856. /**
  53857. * Set the value of an uniform to an array of int32 (stored as vec4)
  53858. * @param uniform defines the webGL uniform location where to store the value
  53859. * @param array defines the array of int32 to store
  53860. */
  53861. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53862. /**
  53863. * Set the value of an uniform to an array of float32
  53864. * @param uniform defines the webGL uniform location where to store the value
  53865. * @param array defines the array of float32 to store
  53866. */
  53867. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53868. /**
  53869. * Set the value of an uniform to an array of float32 (stored as vec2)
  53870. * @param uniform defines the webGL uniform location where to store the value
  53871. * @param array defines the array of float32 to store
  53872. */
  53873. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53874. /**
  53875. * Set the value of an uniform to an array of float32 (stored as vec3)
  53876. * @param uniform defines the webGL uniform location where to store the value
  53877. * @param array defines the array of float32 to store
  53878. */
  53879. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53880. /**
  53881. * Set the value of an uniform to an array of float32 (stored as vec4)
  53882. * @param uniform defines the webGL uniform location where to store the value
  53883. * @param array defines the array of float32 to store
  53884. */
  53885. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53886. /**
  53887. * Set the value of an uniform to an array of number
  53888. * @param uniform defines the webGL uniform location where to store the value
  53889. * @param array defines the array of number to store
  53890. */
  53891. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53892. /**
  53893. * Set the value of an uniform to an array of number (stored as vec2)
  53894. * @param uniform defines the webGL uniform location where to store the value
  53895. * @param array defines the array of number to store
  53896. */
  53897. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53898. /**
  53899. * Set the value of an uniform to an array of number (stored as vec3)
  53900. * @param uniform defines the webGL uniform location where to store the value
  53901. * @param array defines the array of number to store
  53902. */
  53903. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53904. /**
  53905. * Set the value of an uniform to an array of number (stored as vec4)
  53906. * @param uniform defines the webGL uniform location where to store the value
  53907. * @param array defines the array of number to store
  53908. */
  53909. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53910. /**
  53911. * Set the value of an uniform to an array of float32 (stored as matrices)
  53912. * @param uniform defines the webGL uniform location where to store the value
  53913. * @param matrices defines the array of float32 to store
  53914. */
  53915. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53916. /**
  53917. * Set the value of an uniform to a matrix (3x3)
  53918. * @param uniform defines the webGL uniform location where to store the value
  53919. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  53920. */
  53921. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53922. /**
  53923. * Set the value of an uniform to a matrix (2x2)
  53924. * @param uniform defines the webGL uniform location where to store the value
  53925. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  53926. */
  53927. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53928. /**
  53929. * Set the value of an uniform to a number (float)
  53930. * @param uniform defines the webGL uniform location where to store the value
  53931. * @param value defines the float number to store
  53932. */
  53933. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53934. /**
  53935. * Set the value of an uniform to a vec2
  53936. * @param uniform defines the webGL uniform location where to store the value
  53937. * @param x defines the 1st component of the value
  53938. * @param y defines the 2nd component of the value
  53939. */
  53940. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53941. /**
  53942. * Set the value of an uniform to a vec3
  53943. * @param uniform defines the webGL uniform location where to store the value
  53944. * @param x defines the 1st component of the value
  53945. * @param y defines the 2nd component of the value
  53946. * @param z defines the 3rd component of the value
  53947. */
  53948. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53949. /**
  53950. * Set the value of an uniform to a boolean
  53951. * @param uniform defines the webGL uniform location where to store the value
  53952. * @param bool defines the boolean to store
  53953. */
  53954. setBool(uniform: WebGLUniformLocation, bool: number): void;
  53955. /**
  53956. * Set the value of an uniform to a vec4
  53957. * @param uniform defines the webGL uniform location where to store the value
  53958. * @param x defines the 1st component of the value
  53959. * @param y defines the 2nd component of the value
  53960. * @param z defines the 3rd component of the value
  53961. * @param w defines the 4th component of the value
  53962. */
  53963. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53964. /**
  53965. * Sets the current alpha mode
  53966. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  53967. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53968. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53969. */
  53970. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53971. /**
  53972. * Bind webGl buffers directly to the webGL context
  53973. * @param vertexBuffers defines the vertex buffer to bind
  53974. * @param indexBuffer defines the index buffer to bind
  53975. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  53976. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  53977. * @param effect defines the effect associated with the vertex buffer
  53978. */
  53979. bindBuffers(vertexBuffers: {
  53980. [key: string]: VertexBuffer;
  53981. }, indexBuffer: DataBuffer, effect: Effect): void;
  53982. /**
  53983. * Force the entire cache to be cleared
  53984. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  53985. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  53986. */
  53987. wipeCaches(bruteForce?: boolean): void;
  53988. /**
  53989. * Send a draw order
  53990. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  53991. * @param indexStart defines the starting index
  53992. * @param indexCount defines the number of index to draw
  53993. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53994. */
  53995. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  53996. /**
  53997. * Draw a list of indexed primitives
  53998. * @param fillMode defines the primitive to use
  53999. * @param indexStart defines the starting index
  54000. * @param indexCount defines the number of index to draw
  54001. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54002. */
  54003. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54004. /**
  54005. * Draw a list of unindexed primitives
  54006. * @param fillMode defines the primitive to use
  54007. * @param verticesStart defines the index of first vertex to draw
  54008. * @param verticesCount defines the count of vertices to draw
  54009. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54010. */
  54011. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54012. /** @hidden */
  54013. _createTexture(): WebGLTexture;
  54014. /** @hidden */
  54015. _releaseTexture(texture: InternalTexture): void;
  54016. /**
  54017. * Usually called from Texture.ts.
  54018. * Passed information to create a WebGLTexture
  54019. * @param urlArg defines a value which contains one of the following:
  54020. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54021. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54022. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54023. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54024. * @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)
  54025. * @param scene needed for loading to the correct scene
  54026. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54027. * @param onLoad optional callback to be called upon successful completion
  54028. * @param onError optional callback to be called upon failure
  54029. * @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
  54030. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54031. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54032. * @param forcedExtension defines the extension to use to pick the right loader
  54033. * @param mimeType defines an optional mime type
  54034. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54035. */
  54036. 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;
  54037. /**
  54038. * Creates a new render target texture
  54039. * @param size defines the size of the texture
  54040. * @param options defines the options used to create the texture
  54041. * @returns a new render target texture stored in an InternalTexture
  54042. */
  54043. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  54044. /**
  54045. * Update the sampling mode of a given texture
  54046. * @param samplingMode defines the required sampling mode
  54047. * @param texture defines the texture to update
  54048. */
  54049. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54050. /**
  54051. * Binds the frame buffer to the specified texture.
  54052. * @param texture The texture to render to or null for the default canvas
  54053. * @param faceIndex The face of the texture to render to in case of cube texture
  54054. * @param requiredWidth The width of the target to render to
  54055. * @param requiredHeight The height of the target to render to
  54056. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54057. * @param lodLevel defines le lod level to bind to the frame buffer
  54058. */
  54059. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54060. /**
  54061. * Unbind the current render target texture from the webGL context
  54062. * @param texture defines the render target texture to unbind
  54063. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54064. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54065. */
  54066. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54067. /**
  54068. * Creates a dynamic vertex buffer
  54069. * @param vertices the data for the dynamic vertex buffer
  54070. * @returns the new WebGL dynamic buffer
  54071. */
  54072. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54073. /**
  54074. * Update the content of a dynamic texture
  54075. * @param texture defines the texture to update
  54076. * @param canvas defines the canvas containing the source
  54077. * @param invertY defines if data must be stored with Y axis inverted
  54078. * @param premulAlpha defines if alpha is stored as premultiplied
  54079. * @param format defines the format of the data
  54080. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54081. */
  54082. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54083. /**
  54084. * Gets a boolean indicating if all created effects are ready
  54085. * @returns true if all effects are ready
  54086. */
  54087. areAllEffectsReady(): boolean;
  54088. /**
  54089. * @hidden
  54090. * Get the current error code of the webGL context
  54091. * @returns the error code
  54092. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54093. */
  54094. getError(): number;
  54095. /** @hidden */
  54096. _getUnpackAlignement(): number;
  54097. /** @hidden */
  54098. _unpackFlipY(value: boolean): void;
  54099. /**
  54100. * Update a dynamic index buffer
  54101. * @param indexBuffer defines the target index buffer
  54102. * @param indices defines the data to update
  54103. * @param offset defines the offset in the target index buffer where update should start
  54104. */
  54105. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54106. /**
  54107. * Updates a dynamic vertex buffer.
  54108. * @param vertexBuffer the vertex buffer to update
  54109. * @param vertices the data used to update the vertex buffer
  54110. * @param byteOffset the byte offset of the data (optional)
  54111. * @param byteLength the byte length of the data (optional)
  54112. */
  54113. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54114. /** @hidden */
  54115. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54116. /** @hidden */
  54117. _bindTexture(channel: number, texture: InternalTexture): void;
  54118. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54119. /**
  54120. * 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
  54121. */
  54122. releaseEffects(): void;
  54123. displayLoadingUI(): void;
  54124. hideLoadingUI(): void;
  54125. /** @hidden */
  54126. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54127. /** @hidden */
  54128. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54129. /** @hidden */
  54130. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54131. /** @hidden */
  54132. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54133. }
  54134. }
  54135. declare module "babylonjs/Instrumentation/timeToken" {
  54136. import { Nullable } from "babylonjs/types";
  54137. /**
  54138. * @hidden
  54139. **/
  54140. export class _TimeToken {
  54141. _startTimeQuery: Nullable<WebGLQuery>;
  54142. _endTimeQuery: Nullable<WebGLQuery>;
  54143. _timeElapsedQuery: Nullable<WebGLQuery>;
  54144. _timeElapsedQueryEnded: boolean;
  54145. }
  54146. }
  54147. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54148. import { Nullable, int } from "babylonjs/types";
  54149. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54150. /** @hidden */
  54151. export class _OcclusionDataStorage {
  54152. /** @hidden */
  54153. occlusionInternalRetryCounter: number;
  54154. /** @hidden */
  54155. isOcclusionQueryInProgress: boolean;
  54156. /** @hidden */
  54157. isOccluded: boolean;
  54158. /** @hidden */
  54159. occlusionRetryCount: number;
  54160. /** @hidden */
  54161. occlusionType: number;
  54162. /** @hidden */
  54163. occlusionQueryAlgorithmType: number;
  54164. }
  54165. module "babylonjs/Engines/engine" {
  54166. interface Engine {
  54167. /**
  54168. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54169. * @return the new query
  54170. */
  54171. createQuery(): WebGLQuery;
  54172. /**
  54173. * Delete and release a webGL query
  54174. * @param query defines the query to delete
  54175. * @return the current engine
  54176. */
  54177. deleteQuery(query: WebGLQuery): Engine;
  54178. /**
  54179. * Check if a given query has resolved and got its value
  54180. * @param query defines the query to check
  54181. * @returns true if the query got its value
  54182. */
  54183. isQueryResultAvailable(query: WebGLQuery): boolean;
  54184. /**
  54185. * Gets the value of a given query
  54186. * @param query defines the query to check
  54187. * @returns the value of the query
  54188. */
  54189. getQueryResult(query: WebGLQuery): number;
  54190. /**
  54191. * Initiates an occlusion query
  54192. * @param algorithmType defines the algorithm to use
  54193. * @param query defines the query to use
  54194. * @returns the current engine
  54195. * @see https://doc.babylonjs.com/features/occlusionquery
  54196. */
  54197. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54198. /**
  54199. * Ends an occlusion query
  54200. * @see https://doc.babylonjs.com/features/occlusionquery
  54201. * @param algorithmType defines the algorithm to use
  54202. * @returns the current engine
  54203. */
  54204. endOcclusionQuery(algorithmType: number): Engine;
  54205. /**
  54206. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54207. * Please note that only one query can be issued at a time
  54208. * @returns a time token used to track the time span
  54209. */
  54210. startTimeQuery(): Nullable<_TimeToken>;
  54211. /**
  54212. * Ends a time query
  54213. * @param token defines the token used to measure the time span
  54214. * @returns the time spent (in ns)
  54215. */
  54216. endTimeQuery(token: _TimeToken): int;
  54217. /** @hidden */
  54218. _currentNonTimestampToken: Nullable<_TimeToken>;
  54219. /** @hidden */
  54220. _createTimeQuery(): WebGLQuery;
  54221. /** @hidden */
  54222. _deleteTimeQuery(query: WebGLQuery): void;
  54223. /** @hidden */
  54224. _getGlAlgorithmType(algorithmType: number): number;
  54225. /** @hidden */
  54226. _getTimeQueryResult(query: WebGLQuery): any;
  54227. /** @hidden */
  54228. _getTimeQueryAvailability(query: WebGLQuery): any;
  54229. }
  54230. }
  54231. module "babylonjs/Meshes/abstractMesh" {
  54232. interface AbstractMesh {
  54233. /**
  54234. * Backing filed
  54235. * @hidden
  54236. */
  54237. __occlusionDataStorage: _OcclusionDataStorage;
  54238. /**
  54239. * Access property
  54240. * @hidden
  54241. */
  54242. _occlusionDataStorage: _OcclusionDataStorage;
  54243. /**
  54244. * 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.
  54245. * The default value is -1 which means don't break the query and wait till the result
  54246. * @see https://doc.babylonjs.com/features/occlusionquery
  54247. */
  54248. occlusionRetryCount: number;
  54249. /**
  54250. * 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:
  54251. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54252. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54253. * * 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.
  54254. * @see https://doc.babylonjs.com/features/occlusionquery
  54255. */
  54256. occlusionType: number;
  54257. /**
  54258. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54259. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54260. * * 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.
  54261. * @see https://doc.babylonjs.com/features/occlusionquery
  54262. */
  54263. occlusionQueryAlgorithmType: number;
  54264. /**
  54265. * 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
  54266. * @see https://doc.babylonjs.com/features/occlusionquery
  54267. */
  54268. isOccluded: boolean;
  54269. /**
  54270. * Flag to check the progress status of the query
  54271. * @see https://doc.babylonjs.com/features/occlusionquery
  54272. */
  54273. isOcclusionQueryInProgress: boolean;
  54274. }
  54275. }
  54276. }
  54277. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54278. import { Nullable } from "babylonjs/types";
  54279. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54280. /** @hidden */
  54281. export var _forceTransformFeedbackToBundle: boolean;
  54282. module "babylonjs/Engines/engine" {
  54283. interface Engine {
  54284. /**
  54285. * Creates a webGL transform feedback object
  54286. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54287. * @returns the webGL transform feedback object
  54288. */
  54289. createTransformFeedback(): WebGLTransformFeedback;
  54290. /**
  54291. * Delete a webGL transform feedback object
  54292. * @param value defines the webGL transform feedback object to delete
  54293. */
  54294. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54295. /**
  54296. * Bind a webGL transform feedback object to the webgl context
  54297. * @param value defines the webGL transform feedback object to bind
  54298. */
  54299. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54300. /**
  54301. * Begins a transform feedback operation
  54302. * @param usePoints defines if points or triangles must be used
  54303. */
  54304. beginTransformFeedback(usePoints: boolean): void;
  54305. /**
  54306. * Ends a transform feedback operation
  54307. */
  54308. endTransformFeedback(): void;
  54309. /**
  54310. * Specify the varyings to use with transform feedback
  54311. * @param program defines the associated webGL program
  54312. * @param value defines the list of strings representing the varying names
  54313. */
  54314. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54315. /**
  54316. * Bind a webGL buffer for a transform feedback operation
  54317. * @param value defines the webGL buffer to bind
  54318. */
  54319. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54320. }
  54321. }
  54322. }
  54323. declare module "babylonjs/Engines/Extensions/engine.views" {
  54324. import { Camera } from "babylonjs/Cameras/camera";
  54325. import { Nullable } from "babylonjs/types";
  54326. /**
  54327. * Class used to define an additional view for the engine
  54328. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54329. */
  54330. export class EngineView {
  54331. /** Defines the canvas where to render the view */
  54332. target: HTMLCanvasElement;
  54333. /** Defines an optional camera used to render the view (will use active camera else) */
  54334. camera?: Camera;
  54335. }
  54336. module "babylonjs/Engines/engine" {
  54337. interface Engine {
  54338. /**
  54339. * Gets or sets the HTML element to use for attaching events
  54340. */
  54341. inputElement: Nullable<HTMLElement>;
  54342. /**
  54343. * Gets the current engine view
  54344. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54345. */
  54346. activeView: Nullable<EngineView>;
  54347. /** Gets or sets the list of views */
  54348. views: EngineView[];
  54349. /**
  54350. * Register a new child canvas
  54351. * @param canvas defines the canvas to register
  54352. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54353. * @returns the associated view
  54354. */
  54355. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54356. /**
  54357. * Remove a registered child canvas
  54358. * @param canvas defines the canvas to remove
  54359. * @returns the current engine
  54360. */
  54361. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54362. }
  54363. }
  54364. }
  54365. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54366. import { Nullable } from "babylonjs/types";
  54367. module "babylonjs/Engines/engine" {
  54368. interface Engine {
  54369. /** @hidden */
  54370. _excludedCompressedTextures: string[];
  54371. /** @hidden */
  54372. _textureFormatInUse: string;
  54373. /**
  54374. * Gets the list of texture formats supported
  54375. */
  54376. readonly texturesSupported: Array<string>;
  54377. /**
  54378. * Gets the texture format in use
  54379. */
  54380. readonly textureFormatInUse: Nullable<string>;
  54381. /**
  54382. * Set the compressed texture extensions or file names to skip.
  54383. *
  54384. * @param skippedFiles defines the list of those texture files you want to skip
  54385. * Example: [".dds", ".env", "myfile.png"]
  54386. */
  54387. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54388. /**
  54389. * Set the compressed texture format to use, based on the formats you have, and the formats
  54390. * supported by the hardware / browser.
  54391. *
  54392. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54393. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54394. * to API arguments needed to compressed textures. This puts the burden on the container
  54395. * generator to house the arcane code for determining these for current & future formats.
  54396. *
  54397. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54398. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54399. *
  54400. * Note: The result of this call is not taken into account when a texture is base64.
  54401. *
  54402. * @param formatsAvailable defines the list of those format families you have created
  54403. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54404. *
  54405. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54406. * @returns The extension selected.
  54407. */
  54408. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54409. }
  54410. }
  54411. }
  54412. declare module "babylonjs/Engines/Extensions/index" {
  54413. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54414. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54415. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54416. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54417. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54418. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54419. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54420. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54421. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54422. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54423. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54424. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54425. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54426. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54427. export * from "babylonjs/Engines/Extensions/engine.views";
  54428. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54429. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54430. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54431. }
  54432. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54433. import { Nullable } from "babylonjs/types";
  54434. /**
  54435. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54436. */
  54437. export interface CubeMapInfo {
  54438. /**
  54439. * The pixel array for the front face.
  54440. * This is stored in format, left to right, up to down format.
  54441. */
  54442. front: Nullable<ArrayBufferView>;
  54443. /**
  54444. * The pixel array for the back face.
  54445. * This is stored in format, left to right, up to down format.
  54446. */
  54447. back: Nullable<ArrayBufferView>;
  54448. /**
  54449. * The pixel array for the left face.
  54450. * This is stored in format, left to right, up to down format.
  54451. */
  54452. left: Nullable<ArrayBufferView>;
  54453. /**
  54454. * The pixel array for the right face.
  54455. * This is stored in format, left to right, up to down format.
  54456. */
  54457. right: Nullable<ArrayBufferView>;
  54458. /**
  54459. * The pixel array for the up face.
  54460. * This is stored in format, left to right, up to down format.
  54461. */
  54462. up: Nullable<ArrayBufferView>;
  54463. /**
  54464. * The pixel array for the down face.
  54465. * This is stored in format, left to right, up to down format.
  54466. */
  54467. down: Nullable<ArrayBufferView>;
  54468. /**
  54469. * The size of the cubemap stored.
  54470. *
  54471. * Each faces will be size * size pixels.
  54472. */
  54473. size: number;
  54474. /**
  54475. * The format of the texture.
  54476. *
  54477. * RGBA, RGB.
  54478. */
  54479. format: number;
  54480. /**
  54481. * The type of the texture data.
  54482. *
  54483. * UNSIGNED_INT, FLOAT.
  54484. */
  54485. type: number;
  54486. /**
  54487. * Specifies whether the texture is in gamma space.
  54488. */
  54489. gammaSpace: boolean;
  54490. }
  54491. /**
  54492. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54493. */
  54494. export class PanoramaToCubeMapTools {
  54495. private static FACE_LEFT;
  54496. private static FACE_RIGHT;
  54497. private static FACE_FRONT;
  54498. private static FACE_BACK;
  54499. private static FACE_DOWN;
  54500. private static FACE_UP;
  54501. /**
  54502. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54503. *
  54504. * @param float32Array The source data.
  54505. * @param inputWidth The width of the input panorama.
  54506. * @param inputHeight The height of the input panorama.
  54507. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54508. * @return The cubemap data
  54509. */
  54510. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54511. private static CreateCubemapTexture;
  54512. private static CalcProjectionSpherical;
  54513. }
  54514. }
  54515. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54516. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54517. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54518. import { Nullable } from "babylonjs/types";
  54519. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54520. /**
  54521. * Helper class dealing with the extraction of spherical polynomial dataArray
  54522. * from a cube map.
  54523. */
  54524. export class CubeMapToSphericalPolynomialTools {
  54525. private static FileFaces;
  54526. /**
  54527. * Converts a texture to the according Spherical Polynomial data.
  54528. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54529. *
  54530. * @param texture The texture to extract the information from.
  54531. * @return The Spherical Polynomial data.
  54532. */
  54533. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54534. /**
  54535. * Converts a cubemap to the according Spherical Polynomial data.
  54536. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54537. *
  54538. * @param cubeInfo The Cube map to extract the information from.
  54539. * @return The Spherical Polynomial data.
  54540. */
  54541. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54542. }
  54543. }
  54544. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54545. import { Nullable } from "babylonjs/types";
  54546. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54547. module "babylonjs/Materials/Textures/baseTexture" {
  54548. interface BaseTexture {
  54549. /**
  54550. * Get the polynomial representation of the texture data.
  54551. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54552. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54553. */
  54554. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54555. }
  54556. }
  54557. }
  54558. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54559. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54560. /** @hidden */
  54561. export var rgbdEncodePixelShader: {
  54562. name: string;
  54563. shader: string;
  54564. };
  54565. }
  54566. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54567. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54568. /** @hidden */
  54569. export var rgbdDecodePixelShader: {
  54570. name: string;
  54571. shader: string;
  54572. };
  54573. }
  54574. declare module "babylonjs/Misc/environmentTextureTools" {
  54575. import { Nullable } from "babylonjs/types";
  54576. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54577. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54578. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54579. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54580. import "babylonjs/Engines/Extensions/engine.readTexture";
  54581. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54582. import "babylonjs/Shaders/rgbdEncode.fragment";
  54583. import "babylonjs/Shaders/rgbdDecode.fragment";
  54584. /**
  54585. * Raw texture data and descriptor sufficient for WebGL texture upload
  54586. */
  54587. export interface EnvironmentTextureInfo {
  54588. /**
  54589. * Version of the environment map
  54590. */
  54591. version: number;
  54592. /**
  54593. * Width of image
  54594. */
  54595. width: number;
  54596. /**
  54597. * Irradiance information stored in the file.
  54598. */
  54599. irradiance: any;
  54600. /**
  54601. * Specular information stored in the file.
  54602. */
  54603. specular: any;
  54604. }
  54605. /**
  54606. * Defines One Image in the file. It requires only the position in the file
  54607. * as well as the length.
  54608. */
  54609. interface BufferImageData {
  54610. /**
  54611. * Length of the image data.
  54612. */
  54613. length: number;
  54614. /**
  54615. * Position of the data from the null terminator delimiting the end of the JSON.
  54616. */
  54617. position: number;
  54618. }
  54619. /**
  54620. * Defines the specular data enclosed in the file.
  54621. * This corresponds to the version 1 of the data.
  54622. */
  54623. export interface EnvironmentTextureSpecularInfoV1 {
  54624. /**
  54625. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54626. */
  54627. specularDataPosition?: number;
  54628. /**
  54629. * This contains all the images data needed to reconstruct the cubemap.
  54630. */
  54631. mipmaps: Array<BufferImageData>;
  54632. /**
  54633. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54634. */
  54635. lodGenerationScale: number;
  54636. }
  54637. /**
  54638. * Sets of helpers addressing the serialization and deserialization of environment texture
  54639. * stored in a BabylonJS env file.
  54640. * Those files are usually stored as .env files.
  54641. */
  54642. export class EnvironmentTextureTools {
  54643. /**
  54644. * Magic number identifying the env file.
  54645. */
  54646. private static _MagicBytes;
  54647. /**
  54648. * Gets the environment info from an env file.
  54649. * @param data The array buffer containing the .env bytes.
  54650. * @returns the environment file info (the json header) if successfully parsed.
  54651. */
  54652. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54653. /**
  54654. * Creates an environment texture from a loaded cube texture.
  54655. * @param texture defines the cube texture to convert in env file
  54656. * @return a promise containing the environment data if succesfull.
  54657. */
  54658. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54659. /**
  54660. * Creates a JSON representation of the spherical data.
  54661. * @param texture defines the texture containing the polynomials
  54662. * @return the JSON representation of the spherical info
  54663. */
  54664. private static _CreateEnvTextureIrradiance;
  54665. /**
  54666. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54667. * @param data the image data
  54668. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54669. * @return the views described by info providing access to the underlying buffer
  54670. */
  54671. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54672. /**
  54673. * Uploads the texture info contained in the env file to the GPU.
  54674. * @param texture defines the internal texture to upload to
  54675. * @param data defines the data to load
  54676. * @param info defines the texture info retrieved through the GetEnvInfo method
  54677. * @returns a promise
  54678. */
  54679. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54680. private static _OnImageReadyAsync;
  54681. /**
  54682. * Uploads the levels of image data to the GPU.
  54683. * @param texture defines the internal texture to upload to
  54684. * @param imageData defines the array buffer views of image data [mipmap][face]
  54685. * @returns a promise
  54686. */
  54687. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54688. /**
  54689. * Uploads spherical polynomials information to the texture.
  54690. * @param texture defines the texture we are trying to upload the information to
  54691. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54692. */
  54693. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54694. /** @hidden */
  54695. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54696. }
  54697. }
  54698. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54699. /**
  54700. * Class used to inline functions in shader code
  54701. */
  54702. export class ShaderCodeInliner {
  54703. private static readonly _RegexpFindFunctionNameAndType;
  54704. private _sourceCode;
  54705. private _functionDescr;
  54706. private _numMaxIterations;
  54707. /** Gets or sets the token used to mark the functions to inline */
  54708. inlineToken: string;
  54709. /** Gets or sets the debug mode */
  54710. debug: boolean;
  54711. /** Gets the code after the inlining process */
  54712. get code(): string;
  54713. /**
  54714. * Initializes the inliner
  54715. * @param sourceCode shader code source to inline
  54716. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  54717. */
  54718. constructor(sourceCode: string, numMaxIterations?: number);
  54719. /**
  54720. * Start the processing of the shader code
  54721. */
  54722. processCode(): void;
  54723. private _collectFunctions;
  54724. private _processInlining;
  54725. private _extractBetweenMarkers;
  54726. private _skipWhitespaces;
  54727. private _removeComments;
  54728. private _replaceFunctionCallsByCode;
  54729. private _findBackward;
  54730. private _escapeRegExp;
  54731. private _replaceNames;
  54732. }
  54733. }
  54734. declare module "babylonjs/Engines/nativeEngine" {
  54735. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  54736. import { Engine } from "babylonjs/Engines/engine";
  54737. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54738. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54739. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54740. import { Effect } from "babylonjs/Materials/effect";
  54741. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54742. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  54743. import { IColor4Like } from "babylonjs/Maths/math.like";
  54744. import { Scene } from "babylonjs/scene";
  54745. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54746. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54747. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54748. /**
  54749. * Container for accessors for natively-stored mesh data buffers.
  54750. */
  54751. class NativeDataBuffer extends DataBuffer {
  54752. /**
  54753. * Accessor value used to identify/retrieve a natively-stored index buffer.
  54754. */
  54755. nativeIndexBuffer?: any;
  54756. /**
  54757. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  54758. */
  54759. nativeVertexBuffer?: any;
  54760. }
  54761. /** @hidden */
  54762. class NativeTexture extends InternalTexture {
  54763. getInternalTexture(): InternalTexture;
  54764. getViewCount(): number;
  54765. }
  54766. /** @hidden */
  54767. export class NativeEngine extends Engine {
  54768. private readonly _native;
  54769. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  54770. private readonly INVALID_HANDLE;
  54771. private _boundBuffersVertexArray;
  54772. getHardwareScalingLevel(): number;
  54773. constructor();
  54774. dispose(): void;
  54775. /**
  54776. * Can be used to override the current requestAnimationFrame requester.
  54777. * @hidden
  54778. */
  54779. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  54780. /**
  54781. * Override default engine behavior.
  54782. * @param color
  54783. * @param backBuffer
  54784. * @param depth
  54785. * @param stencil
  54786. */
  54787. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  54788. /**
  54789. * Gets host document
  54790. * @returns the host document object
  54791. */
  54792. getHostDocument(): Nullable<Document>;
  54793. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54794. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  54795. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  54796. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  54797. [key: string]: VertexBuffer;
  54798. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54799. bindBuffers(vertexBuffers: {
  54800. [key: string]: VertexBuffer;
  54801. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54802. recordVertexArrayObject(vertexBuffers: {
  54803. [key: string]: VertexBuffer;
  54804. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  54805. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54806. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54807. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54808. /**
  54809. * Draw a list of indexed primitives
  54810. * @param fillMode defines the primitive to use
  54811. * @param indexStart defines the starting index
  54812. * @param indexCount defines the number of index to draw
  54813. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54814. */
  54815. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54816. /**
  54817. * Draw a list of unindexed primitives
  54818. * @param fillMode defines the primitive to use
  54819. * @param verticesStart defines the index of first vertex to draw
  54820. * @param verticesCount defines the count of vertices to draw
  54821. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54822. */
  54823. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54824. createPipelineContext(): IPipelineContext;
  54825. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  54826. /** @hidden */
  54827. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  54828. /** @hidden */
  54829. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  54830. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54831. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54832. protected _setProgram(program: WebGLProgram): void;
  54833. _releaseEffect(effect: Effect): void;
  54834. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  54835. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  54836. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  54837. bindSamplers(effect: Effect): void;
  54838. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  54839. getRenderWidth(useScreen?: boolean): number;
  54840. getRenderHeight(useScreen?: boolean): number;
  54841. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  54842. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54843. /**
  54844. * Set the z offset to apply to current rendering
  54845. * @param value defines the offset to apply
  54846. */
  54847. setZOffset(value: number): void;
  54848. /**
  54849. * Gets the current value of the zOffset
  54850. * @returns the current zOffset state
  54851. */
  54852. getZOffset(): number;
  54853. /**
  54854. * Enable or disable depth buffering
  54855. * @param enable defines the state to set
  54856. */
  54857. setDepthBuffer(enable: boolean): void;
  54858. /**
  54859. * Gets a boolean indicating if depth writing is enabled
  54860. * @returns the current depth writing state
  54861. */
  54862. getDepthWrite(): boolean;
  54863. /**
  54864. * Enable or disable depth writing
  54865. * @param enable defines the state to set
  54866. */
  54867. setDepthWrite(enable: boolean): void;
  54868. /**
  54869. * Enable or disable color writing
  54870. * @param enable defines the state to set
  54871. */
  54872. setColorWrite(enable: boolean): void;
  54873. /**
  54874. * Gets a boolean indicating if color writing is enabled
  54875. * @returns the current color writing state
  54876. */
  54877. getColorWrite(): boolean;
  54878. /**
  54879. * Sets alpha constants used by some alpha blending modes
  54880. * @param r defines the red component
  54881. * @param g defines the green component
  54882. * @param b defines the blue component
  54883. * @param a defines the alpha component
  54884. */
  54885. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  54886. /**
  54887. * Sets the current alpha mode
  54888. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  54889. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54890. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54891. */
  54892. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54893. /**
  54894. * Gets the current alpha mode
  54895. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54896. * @returns the current alpha mode
  54897. */
  54898. getAlphaMode(): number;
  54899. setInt(uniform: WebGLUniformLocation, int: number): void;
  54900. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  54901. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  54902. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  54903. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  54904. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  54905. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  54906. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  54907. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  54908. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  54909. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  54910. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  54911. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  54912. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  54913. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54914. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54915. setFloat(uniform: WebGLUniformLocation, value: number): void;
  54916. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  54917. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  54918. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54919. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  54920. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  54921. wipeCaches(bruteForce?: boolean): void;
  54922. _createTexture(): WebGLTexture;
  54923. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  54924. /**
  54925. * Usually called from Texture.ts.
  54926. * Passed information to create a WebGLTexture
  54927. * @param url defines a value which contains one of the following:
  54928. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54929. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54930. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54931. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54932. * @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)
  54933. * @param scene needed for loading to the correct scene
  54934. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54935. * @param onLoad optional callback to be called upon successful completion
  54936. * @param onError optional callback to be called upon failure
  54937. * @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
  54938. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54939. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54940. * @param forcedExtension defines the extension to use to pick the right loader
  54941. * @param mimeType defines an optional mime type
  54942. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54943. */
  54944. 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;
  54945. /**
  54946. * Creates a cube texture
  54947. * @param rootUrl defines the url where the files to load is located
  54948. * @param scene defines the current scene
  54949. * @param files defines the list of files to load (1 per face)
  54950. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  54951. * @param onLoad defines an optional callback raised when the texture is loaded
  54952. * @param onError defines an optional callback raised if there is an issue to load the texture
  54953. * @param format defines the format of the data
  54954. * @param forcedExtension defines the extension to use to pick the right loader
  54955. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  54956. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54957. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54958. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  54959. * @returns the cube texture as an InternalTexture
  54960. */
  54961. 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;
  54962. private _getSamplingFilter;
  54963. private static _GetNativeTextureFormat;
  54964. createRenderTargetTexture(size: number | {
  54965. width: number;
  54966. height: number;
  54967. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  54968. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54969. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54970. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54971. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  54972. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  54973. /**
  54974. * Updates a dynamic vertex buffer.
  54975. * @param vertexBuffer the vertex buffer to update
  54976. * @param data the data used to update the vertex buffer
  54977. * @param byteOffset the byte offset of the data (optional)
  54978. * @param byteLength the byte length of the data (optional)
  54979. */
  54980. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  54981. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  54982. private _updateAnisotropicLevel;
  54983. private _getAddressMode;
  54984. /** @hidden */
  54985. _bindTexture(channel: number, texture: InternalTexture): void;
  54986. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  54987. releaseEffects(): void;
  54988. /** @hidden */
  54989. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54990. /** @hidden */
  54991. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54992. /** @hidden */
  54993. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54994. /** @hidden */
  54995. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54996. }
  54997. }
  54998. declare module "babylonjs/Engines/index" {
  54999. export * from "babylonjs/Engines/constants";
  55000. export * from "babylonjs/Engines/engineCapabilities";
  55001. export * from "babylonjs/Engines/instancingAttributeInfo";
  55002. export * from "babylonjs/Engines/thinEngine";
  55003. export * from "babylonjs/Engines/engine";
  55004. export * from "babylonjs/Engines/engineStore";
  55005. export * from "babylonjs/Engines/nullEngine";
  55006. export * from "babylonjs/Engines/Extensions/index";
  55007. export * from "babylonjs/Engines/IPipelineContext";
  55008. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  55009. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  55010. export * from "babylonjs/Engines/nativeEngine";
  55011. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  55012. export * from "babylonjs/Engines/performanceConfigurator";
  55013. }
  55014. declare module "babylonjs/Events/clipboardEvents" {
  55015. /**
  55016. * Gather the list of clipboard event types as constants.
  55017. */
  55018. export class ClipboardEventTypes {
  55019. /**
  55020. * The clipboard event is fired when a copy command is active (pressed).
  55021. */
  55022. static readonly COPY: number;
  55023. /**
  55024. * The clipboard event is fired when a cut command is active (pressed).
  55025. */
  55026. static readonly CUT: number;
  55027. /**
  55028. * The clipboard event is fired when a paste command is active (pressed).
  55029. */
  55030. static readonly PASTE: number;
  55031. }
  55032. /**
  55033. * This class is used to store clipboard related info for the onClipboardObservable event.
  55034. */
  55035. export class ClipboardInfo {
  55036. /**
  55037. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55038. */
  55039. type: number;
  55040. /**
  55041. * Defines the related dom event
  55042. */
  55043. event: ClipboardEvent;
  55044. /**
  55045. *Creates an instance of ClipboardInfo.
  55046. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55047. * @param event Defines the related dom event
  55048. */
  55049. constructor(
  55050. /**
  55051. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55052. */
  55053. type: number,
  55054. /**
  55055. * Defines the related dom event
  55056. */
  55057. event: ClipboardEvent);
  55058. /**
  55059. * Get the clipboard event's type from the keycode.
  55060. * @param keyCode Defines the keyCode for the current keyboard event.
  55061. * @return {number}
  55062. */
  55063. static GetTypeFromCharacter(keyCode: number): number;
  55064. }
  55065. }
  55066. declare module "babylonjs/Events/index" {
  55067. export * from "babylonjs/Events/keyboardEvents";
  55068. export * from "babylonjs/Events/pointerEvents";
  55069. export * from "babylonjs/Events/clipboardEvents";
  55070. }
  55071. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55072. import { Scene } from "babylonjs/scene";
  55073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55074. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55075. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55076. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55077. /**
  55078. * Google Daydream controller
  55079. */
  55080. export class DaydreamController extends WebVRController {
  55081. /**
  55082. * Base Url for the controller model.
  55083. */
  55084. static MODEL_BASE_URL: string;
  55085. /**
  55086. * File name for the controller model.
  55087. */
  55088. static MODEL_FILENAME: string;
  55089. /**
  55090. * Gamepad Id prefix used to identify Daydream Controller.
  55091. */
  55092. static readonly GAMEPAD_ID_PREFIX: string;
  55093. /**
  55094. * Creates a new DaydreamController from a gamepad
  55095. * @param vrGamepad the gamepad that the controller should be created from
  55096. */
  55097. constructor(vrGamepad: any);
  55098. /**
  55099. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55100. * @param scene scene in which to add meshes
  55101. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55102. */
  55103. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55104. /**
  55105. * Called once for each button that changed state since the last frame
  55106. * @param buttonIdx Which button index changed
  55107. * @param state New state of the button
  55108. * @param changes Which properties on the state changed since last frame
  55109. */
  55110. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55111. }
  55112. }
  55113. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55114. import { Scene } from "babylonjs/scene";
  55115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55116. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55117. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55118. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55119. /**
  55120. * Gear VR Controller
  55121. */
  55122. export class GearVRController extends WebVRController {
  55123. /**
  55124. * Base Url for the controller model.
  55125. */
  55126. static MODEL_BASE_URL: string;
  55127. /**
  55128. * File name for the controller model.
  55129. */
  55130. static MODEL_FILENAME: string;
  55131. /**
  55132. * Gamepad Id prefix used to identify this controller.
  55133. */
  55134. static readonly GAMEPAD_ID_PREFIX: string;
  55135. private readonly _buttonIndexToObservableNameMap;
  55136. /**
  55137. * Creates a new GearVRController from a gamepad
  55138. * @param vrGamepad the gamepad that the controller should be created from
  55139. */
  55140. constructor(vrGamepad: any);
  55141. /**
  55142. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55143. * @param scene scene in which to add meshes
  55144. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55145. */
  55146. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55147. /**
  55148. * Called once for each button that changed state since the last frame
  55149. * @param buttonIdx Which button index changed
  55150. * @param state New state of the button
  55151. * @param changes Which properties on the state changed since last frame
  55152. */
  55153. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55154. }
  55155. }
  55156. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55157. import { Scene } from "babylonjs/scene";
  55158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55159. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55160. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55161. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55162. /**
  55163. * Generic Controller
  55164. */
  55165. export class GenericController extends WebVRController {
  55166. /**
  55167. * Base Url for the controller model.
  55168. */
  55169. static readonly MODEL_BASE_URL: string;
  55170. /**
  55171. * File name for the controller model.
  55172. */
  55173. static readonly MODEL_FILENAME: string;
  55174. /**
  55175. * Creates a new GenericController from a gamepad
  55176. * @param vrGamepad the gamepad that the controller should be created from
  55177. */
  55178. constructor(vrGamepad: any);
  55179. /**
  55180. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55181. * @param scene scene in which to add meshes
  55182. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55183. */
  55184. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55185. /**
  55186. * Called once for each button that changed state since the last frame
  55187. * @param buttonIdx Which button index changed
  55188. * @param state New state of the button
  55189. * @param changes Which properties on the state changed since last frame
  55190. */
  55191. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55192. }
  55193. }
  55194. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55195. import { Observable } from "babylonjs/Misc/observable";
  55196. import { Scene } from "babylonjs/scene";
  55197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55198. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55199. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55200. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55201. /**
  55202. * Oculus Touch Controller
  55203. */
  55204. export class OculusTouchController extends WebVRController {
  55205. /**
  55206. * Base Url for the controller model.
  55207. */
  55208. static MODEL_BASE_URL: string;
  55209. /**
  55210. * File name for the left controller model.
  55211. */
  55212. static MODEL_LEFT_FILENAME: string;
  55213. /**
  55214. * File name for the right controller model.
  55215. */
  55216. static MODEL_RIGHT_FILENAME: string;
  55217. /**
  55218. * Base Url for the Quest controller model.
  55219. */
  55220. static QUEST_MODEL_BASE_URL: string;
  55221. /**
  55222. * @hidden
  55223. * If the controllers are running on a device that needs the updated Quest controller models
  55224. */
  55225. static _IsQuest: boolean;
  55226. /**
  55227. * Fired when the secondary trigger on this controller is modified
  55228. */
  55229. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55230. /**
  55231. * Fired when the thumb rest on this controller is modified
  55232. */
  55233. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55234. /**
  55235. * Creates a new OculusTouchController from a gamepad
  55236. * @param vrGamepad the gamepad that the controller should be created from
  55237. */
  55238. constructor(vrGamepad: any);
  55239. /**
  55240. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55241. * @param scene scene in which to add meshes
  55242. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55243. */
  55244. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55245. /**
  55246. * Fired when the A button on this controller is modified
  55247. */
  55248. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55249. /**
  55250. * Fired when the B button on this controller is modified
  55251. */
  55252. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55253. /**
  55254. * Fired when the X button on this controller is modified
  55255. */
  55256. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55257. /**
  55258. * Fired when the Y button on this controller is modified
  55259. */
  55260. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55261. /**
  55262. * Called once for each button that changed state since the last frame
  55263. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55264. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55265. * 2) secondary trigger (same)
  55266. * 3) A (right) X (left), touch, pressed = value
  55267. * 4) B / Y
  55268. * 5) thumb rest
  55269. * @param buttonIdx Which button index changed
  55270. * @param state New state of the button
  55271. * @param changes Which properties on the state changed since last frame
  55272. */
  55273. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55274. }
  55275. }
  55276. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55277. import { Scene } from "babylonjs/scene";
  55278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55279. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55280. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55281. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55282. import { Observable } from "babylonjs/Misc/observable";
  55283. /**
  55284. * Vive Controller
  55285. */
  55286. export class ViveController extends WebVRController {
  55287. /**
  55288. * Base Url for the controller model.
  55289. */
  55290. static MODEL_BASE_URL: string;
  55291. /**
  55292. * File name for the controller model.
  55293. */
  55294. static MODEL_FILENAME: string;
  55295. /**
  55296. * Creates a new ViveController from a gamepad
  55297. * @param vrGamepad the gamepad that the controller should be created from
  55298. */
  55299. constructor(vrGamepad: any);
  55300. /**
  55301. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55302. * @param scene scene in which to add meshes
  55303. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55304. */
  55305. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55306. /**
  55307. * Fired when the left button on this controller is modified
  55308. */
  55309. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55310. /**
  55311. * Fired when the right button on this controller is modified
  55312. */
  55313. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55314. /**
  55315. * Fired when the menu button on this controller is modified
  55316. */
  55317. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55318. /**
  55319. * Called once for each button that changed state since the last frame
  55320. * Vive mapping:
  55321. * 0: touchpad
  55322. * 1: trigger
  55323. * 2: left AND right buttons
  55324. * 3: menu button
  55325. * @param buttonIdx Which button index changed
  55326. * @param state New state of the button
  55327. * @param changes Which properties on the state changed since last frame
  55328. */
  55329. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55330. }
  55331. }
  55332. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55333. import { Observable } from "babylonjs/Misc/observable";
  55334. import { Scene } from "babylonjs/scene";
  55335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55336. import { Ray } from "babylonjs/Culling/ray";
  55337. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55338. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55339. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55340. /**
  55341. * Defines the WindowsMotionController object that the state of the windows motion controller
  55342. */
  55343. export class WindowsMotionController extends WebVRController {
  55344. /**
  55345. * The base url used to load the left and right controller models
  55346. */
  55347. static MODEL_BASE_URL: string;
  55348. /**
  55349. * The name of the left controller model file
  55350. */
  55351. static MODEL_LEFT_FILENAME: string;
  55352. /**
  55353. * The name of the right controller model file
  55354. */
  55355. static MODEL_RIGHT_FILENAME: string;
  55356. /**
  55357. * The controller name prefix for this controller type
  55358. */
  55359. static readonly GAMEPAD_ID_PREFIX: string;
  55360. /**
  55361. * The controller id pattern for this controller type
  55362. */
  55363. private static readonly GAMEPAD_ID_PATTERN;
  55364. private _loadedMeshInfo;
  55365. protected readonly _mapping: {
  55366. buttons: string[];
  55367. buttonMeshNames: {
  55368. trigger: string;
  55369. menu: string;
  55370. grip: string;
  55371. thumbstick: string;
  55372. trackpad: string;
  55373. };
  55374. buttonObservableNames: {
  55375. trigger: string;
  55376. menu: string;
  55377. grip: string;
  55378. thumbstick: string;
  55379. trackpad: string;
  55380. };
  55381. axisMeshNames: string[];
  55382. pointingPoseMeshName: string;
  55383. };
  55384. /**
  55385. * Fired when the trackpad on this controller is clicked
  55386. */
  55387. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55388. /**
  55389. * Fired when the trackpad on this controller is modified
  55390. */
  55391. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55392. /**
  55393. * The current x and y values of this controller's trackpad
  55394. */
  55395. trackpad: StickValues;
  55396. /**
  55397. * Creates a new WindowsMotionController from a gamepad
  55398. * @param vrGamepad the gamepad that the controller should be created from
  55399. */
  55400. constructor(vrGamepad: any);
  55401. /**
  55402. * Fired when the trigger on this controller is modified
  55403. */
  55404. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55405. /**
  55406. * Fired when the menu button on this controller is modified
  55407. */
  55408. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55409. /**
  55410. * Fired when the grip button on this controller is modified
  55411. */
  55412. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55413. /**
  55414. * Fired when the thumbstick button on this controller is modified
  55415. */
  55416. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55417. /**
  55418. * Fired when the touchpad button on this controller is modified
  55419. */
  55420. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55421. /**
  55422. * Fired when the touchpad values on this controller are modified
  55423. */
  55424. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55425. protected _updateTrackpad(): void;
  55426. /**
  55427. * Called once per frame by the engine.
  55428. */
  55429. update(): void;
  55430. /**
  55431. * Called once for each button that changed state since the last frame
  55432. * @param buttonIdx Which button index changed
  55433. * @param state New state of the button
  55434. * @param changes Which properties on the state changed since last frame
  55435. */
  55436. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55437. /**
  55438. * Moves the buttons on the controller mesh based on their current state
  55439. * @param buttonName the name of the button to move
  55440. * @param buttonValue the value of the button which determines the buttons new position
  55441. */
  55442. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55443. /**
  55444. * Moves the axis on the controller mesh based on its current state
  55445. * @param axis the index of the axis
  55446. * @param axisValue the value of the axis which determines the meshes new position
  55447. * @hidden
  55448. */
  55449. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55450. /**
  55451. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55452. * @param scene scene in which to add meshes
  55453. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55454. */
  55455. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55456. /**
  55457. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55458. * can be transformed by button presses and axes values, based on this._mapping.
  55459. *
  55460. * @param scene scene in which the meshes exist
  55461. * @param meshes list of meshes that make up the controller model to process
  55462. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55463. */
  55464. private processModel;
  55465. private createMeshInfo;
  55466. /**
  55467. * Gets the ray of the controller in the direction the controller is pointing
  55468. * @param length the length the resulting ray should be
  55469. * @returns a ray in the direction the controller is pointing
  55470. */
  55471. getForwardRay(length?: number): Ray;
  55472. /**
  55473. * Disposes of the controller
  55474. */
  55475. dispose(): void;
  55476. }
  55477. /**
  55478. * This class represents a new windows motion controller in XR.
  55479. */
  55480. export class XRWindowsMotionController extends WindowsMotionController {
  55481. /**
  55482. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55483. */
  55484. protected readonly _mapping: {
  55485. buttons: string[];
  55486. buttonMeshNames: {
  55487. trigger: string;
  55488. menu: string;
  55489. grip: string;
  55490. thumbstick: string;
  55491. trackpad: string;
  55492. };
  55493. buttonObservableNames: {
  55494. trigger: string;
  55495. menu: string;
  55496. grip: string;
  55497. thumbstick: string;
  55498. trackpad: string;
  55499. };
  55500. axisMeshNames: string[];
  55501. pointingPoseMeshName: string;
  55502. };
  55503. /**
  55504. * Construct a new XR-Based windows motion controller
  55505. *
  55506. * @param gamepadInfo the gamepad object from the browser
  55507. */
  55508. constructor(gamepadInfo: any);
  55509. /**
  55510. * holds the thumbstick values (X,Y)
  55511. */
  55512. thumbstickValues: StickValues;
  55513. /**
  55514. * Fired when the thumbstick on this controller is clicked
  55515. */
  55516. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55517. /**
  55518. * Fired when the thumbstick on this controller is modified
  55519. */
  55520. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55521. /**
  55522. * Fired when the touchpad button on this controller is modified
  55523. */
  55524. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55525. /**
  55526. * Fired when the touchpad values on this controller are modified
  55527. */
  55528. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55529. /**
  55530. * Fired when the thumbstick button on this controller is modified
  55531. * here to prevent breaking changes
  55532. */
  55533. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55534. /**
  55535. * updating the thumbstick(!) and not the trackpad.
  55536. * This is named this way due to the difference between WebVR and XR and to avoid
  55537. * changing the parent class.
  55538. */
  55539. protected _updateTrackpad(): void;
  55540. /**
  55541. * Disposes the class with joy
  55542. */
  55543. dispose(): void;
  55544. }
  55545. }
  55546. declare module "babylonjs/Gamepads/Controllers/index" {
  55547. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55548. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55549. export * from "babylonjs/Gamepads/Controllers/genericController";
  55550. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55551. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55552. export * from "babylonjs/Gamepads/Controllers/viveController";
  55553. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55554. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55555. }
  55556. declare module "babylonjs/Gamepads/index" {
  55557. export * from "babylonjs/Gamepads/Controllers/index";
  55558. export * from "babylonjs/Gamepads/gamepad";
  55559. export * from "babylonjs/Gamepads/gamepadManager";
  55560. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55561. export * from "babylonjs/Gamepads/xboxGamepad";
  55562. export * from "babylonjs/Gamepads/dualShockGamepad";
  55563. }
  55564. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55565. import { Scene } from "babylonjs/scene";
  55566. import { Vector4 } from "babylonjs/Maths/math.vector";
  55567. import { Color4 } from "babylonjs/Maths/math.color";
  55568. import { Mesh } from "babylonjs/Meshes/mesh";
  55569. import { Nullable } from "babylonjs/types";
  55570. /**
  55571. * Class containing static functions to help procedurally build meshes
  55572. */
  55573. export class PolyhedronBuilder {
  55574. /**
  55575. * Creates a polyhedron mesh
  55576. * * 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
  55577. * * The parameter `size` (positive float, default 1) sets the polygon size
  55578. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55579. * * 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`
  55580. * * 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
  55581. * * 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)`)
  55582. * * 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
  55583. * * 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
  55584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55587. * @param name defines the name of the mesh
  55588. * @param options defines the options used to create the mesh
  55589. * @param scene defines the hosting scene
  55590. * @returns the polyhedron mesh
  55591. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55592. */
  55593. static CreatePolyhedron(name: string, options: {
  55594. type?: number;
  55595. size?: number;
  55596. sizeX?: number;
  55597. sizeY?: number;
  55598. sizeZ?: number;
  55599. custom?: any;
  55600. faceUV?: Vector4[];
  55601. faceColors?: Color4[];
  55602. flat?: boolean;
  55603. updatable?: boolean;
  55604. sideOrientation?: number;
  55605. frontUVs?: Vector4;
  55606. backUVs?: Vector4;
  55607. }, scene?: Nullable<Scene>): Mesh;
  55608. }
  55609. }
  55610. declare module "babylonjs/Gizmos/scaleGizmo" {
  55611. import { Observable } from "babylonjs/Misc/observable";
  55612. import { Nullable } from "babylonjs/types";
  55613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55614. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55615. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55616. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55617. import { Node } from "babylonjs/node";
  55618. /**
  55619. * Gizmo that enables scaling a mesh along 3 axis
  55620. */
  55621. export class ScaleGizmo extends Gizmo {
  55622. /**
  55623. * Internal gizmo used for interactions on the x axis
  55624. */
  55625. xGizmo: AxisScaleGizmo;
  55626. /**
  55627. * Internal gizmo used for interactions on the y axis
  55628. */
  55629. yGizmo: AxisScaleGizmo;
  55630. /**
  55631. * Internal gizmo used for interactions on the z axis
  55632. */
  55633. zGizmo: AxisScaleGizmo;
  55634. /**
  55635. * Internal gizmo used to scale all axis equally
  55636. */
  55637. uniformScaleGizmo: AxisScaleGizmo;
  55638. private _meshAttached;
  55639. private _nodeAttached;
  55640. private _updateGizmoRotationToMatchAttachedMesh;
  55641. private _snapDistance;
  55642. private _scaleRatio;
  55643. private _uniformScalingMesh;
  55644. private _octahedron;
  55645. private _sensitivity;
  55646. /** Fires an event when any of it's sub gizmos are dragged */
  55647. onDragStartObservable: Observable<unknown>;
  55648. /** Fires an event when any of it's sub gizmos are released from dragging */
  55649. onDragEndObservable: Observable<unknown>;
  55650. get attachedMesh(): Nullable<AbstractMesh>;
  55651. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55652. get attachedNode(): Nullable<Node>;
  55653. set attachedNode(node: Nullable<Node>);
  55654. /**
  55655. * Creates a ScaleGizmo
  55656. * @param gizmoLayer The utility layer the gizmo will be added to
  55657. * @param thickness display gizmo axis thickness
  55658. */
  55659. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55660. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55661. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55662. /**
  55663. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55664. */
  55665. set snapDistance(value: number);
  55666. get snapDistance(): number;
  55667. /**
  55668. * Ratio for the scale of the gizmo (Default: 1)
  55669. */
  55670. set scaleRatio(value: number);
  55671. get scaleRatio(): number;
  55672. /**
  55673. * Sensitivity factor for dragging (Default: 1)
  55674. */
  55675. set sensitivity(value: number);
  55676. get sensitivity(): number;
  55677. /**
  55678. * Disposes of the gizmo
  55679. */
  55680. dispose(): void;
  55681. }
  55682. }
  55683. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55684. import { Observable } from "babylonjs/Misc/observable";
  55685. import { Nullable } from "babylonjs/types";
  55686. import { Vector3 } from "babylonjs/Maths/math.vector";
  55687. import { Node } from "babylonjs/node";
  55688. import { Mesh } from "babylonjs/Meshes/mesh";
  55689. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55690. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55691. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55692. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55693. import { Color3 } from "babylonjs/Maths/math.color";
  55694. /**
  55695. * Single axis scale gizmo
  55696. */
  55697. export class AxisScaleGizmo extends Gizmo {
  55698. /**
  55699. * Drag behavior responsible for the gizmos dragging interactions
  55700. */
  55701. dragBehavior: PointerDragBehavior;
  55702. private _pointerObserver;
  55703. /**
  55704. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55705. */
  55706. snapDistance: number;
  55707. /**
  55708. * Event that fires each time the gizmo snaps to a new location.
  55709. * * snapDistance is the the change in distance
  55710. */
  55711. onSnapObservable: Observable<{
  55712. snapDistance: number;
  55713. }>;
  55714. /**
  55715. * If the scaling operation should be done on all axis (default: false)
  55716. */
  55717. uniformScaling: boolean;
  55718. /**
  55719. * Custom sensitivity value for the drag strength
  55720. */
  55721. sensitivity: number;
  55722. private _isEnabled;
  55723. private _parent;
  55724. private _arrow;
  55725. private _coloredMaterial;
  55726. private _hoverMaterial;
  55727. /**
  55728. * Creates an AxisScaleGizmo
  55729. * @param gizmoLayer The utility layer the gizmo will be added to
  55730. * @param dragAxis The axis which the gizmo will be able to scale on
  55731. * @param color The color of the gizmo
  55732. * @param thickness display gizmo axis thickness
  55733. */
  55734. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  55735. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55736. /**
  55737. * If the gizmo is enabled
  55738. */
  55739. set isEnabled(value: boolean);
  55740. get isEnabled(): boolean;
  55741. /**
  55742. * Disposes of the gizmo
  55743. */
  55744. dispose(): void;
  55745. /**
  55746. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55747. * @param mesh The mesh to replace the default mesh of the gizmo
  55748. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  55749. */
  55750. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  55751. }
  55752. }
  55753. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  55754. import { Observable } from "babylonjs/Misc/observable";
  55755. import { Nullable } from "babylonjs/types";
  55756. import { Vector3 } from "babylonjs/Maths/math.vector";
  55757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55758. import { Mesh } from "babylonjs/Meshes/mesh";
  55759. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55760. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55761. import { Color3 } from "babylonjs/Maths/math.color";
  55762. import "babylonjs/Meshes/Builders/boxBuilder";
  55763. /**
  55764. * Bounding box gizmo
  55765. */
  55766. export class BoundingBoxGizmo extends Gizmo {
  55767. private _lineBoundingBox;
  55768. private _rotateSpheresParent;
  55769. private _scaleBoxesParent;
  55770. private _boundingDimensions;
  55771. private _renderObserver;
  55772. private _pointerObserver;
  55773. private _scaleDragSpeed;
  55774. private _tmpQuaternion;
  55775. private _tmpVector;
  55776. private _tmpRotationMatrix;
  55777. /**
  55778. * 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)
  55779. */
  55780. ignoreChildren: boolean;
  55781. /**
  55782. * 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)
  55783. */
  55784. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  55785. /**
  55786. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  55787. */
  55788. rotationSphereSize: number;
  55789. /**
  55790. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  55791. */
  55792. scaleBoxSize: number;
  55793. /**
  55794. * 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)
  55795. */
  55796. fixedDragMeshScreenSize: boolean;
  55797. /**
  55798. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  55799. */
  55800. fixedDragMeshScreenSizeDistanceFactor: number;
  55801. /**
  55802. * Fired when a rotation sphere or scale box is dragged
  55803. */
  55804. onDragStartObservable: Observable<{}>;
  55805. /**
  55806. * Fired when a scale box is dragged
  55807. */
  55808. onScaleBoxDragObservable: Observable<{}>;
  55809. /**
  55810. * Fired when a scale box drag is ended
  55811. */
  55812. onScaleBoxDragEndObservable: Observable<{}>;
  55813. /**
  55814. * Fired when a rotation sphere is dragged
  55815. */
  55816. onRotationSphereDragObservable: Observable<{}>;
  55817. /**
  55818. * Fired when a rotation sphere drag is ended
  55819. */
  55820. onRotationSphereDragEndObservable: Observable<{}>;
  55821. /**
  55822. * 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)
  55823. */
  55824. scalePivot: Nullable<Vector3>;
  55825. /**
  55826. * Mesh used as a pivot to rotate the attached node
  55827. */
  55828. private _anchorMesh;
  55829. private _existingMeshScale;
  55830. private _dragMesh;
  55831. private pointerDragBehavior;
  55832. private coloredMaterial;
  55833. private hoverColoredMaterial;
  55834. /**
  55835. * Sets the color of the bounding box gizmo
  55836. * @param color the color to set
  55837. */
  55838. setColor(color: Color3): void;
  55839. /**
  55840. * Creates an BoundingBoxGizmo
  55841. * @param gizmoLayer The utility layer the gizmo will be added to
  55842. * @param color The color of the gizmo
  55843. */
  55844. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  55845. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  55846. private _selectNode;
  55847. /**
  55848. * Updates the bounding box information for the Gizmo
  55849. */
  55850. updateBoundingBox(): void;
  55851. private _updateRotationSpheres;
  55852. private _updateScaleBoxes;
  55853. /**
  55854. * Enables rotation on the specified axis and disables rotation on the others
  55855. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  55856. */
  55857. setEnabledRotationAxis(axis: string): void;
  55858. /**
  55859. * Enables/disables scaling
  55860. * @param enable if scaling should be enabled
  55861. * @param homogeneousScaling defines if scaling should only be homogeneous
  55862. */
  55863. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  55864. private _updateDummy;
  55865. /**
  55866. * Enables a pointer drag behavior on the bounding box of the gizmo
  55867. */
  55868. enableDragBehavior(): void;
  55869. /**
  55870. * Disposes of the gizmo
  55871. */
  55872. dispose(): void;
  55873. /**
  55874. * 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)
  55875. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  55876. * @returns the bounding box mesh with the passed in mesh as a child
  55877. */
  55878. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  55879. /**
  55880. * CustomMeshes are not supported by this gizmo
  55881. * @param mesh The mesh to replace the default mesh of the gizmo
  55882. */
  55883. setCustomMesh(mesh: Mesh): void;
  55884. }
  55885. }
  55886. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  55887. import { Observable } from "babylonjs/Misc/observable";
  55888. import { Nullable } from "babylonjs/types";
  55889. import { Vector3 } from "babylonjs/Maths/math.vector";
  55890. import { Color3 } from "babylonjs/Maths/math.color";
  55891. import { Node } from "babylonjs/node";
  55892. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55893. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55894. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55895. import "babylonjs/Meshes/Builders/linesBuilder";
  55896. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55897. /**
  55898. * Single plane rotation gizmo
  55899. */
  55900. export class PlaneRotationGizmo extends Gizmo {
  55901. /**
  55902. * Drag behavior responsible for the gizmos dragging interactions
  55903. */
  55904. dragBehavior: PointerDragBehavior;
  55905. private _pointerObserver;
  55906. /**
  55907. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  55908. */
  55909. snapDistance: number;
  55910. /**
  55911. * Event that fires each time the gizmo snaps to a new location.
  55912. * * snapDistance is the the change in distance
  55913. */
  55914. onSnapObservable: Observable<{
  55915. snapDistance: number;
  55916. }>;
  55917. private _isEnabled;
  55918. private _parent;
  55919. /**
  55920. * Creates a PlaneRotationGizmo
  55921. * @param gizmoLayer The utility layer the gizmo will be added to
  55922. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  55923. * @param color The color of the gizmo
  55924. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55925. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55926. * @param thickness display gizmo axis thickness
  55927. */
  55928. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  55929. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55930. /**
  55931. * If the gizmo is enabled
  55932. */
  55933. set isEnabled(value: boolean);
  55934. get isEnabled(): boolean;
  55935. /**
  55936. * Disposes of the gizmo
  55937. */
  55938. dispose(): void;
  55939. }
  55940. }
  55941. declare module "babylonjs/Gizmos/rotationGizmo" {
  55942. import { Observable } from "babylonjs/Misc/observable";
  55943. import { Nullable } from "babylonjs/types";
  55944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55945. import { Mesh } from "babylonjs/Meshes/mesh";
  55946. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55947. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  55948. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55949. import { Node } from "babylonjs/node";
  55950. /**
  55951. * Gizmo that enables rotating a mesh along 3 axis
  55952. */
  55953. export class RotationGizmo extends Gizmo {
  55954. /**
  55955. * Internal gizmo used for interactions on the x axis
  55956. */
  55957. xGizmo: PlaneRotationGizmo;
  55958. /**
  55959. * Internal gizmo used for interactions on the y axis
  55960. */
  55961. yGizmo: PlaneRotationGizmo;
  55962. /**
  55963. * Internal gizmo used for interactions on the z axis
  55964. */
  55965. zGizmo: PlaneRotationGizmo;
  55966. /** Fires an event when any of it's sub gizmos are dragged */
  55967. onDragStartObservable: Observable<unknown>;
  55968. /** Fires an event when any of it's sub gizmos are released from dragging */
  55969. onDragEndObservable: Observable<unknown>;
  55970. private _meshAttached;
  55971. private _nodeAttached;
  55972. get attachedMesh(): Nullable<AbstractMesh>;
  55973. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55974. get attachedNode(): Nullable<Node>;
  55975. set attachedNode(node: Nullable<Node>);
  55976. /**
  55977. * Creates a RotationGizmo
  55978. * @param gizmoLayer The utility layer the gizmo will be added to
  55979. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55980. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55981. * @param thickness display gizmo axis thickness
  55982. */
  55983. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  55984. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55985. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55986. /**
  55987. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55988. */
  55989. set snapDistance(value: number);
  55990. get snapDistance(): number;
  55991. /**
  55992. * Ratio for the scale of the gizmo (Default: 1)
  55993. */
  55994. set scaleRatio(value: number);
  55995. get scaleRatio(): number;
  55996. /**
  55997. * Disposes of the gizmo
  55998. */
  55999. dispose(): void;
  56000. /**
  56001. * CustomMeshes are not supported by this gizmo
  56002. * @param mesh The mesh to replace the default mesh of the gizmo
  56003. */
  56004. setCustomMesh(mesh: Mesh): void;
  56005. }
  56006. }
  56007. declare module "babylonjs/Gizmos/gizmoManager" {
  56008. import { Observable } from "babylonjs/Misc/observable";
  56009. import { Nullable } from "babylonjs/types";
  56010. import { Scene, IDisposable } from "babylonjs/scene";
  56011. import { Node } from "babylonjs/node";
  56012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56013. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56014. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56015. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56016. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56017. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56018. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56019. /**
  56020. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56021. */
  56022. export class GizmoManager implements IDisposable {
  56023. private scene;
  56024. /**
  56025. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56026. */
  56027. gizmos: {
  56028. positionGizmo: Nullable<PositionGizmo>;
  56029. rotationGizmo: Nullable<RotationGizmo>;
  56030. scaleGizmo: Nullable<ScaleGizmo>;
  56031. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56032. };
  56033. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56034. clearGizmoOnEmptyPointerEvent: boolean;
  56035. /** Fires an event when the manager is attached to a mesh */
  56036. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56037. /** Fires an event when the manager is attached to a node */
  56038. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56039. private _gizmosEnabled;
  56040. private _pointerObserver;
  56041. private _attachedMesh;
  56042. private _attachedNode;
  56043. private _boundingBoxColor;
  56044. private _defaultUtilityLayer;
  56045. private _defaultKeepDepthUtilityLayer;
  56046. private _thickness;
  56047. /**
  56048. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56049. */
  56050. boundingBoxDragBehavior: SixDofDragBehavior;
  56051. /**
  56052. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56053. */
  56054. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56055. /**
  56056. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56057. */
  56058. attachableNodes: Nullable<Array<Node>>;
  56059. /**
  56060. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56061. */
  56062. usePointerToAttachGizmos: boolean;
  56063. /**
  56064. * Utility layer that the bounding box gizmo belongs to
  56065. */
  56066. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56067. /**
  56068. * Utility layer that all gizmos besides bounding box belong to
  56069. */
  56070. get utilityLayer(): UtilityLayerRenderer;
  56071. /**
  56072. * Instatiates a gizmo manager
  56073. * @param scene the scene to overlay the gizmos on top of
  56074. * @param thickness display gizmo axis thickness
  56075. */
  56076. constructor(scene: Scene, thickness?: number);
  56077. /**
  56078. * Attaches a set of gizmos to the specified mesh
  56079. * @param mesh The mesh the gizmo's should be attached to
  56080. */
  56081. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56082. /**
  56083. * Attaches a set of gizmos to the specified node
  56084. * @param node The node the gizmo's should be attached to
  56085. */
  56086. attachToNode(node: Nullable<Node>): void;
  56087. /**
  56088. * If the position gizmo is enabled
  56089. */
  56090. set positionGizmoEnabled(value: boolean);
  56091. get positionGizmoEnabled(): boolean;
  56092. /**
  56093. * If the rotation gizmo is enabled
  56094. */
  56095. set rotationGizmoEnabled(value: boolean);
  56096. get rotationGizmoEnabled(): boolean;
  56097. /**
  56098. * If the scale gizmo is enabled
  56099. */
  56100. set scaleGizmoEnabled(value: boolean);
  56101. get scaleGizmoEnabled(): boolean;
  56102. /**
  56103. * If the boundingBox gizmo is enabled
  56104. */
  56105. set boundingBoxGizmoEnabled(value: boolean);
  56106. get boundingBoxGizmoEnabled(): boolean;
  56107. /**
  56108. * Disposes of the gizmo manager
  56109. */
  56110. dispose(): void;
  56111. }
  56112. }
  56113. declare module "babylonjs/Lights/directionalLight" {
  56114. import { Camera } from "babylonjs/Cameras/camera";
  56115. import { Scene } from "babylonjs/scene";
  56116. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56118. import { Light } from "babylonjs/Lights/light";
  56119. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56120. import { Effect } from "babylonjs/Materials/effect";
  56121. /**
  56122. * A directional light is defined by a direction (what a surprise!).
  56123. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56124. * 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.
  56125. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56126. */
  56127. export class DirectionalLight extends ShadowLight {
  56128. private _shadowFrustumSize;
  56129. /**
  56130. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56131. */
  56132. get shadowFrustumSize(): number;
  56133. /**
  56134. * Specifies a fix frustum size for the shadow generation.
  56135. */
  56136. set shadowFrustumSize(value: number);
  56137. private _shadowOrthoScale;
  56138. /**
  56139. * Gets the shadow projection scale against the optimal computed one.
  56140. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56141. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56142. */
  56143. get shadowOrthoScale(): number;
  56144. /**
  56145. * Sets the shadow projection scale against the optimal computed one.
  56146. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56147. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56148. */
  56149. set shadowOrthoScale(value: number);
  56150. /**
  56151. * Automatically compute the projection matrix to best fit (including all the casters)
  56152. * on each frame.
  56153. */
  56154. autoUpdateExtends: boolean;
  56155. /**
  56156. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56157. * on each frame. autoUpdateExtends must be set to true for this to work
  56158. */
  56159. autoCalcShadowZBounds: boolean;
  56160. private _orthoLeft;
  56161. private _orthoRight;
  56162. private _orthoTop;
  56163. private _orthoBottom;
  56164. /**
  56165. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56166. * The directional light is emitted from everywhere in the given direction.
  56167. * It can cast shadows.
  56168. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56169. * @param name The friendly name of the light
  56170. * @param direction The direction of the light
  56171. * @param scene The scene the light belongs to
  56172. */
  56173. constructor(name: string, direction: Vector3, scene: Scene);
  56174. /**
  56175. * Returns the string "DirectionalLight".
  56176. * @return The class name
  56177. */
  56178. getClassName(): string;
  56179. /**
  56180. * Returns the integer 1.
  56181. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56182. */
  56183. getTypeID(): number;
  56184. /**
  56185. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56186. * Returns the DirectionalLight Shadow projection matrix.
  56187. */
  56188. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56189. /**
  56190. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56191. * Returns the DirectionalLight Shadow projection matrix.
  56192. */
  56193. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56194. /**
  56195. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56196. * Returns the DirectionalLight Shadow projection matrix.
  56197. */
  56198. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56199. protected _buildUniformLayout(): void;
  56200. /**
  56201. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56202. * @param effect The effect to update
  56203. * @param lightIndex The index of the light in the effect to update
  56204. * @returns The directional light
  56205. */
  56206. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56207. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56208. /**
  56209. * Gets the minZ used for shadow according to both the scene and the light.
  56210. *
  56211. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56212. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56213. * @param activeCamera The camera we are returning the min for
  56214. * @returns the depth min z
  56215. */
  56216. getDepthMinZ(activeCamera: Camera): number;
  56217. /**
  56218. * Gets the maxZ used for shadow according to both the scene and the light.
  56219. *
  56220. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56221. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56222. * @param activeCamera The camera we are returning the max for
  56223. * @returns the depth max z
  56224. */
  56225. getDepthMaxZ(activeCamera: Camera): number;
  56226. /**
  56227. * Prepares the list of defines specific to the light type.
  56228. * @param defines the list of defines
  56229. * @param lightIndex defines the index of the light for the effect
  56230. */
  56231. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56232. }
  56233. }
  56234. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56235. import { Mesh } from "babylonjs/Meshes/mesh";
  56236. /**
  56237. * Class containing static functions to help procedurally build meshes
  56238. */
  56239. export class HemisphereBuilder {
  56240. /**
  56241. * Creates a hemisphere mesh
  56242. * @param name defines the name of the mesh
  56243. * @param options defines the options used to create the mesh
  56244. * @param scene defines the hosting scene
  56245. * @returns the hemisphere mesh
  56246. */
  56247. static CreateHemisphere(name: string, options: {
  56248. segments?: number;
  56249. diameter?: number;
  56250. sideOrientation?: number;
  56251. }, scene: any): Mesh;
  56252. }
  56253. }
  56254. declare module "babylonjs/Lights/spotLight" {
  56255. import { Nullable } from "babylonjs/types";
  56256. import { Scene } from "babylonjs/scene";
  56257. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56259. import { Effect } from "babylonjs/Materials/effect";
  56260. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56261. import { Light } from "babylonjs/Lights/light";
  56262. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56263. /**
  56264. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56265. * These values define a cone of light starting from the position, emitting toward the direction.
  56266. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56267. * and the exponent defines the speed of the decay of the light with distance (reach).
  56268. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56269. */
  56270. export class SpotLight extends ShadowLight {
  56271. private _angle;
  56272. private _innerAngle;
  56273. private _cosHalfAngle;
  56274. private _lightAngleScale;
  56275. private _lightAngleOffset;
  56276. /**
  56277. * Gets the cone angle of the spot light in Radians.
  56278. */
  56279. get angle(): number;
  56280. /**
  56281. * Sets the cone angle of the spot light in Radians.
  56282. */
  56283. set angle(value: number);
  56284. /**
  56285. * Only used in gltf falloff mode, this defines the angle where
  56286. * the directional falloff will start before cutting at angle which could be seen
  56287. * as outer angle.
  56288. */
  56289. get innerAngle(): number;
  56290. /**
  56291. * Only used in gltf falloff mode, this defines the angle where
  56292. * the directional falloff will start before cutting at angle which could be seen
  56293. * as outer angle.
  56294. */
  56295. set innerAngle(value: number);
  56296. private _shadowAngleScale;
  56297. /**
  56298. * Allows scaling the angle of the light for shadow generation only.
  56299. */
  56300. get shadowAngleScale(): number;
  56301. /**
  56302. * Allows scaling the angle of the light for shadow generation only.
  56303. */
  56304. set shadowAngleScale(value: number);
  56305. /**
  56306. * The light decay speed with the distance from the emission spot.
  56307. */
  56308. exponent: number;
  56309. private _projectionTextureMatrix;
  56310. /**
  56311. * Allows reading the projecton texture
  56312. */
  56313. get projectionTextureMatrix(): Matrix;
  56314. protected _projectionTextureLightNear: number;
  56315. /**
  56316. * Gets the near clip of the Spotlight for texture projection.
  56317. */
  56318. get projectionTextureLightNear(): number;
  56319. /**
  56320. * Sets the near clip of the Spotlight for texture projection.
  56321. */
  56322. set projectionTextureLightNear(value: number);
  56323. protected _projectionTextureLightFar: number;
  56324. /**
  56325. * Gets the far clip of the Spotlight for texture projection.
  56326. */
  56327. get projectionTextureLightFar(): number;
  56328. /**
  56329. * Sets the far clip of the Spotlight for texture projection.
  56330. */
  56331. set projectionTextureLightFar(value: number);
  56332. protected _projectionTextureUpDirection: Vector3;
  56333. /**
  56334. * Gets the Up vector of the Spotlight for texture projection.
  56335. */
  56336. get projectionTextureUpDirection(): Vector3;
  56337. /**
  56338. * Sets the Up vector of the Spotlight for texture projection.
  56339. */
  56340. set projectionTextureUpDirection(value: Vector3);
  56341. private _projectionTexture;
  56342. /**
  56343. * Gets the projection texture of the light.
  56344. */
  56345. get projectionTexture(): Nullable<BaseTexture>;
  56346. /**
  56347. * Sets the projection texture of the light.
  56348. */
  56349. set projectionTexture(value: Nullable<BaseTexture>);
  56350. private _projectionTextureViewLightDirty;
  56351. private _projectionTextureProjectionLightDirty;
  56352. private _projectionTextureDirty;
  56353. private _projectionTextureViewTargetVector;
  56354. private _projectionTextureViewLightMatrix;
  56355. private _projectionTextureProjectionLightMatrix;
  56356. private _projectionTextureScalingMatrix;
  56357. /**
  56358. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56359. * It can cast shadows.
  56360. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56361. * @param name The light friendly name
  56362. * @param position The position of the spot light in the scene
  56363. * @param direction The direction of the light in the scene
  56364. * @param angle The cone angle of the light in Radians
  56365. * @param exponent The light decay speed with the distance from the emission spot
  56366. * @param scene The scene the lights belongs to
  56367. */
  56368. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56369. /**
  56370. * Returns the string "SpotLight".
  56371. * @returns the class name
  56372. */
  56373. getClassName(): string;
  56374. /**
  56375. * Returns the integer 2.
  56376. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56377. */
  56378. getTypeID(): number;
  56379. /**
  56380. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56381. */
  56382. protected _setDirection(value: Vector3): void;
  56383. /**
  56384. * Overrides the position setter to recompute the projection texture view light Matrix.
  56385. */
  56386. protected _setPosition(value: Vector3): void;
  56387. /**
  56388. * 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.
  56389. * Returns the SpotLight.
  56390. */
  56391. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56392. protected _computeProjectionTextureViewLightMatrix(): void;
  56393. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56394. /**
  56395. * Main function for light texture projection matrix computing.
  56396. */
  56397. protected _computeProjectionTextureMatrix(): void;
  56398. protected _buildUniformLayout(): void;
  56399. private _computeAngleValues;
  56400. /**
  56401. * Sets the passed Effect "effect" with the Light textures.
  56402. * @param effect The effect to update
  56403. * @param lightIndex The index of the light in the effect to update
  56404. * @returns The light
  56405. */
  56406. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56407. /**
  56408. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56409. * @param effect The effect to update
  56410. * @param lightIndex The index of the light in the effect to update
  56411. * @returns The spot light
  56412. */
  56413. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56414. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56415. /**
  56416. * Disposes the light and the associated resources.
  56417. */
  56418. dispose(): void;
  56419. /**
  56420. * Prepares the list of defines specific to the light type.
  56421. * @param defines the list of defines
  56422. * @param lightIndex defines the index of the light for the effect
  56423. */
  56424. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56425. }
  56426. }
  56427. declare module "babylonjs/Gizmos/lightGizmo" {
  56428. import { Nullable } from "babylonjs/types";
  56429. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56430. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56431. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56432. import { Light } from "babylonjs/Lights/light";
  56433. /**
  56434. * Gizmo that enables viewing a light
  56435. */
  56436. export class LightGizmo extends Gizmo {
  56437. private _lightMesh;
  56438. private _material;
  56439. private _cachedPosition;
  56440. private _cachedForward;
  56441. private _attachedMeshParent;
  56442. /**
  56443. * Creates a LightGizmo
  56444. * @param gizmoLayer The utility layer the gizmo will be added to
  56445. */
  56446. constructor(gizmoLayer?: UtilityLayerRenderer);
  56447. private _light;
  56448. /**
  56449. * The light that the gizmo is attached to
  56450. */
  56451. set light(light: Nullable<Light>);
  56452. get light(): Nullable<Light>;
  56453. /**
  56454. * Gets the material used to render the light gizmo
  56455. */
  56456. get material(): StandardMaterial;
  56457. /**
  56458. * @hidden
  56459. * Updates the gizmo to match the attached mesh's position/rotation
  56460. */
  56461. protected _update(): void;
  56462. private static _Scale;
  56463. /**
  56464. * Creates the lines for a light mesh
  56465. */
  56466. private static _CreateLightLines;
  56467. /**
  56468. * Disposes of the light gizmo
  56469. */
  56470. dispose(): void;
  56471. private static _CreateHemisphericLightMesh;
  56472. private static _CreatePointLightMesh;
  56473. private static _CreateSpotLightMesh;
  56474. private static _CreateDirectionalLightMesh;
  56475. }
  56476. }
  56477. declare module "babylonjs/Gizmos/cameraGizmo" {
  56478. import { Nullable } from "babylonjs/types";
  56479. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56480. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56481. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56482. import { Camera } from "babylonjs/Cameras/camera";
  56483. /**
  56484. * Gizmo that enables viewing a camera
  56485. */
  56486. export class CameraGizmo extends Gizmo {
  56487. private _cameraMesh;
  56488. private _cameraLinesMesh;
  56489. private _material;
  56490. /**
  56491. * Creates a CameraGizmo
  56492. * @param gizmoLayer The utility layer the gizmo will be added to
  56493. */
  56494. constructor(gizmoLayer?: UtilityLayerRenderer);
  56495. private _camera;
  56496. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56497. get displayFrustum(): boolean;
  56498. set displayFrustum(value: boolean);
  56499. /**
  56500. * The camera that the gizmo is attached to
  56501. */
  56502. set camera(camera: Nullable<Camera>);
  56503. get camera(): Nullable<Camera>;
  56504. /**
  56505. * Gets the material used to render the camera gizmo
  56506. */
  56507. get material(): StandardMaterial;
  56508. /**
  56509. * @hidden
  56510. * Updates the gizmo to match the attached mesh's position/rotation
  56511. */
  56512. protected _update(): void;
  56513. private static _Scale;
  56514. private _invProjection;
  56515. /**
  56516. * Disposes of the camera gizmo
  56517. */
  56518. dispose(): void;
  56519. private static _CreateCameraMesh;
  56520. private static _CreateCameraFrustum;
  56521. }
  56522. }
  56523. declare module "babylonjs/Gizmos/index" {
  56524. export * from "babylonjs/Gizmos/axisDragGizmo";
  56525. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56526. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56527. export * from "babylonjs/Gizmos/gizmo";
  56528. export * from "babylonjs/Gizmos/gizmoManager";
  56529. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56530. export * from "babylonjs/Gizmos/positionGizmo";
  56531. export * from "babylonjs/Gizmos/rotationGizmo";
  56532. export * from "babylonjs/Gizmos/scaleGizmo";
  56533. export * from "babylonjs/Gizmos/lightGizmo";
  56534. export * from "babylonjs/Gizmos/cameraGizmo";
  56535. export * from "babylonjs/Gizmos/planeDragGizmo";
  56536. }
  56537. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56538. /** @hidden */
  56539. export var backgroundFragmentDeclaration: {
  56540. name: string;
  56541. shader: string;
  56542. };
  56543. }
  56544. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56545. /** @hidden */
  56546. export var backgroundUboDeclaration: {
  56547. name: string;
  56548. shader: string;
  56549. };
  56550. }
  56551. declare module "babylonjs/Shaders/background.fragment" {
  56552. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56553. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56554. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56555. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56556. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56557. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56558. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56559. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56560. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56561. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56562. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56563. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56564. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56565. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56566. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56567. /** @hidden */
  56568. export var backgroundPixelShader: {
  56569. name: string;
  56570. shader: string;
  56571. };
  56572. }
  56573. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56574. /** @hidden */
  56575. export var backgroundVertexDeclaration: {
  56576. name: string;
  56577. shader: string;
  56578. };
  56579. }
  56580. declare module "babylonjs/Shaders/background.vertex" {
  56581. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56582. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56583. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56584. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56585. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56586. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56587. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56588. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56589. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56590. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56591. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56592. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56593. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56594. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56595. /** @hidden */
  56596. export var backgroundVertexShader: {
  56597. name: string;
  56598. shader: string;
  56599. };
  56600. }
  56601. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56602. import { Nullable, int, float } from "babylonjs/types";
  56603. import { Scene } from "babylonjs/scene";
  56604. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56605. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56607. import { Mesh } from "babylonjs/Meshes/mesh";
  56608. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56609. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56610. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56611. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56612. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56613. import { Color3 } from "babylonjs/Maths/math.color";
  56614. import "babylonjs/Shaders/background.fragment";
  56615. import "babylonjs/Shaders/background.vertex";
  56616. /**
  56617. * Background material used to create an efficient environement around your scene.
  56618. */
  56619. export class BackgroundMaterial extends PushMaterial {
  56620. /**
  56621. * Standard reflectance value at parallel view angle.
  56622. */
  56623. static StandardReflectance0: number;
  56624. /**
  56625. * Standard reflectance value at grazing angle.
  56626. */
  56627. static StandardReflectance90: number;
  56628. protected _primaryColor: Color3;
  56629. /**
  56630. * Key light Color (multiply against the environement texture)
  56631. */
  56632. primaryColor: Color3;
  56633. protected __perceptualColor: Nullable<Color3>;
  56634. /**
  56635. * Experimental Internal Use Only.
  56636. *
  56637. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56638. * This acts as a helper to set the primary color to a more "human friendly" value.
  56639. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56640. * output color as close as possible from the chosen value.
  56641. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56642. * part of lighting setup.)
  56643. */
  56644. get _perceptualColor(): Nullable<Color3>;
  56645. set _perceptualColor(value: Nullable<Color3>);
  56646. protected _primaryColorShadowLevel: float;
  56647. /**
  56648. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56649. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56650. */
  56651. get primaryColorShadowLevel(): float;
  56652. set primaryColorShadowLevel(value: float);
  56653. protected _primaryColorHighlightLevel: float;
  56654. /**
  56655. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56656. * The primary color is used at the level chosen to define what the white area would look.
  56657. */
  56658. get primaryColorHighlightLevel(): float;
  56659. set primaryColorHighlightLevel(value: float);
  56660. protected _reflectionTexture: Nullable<BaseTexture>;
  56661. /**
  56662. * Reflection Texture used in the material.
  56663. * Should be author in a specific way for the best result (refer to the documentation).
  56664. */
  56665. reflectionTexture: Nullable<BaseTexture>;
  56666. protected _reflectionBlur: float;
  56667. /**
  56668. * Reflection Texture level of blur.
  56669. *
  56670. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56671. * texture twice.
  56672. */
  56673. reflectionBlur: float;
  56674. protected _diffuseTexture: Nullable<BaseTexture>;
  56675. /**
  56676. * Diffuse Texture used in the material.
  56677. * Should be author in a specific way for the best result (refer to the documentation).
  56678. */
  56679. diffuseTexture: Nullable<BaseTexture>;
  56680. protected _shadowLights: Nullable<IShadowLight[]>;
  56681. /**
  56682. * Specify the list of lights casting shadow on the material.
  56683. * All scene shadow lights will be included if null.
  56684. */
  56685. shadowLights: Nullable<IShadowLight[]>;
  56686. protected _shadowLevel: float;
  56687. /**
  56688. * Helps adjusting the shadow to a softer level if required.
  56689. * 0 means black shadows and 1 means no shadows.
  56690. */
  56691. shadowLevel: float;
  56692. protected _sceneCenter: Vector3;
  56693. /**
  56694. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  56695. * It is usually zero but might be interesting to modify according to your setup.
  56696. */
  56697. sceneCenter: Vector3;
  56698. protected _opacityFresnel: boolean;
  56699. /**
  56700. * This helps specifying that the material is falling off to the sky box at grazing angle.
  56701. * This helps ensuring a nice transition when the camera goes under the ground.
  56702. */
  56703. opacityFresnel: boolean;
  56704. protected _reflectionFresnel: boolean;
  56705. /**
  56706. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  56707. * This helps adding a mirror texture on the ground.
  56708. */
  56709. reflectionFresnel: boolean;
  56710. protected _reflectionFalloffDistance: number;
  56711. /**
  56712. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  56713. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  56714. */
  56715. reflectionFalloffDistance: number;
  56716. protected _reflectionAmount: number;
  56717. /**
  56718. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  56719. */
  56720. reflectionAmount: number;
  56721. protected _reflectionReflectance0: number;
  56722. /**
  56723. * This specifies the weight of the reflection at grazing angle.
  56724. */
  56725. reflectionReflectance0: number;
  56726. protected _reflectionReflectance90: number;
  56727. /**
  56728. * This specifies the weight of the reflection at a perpendicular point of view.
  56729. */
  56730. reflectionReflectance90: number;
  56731. /**
  56732. * Sets the reflection reflectance fresnel values according to the default standard
  56733. * empirically know to work well :-)
  56734. */
  56735. set reflectionStandardFresnelWeight(value: number);
  56736. protected _useRGBColor: boolean;
  56737. /**
  56738. * Helps to directly use the maps channels instead of their level.
  56739. */
  56740. useRGBColor: boolean;
  56741. protected _enableNoise: boolean;
  56742. /**
  56743. * This helps reducing the banding effect that could occur on the background.
  56744. */
  56745. enableNoise: boolean;
  56746. /**
  56747. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56748. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  56749. * Recommended to be keep at 1.0 except for special cases.
  56750. */
  56751. get fovMultiplier(): number;
  56752. set fovMultiplier(value: number);
  56753. private _fovMultiplier;
  56754. /**
  56755. * Enable the FOV adjustment feature controlled by fovMultiplier.
  56756. */
  56757. useEquirectangularFOV: boolean;
  56758. private _maxSimultaneousLights;
  56759. /**
  56760. * Number of Simultaneous lights allowed on the material.
  56761. */
  56762. maxSimultaneousLights: int;
  56763. private _shadowOnly;
  56764. /**
  56765. * Make the material only render shadows
  56766. */
  56767. shadowOnly: boolean;
  56768. /**
  56769. * Default configuration related to image processing available in the Background Material.
  56770. */
  56771. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56772. /**
  56773. * Keep track of the image processing observer to allow dispose and replace.
  56774. */
  56775. private _imageProcessingObserver;
  56776. /**
  56777. * Attaches a new image processing configuration to the PBR Material.
  56778. * @param configuration (if null the scene configuration will be use)
  56779. */
  56780. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56781. /**
  56782. * Gets the image processing configuration used either in this material.
  56783. */
  56784. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  56785. /**
  56786. * Sets the Default image processing configuration used either in the this material.
  56787. *
  56788. * If sets to null, the scene one is in use.
  56789. */
  56790. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  56791. /**
  56792. * Gets wether the color curves effect is enabled.
  56793. */
  56794. get cameraColorCurvesEnabled(): boolean;
  56795. /**
  56796. * Sets wether the color curves effect is enabled.
  56797. */
  56798. set cameraColorCurvesEnabled(value: boolean);
  56799. /**
  56800. * Gets wether the color grading effect is enabled.
  56801. */
  56802. get cameraColorGradingEnabled(): boolean;
  56803. /**
  56804. * Gets wether the color grading effect is enabled.
  56805. */
  56806. set cameraColorGradingEnabled(value: boolean);
  56807. /**
  56808. * Gets wether tonemapping is enabled or not.
  56809. */
  56810. get cameraToneMappingEnabled(): boolean;
  56811. /**
  56812. * Sets wether tonemapping is enabled or not
  56813. */
  56814. set cameraToneMappingEnabled(value: boolean);
  56815. /**
  56816. * The camera exposure used on this material.
  56817. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56818. * This corresponds to a photographic exposure.
  56819. */
  56820. get cameraExposure(): float;
  56821. /**
  56822. * The camera exposure used on this material.
  56823. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56824. * This corresponds to a photographic exposure.
  56825. */
  56826. set cameraExposure(value: float);
  56827. /**
  56828. * Gets The camera contrast used on this material.
  56829. */
  56830. get cameraContrast(): float;
  56831. /**
  56832. * Sets The camera contrast used on this material.
  56833. */
  56834. set cameraContrast(value: float);
  56835. /**
  56836. * Gets the Color Grading 2D Lookup Texture.
  56837. */
  56838. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56839. /**
  56840. * Sets the Color Grading 2D Lookup Texture.
  56841. */
  56842. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56843. /**
  56844. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56845. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56846. * 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;
  56847. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56848. */
  56849. get cameraColorCurves(): Nullable<ColorCurves>;
  56850. /**
  56851. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56852. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56853. * 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;
  56854. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56855. */
  56856. set cameraColorCurves(value: Nullable<ColorCurves>);
  56857. /**
  56858. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  56859. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  56860. */
  56861. switchToBGR: boolean;
  56862. private _renderTargets;
  56863. private _reflectionControls;
  56864. private _white;
  56865. private _primaryShadowColor;
  56866. private _primaryHighlightColor;
  56867. /**
  56868. * Instantiates a Background Material in the given scene
  56869. * @param name The friendly name of the material
  56870. * @param scene The scene to add the material to
  56871. */
  56872. constructor(name: string, scene: Scene);
  56873. /**
  56874. * Gets a boolean indicating that current material needs to register RTT
  56875. */
  56876. get hasRenderTargetTextures(): boolean;
  56877. /**
  56878. * The entire material has been created in order to prevent overdraw.
  56879. * @returns false
  56880. */
  56881. needAlphaTesting(): boolean;
  56882. /**
  56883. * The entire material has been created in order to prevent overdraw.
  56884. * @returns true if blending is enable
  56885. */
  56886. needAlphaBlending(): boolean;
  56887. /**
  56888. * Checks wether the material is ready to be rendered for a given mesh.
  56889. * @param mesh The mesh to render
  56890. * @param subMesh The submesh to check against
  56891. * @param useInstances Specify wether or not the material is used with instances
  56892. * @returns true if all the dependencies are ready (Textures, Effects...)
  56893. */
  56894. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56895. /**
  56896. * Compute the primary color according to the chosen perceptual color.
  56897. */
  56898. private _computePrimaryColorFromPerceptualColor;
  56899. /**
  56900. * Compute the highlights and shadow colors according to their chosen levels.
  56901. */
  56902. private _computePrimaryColors;
  56903. /**
  56904. * Build the uniform buffer used in the material.
  56905. */
  56906. buildUniformLayout(): void;
  56907. /**
  56908. * Unbind the material.
  56909. */
  56910. unbind(): void;
  56911. /**
  56912. * Bind only the world matrix to the material.
  56913. * @param world The world matrix to bind.
  56914. */
  56915. bindOnlyWorldMatrix(world: Matrix): void;
  56916. /**
  56917. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  56918. * @param world The world matrix to bind.
  56919. * @param subMesh The submesh to bind for.
  56920. */
  56921. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56922. /**
  56923. * Checks to see if a texture is used in the material.
  56924. * @param texture - Base texture to use.
  56925. * @returns - Boolean specifying if a texture is used in the material.
  56926. */
  56927. hasTexture(texture: BaseTexture): boolean;
  56928. /**
  56929. * Dispose the material.
  56930. * @param forceDisposeEffect Force disposal of the associated effect.
  56931. * @param forceDisposeTextures Force disposal of the associated textures.
  56932. */
  56933. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56934. /**
  56935. * Clones the material.
  56936. * @param name The cloned name.
  56937. * @returns The cloned material.
  56938. */
  56939. clone(name: string): BackgroundMaterial;
  56940. /**
  56941. * Serializes the current material to its JSON representation.
  56942. * @returns The JSON representation.
  56943. */
  56944. serialize(): any;
  56945. /**
  56946. * Gets the class name of the material
  56947. * @returns "BackgroundMaterial"
  56948. */
  56949. getClassName(): string;
  56950. /**
  56951. * Parse a JSON input to create back a background material.
  56952. * @param source The JSON data to parse
  56953. * @param scene The scene to create the parsed material in
  56954. * @param rootUrl The root url of the assets the material depends upon
  56955. * @returns the instantiated BackgroundMaterial.
  56956. */
  56957. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  56958. }
  56959. }
  56960. declare module "babylonjs/Helpers/environmentHelper" {
  56961. import { Observable } from "babylonjs/Misc/observable";
  56962. import { Nullable } from "babylonjs/types";
  56963. import { Scene } from "babylonjs/scene";
  56964. import { Vector3 } from "babylonjs/Maths/math.vector";
  56965. import { Color3 } from "babylonjs/Maths/math.color";
  56966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56967. import { Mesh } from "babylonjs/Meshes/mesh";
  56968. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56969. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  56970. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56971. import "babylonjs/Meshes/Builders/planeBuilder";
  56972. import "babylonjs/Meshes/Builders/boxBuilder";
  56973. /**
  56974. * Represents the different options available during the creation of
  56975. * a Environment helper.
  56976. *
  56977. * This can control the default ground, skybox and image processing setup of your scene.
  56978. */
  56979. export interface IEnvironmentHelperOptions {
  56980. /**
  56981. * Specifies whether or not to create a ground.
  56982. * True by default.
  56983. */
  56984. createGround: boolean;
  56985. /**
  56986. * Specifies the ground size.
  56987. * 15 by default.
  56988. */
  56989. groundSize: number;
  56990. /**
  56991. * The texture used on the ground for the main color.
  56992. * Comes from the BabylonJS CDN by default.
  56993. *
  56994. * Remarks: Can be either a texture or a url.
  56995. */
  56996. groundTexture: string | BaseTexture;
  56997. /**
  56998. * The color mixed in the ground texture by default.
  56999. * BabylonJS clearColor by default.
  57000. */
  57001. groundColor: Color3;
  57002. /**
  57003. * Specifies the ground opacity.
  57004. * 1 by default.
  57005. */
  57006. groundOpacity: number;
  57007. /**
  57008. * Enables the ground to receive shadows.
  57009. * True by default.
  57010. */
  57011. enableGroundShadow: boolean;
  57012. /**
  57013. * Helps preventing the shadow to be fully black on the ground.
  57014. * 0.5 by default.
  57015. */
  57016. groundShadowLevel: number;
  57017. /**
  57018. * Creates a mirror texture attach to the ground.
  57019. * false by default.
  57020. */
  57021. enableGroundMirror: boolean;
  57022. /**
  57023. * Specifies the ground mirror size ratio.
  57024. * 0.3 by default as the default kernel is 64.
  57025. */
  57026. groundMirrorSizeRatio: number;
  57027. /**
  57028. * Specifies the ground mirror blur kernel size.
  57029. * 64 by default.
  57030. */
  57031. groundMirrorBlurKernel: number;
  57032. /**
  57033. * Specifies the ground mirror visibility amount.
  57034. * 1 by default
  57035. */
  57036. groundMirrorAmount: number;
  57037. /**
  57038. * Specifies the ground mirror reflectance weight.
  57039. * This uses the standard weight of the background material to setup the fresnel effect
  57040. * of the mirror.
  57041. * 1 by default.
  57042. */
  57043. groundMirrorFresnelWeight: number;
  57044. /**
  57045. * Specifies the ground mirror Falloff distance.
  57046. * This can helps reducing the size of the reflection.
  57047. * 0 by Default.
  57048. */
  57049. groundMirrorFallOffDistance: number;
  57050. /**
  57051. * Specifies the ground mirror texture type.
  57052. * Unsigned Int by Default.
  57053. */
  57054. groundMirrorTextureType: number;
  57055. /**
  57056. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57057. * the shown objects.
  57058. */
  57059. groundYBias: number;
  57060. /**
  57061. * Specifies whether or not to create a skybox.
  57062. * True by default.
  57063. */
  57064. createSkybox: boolean;
  57065. /**
  57066. * Specifies the skybox size.
  57067. * 20 by default.
  57068. */
  57069. skyboxSize: number;
  57070. /**
  57071. * The texture used on the skybox for the main color.
  57072. * Comes from the BabylonJS CDN by default.
  57073. *
  57074. * Remarks: Can be either a texture or a url.
  57075. */
  57076. skyboxTexture: string | BaseTexture;
  57077. /**
  57078. * The color mixed in the skybox texture by default.
  57079. * BabylonJS clearColor by default.
  57080. */
  57081. skyboxColor: Color3;
  57082. /**
  57083. * The background rotation around the Y axis of the scene.
  57084. * This helps aligning the key lights of your scene with the background.
  57085. * 0 by default.
  57086. */
  57087. backgroundYRotation: number;
  57088. /**
  57089. * Compute automatically the size of the elements to best fit with the scene.
  57090. */
  57091. sizeAuto: boolean;
  57092. /**
  57093. * Default position of the rootMesh if autoSize is not true.
  57094. */
  57095. rootPosition: Vector3;
  57096. /**
  57097. * Sets up the image processing in the scene.
  57098. * true by default.
  57099. */
  57100. setupImageProcessing: boolean;
  57101. /**
  57102. * The texture used as your environment texture in the scene.
  57103. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57104. *
  57105. * Remarks: Can be either a texture or a url.
  57106. */
  57107. environmentTexture: string | BaseTexture;
  57108. /**
  57109. * The value of the exposure to apply to the scene.
  57110. * 0.6 by default if setupImageProcessing is true.
  57111. */
  57112. cameraExposure: number;
  57113. /**
  57114. * The value of the contrast to apply to the scene.
  57115. * 1.6 by default if setupImageProcessing is true.
  57116. */
  57117. cameraContrast: number;
  57118. /**
  57119. * Specifies whether or not tonemapping should be enabled in the scene.
  57120. * true by default if setupImageProcessing is true.
  57121. */
  57122. toneMappingEnabled: boolean;
  57123. }
  57124. /**
  57125. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57126. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57127. * It also helps with the default setup of your imageProcessing configuration.
  57128. */
  57129. export class EnvironmentHelper {
  57130. /**
  57131. * Default ground texture URL.
  57132. */
  57133. private static _groundTextureCDNUrl;
  57134. /**
  57135. * Default skybox texture URL.
  57136. */
  57137. private static _skyboxTextureCDNUrl;
  57138. /**
  57139. * Default environment texture URL.
  57140. */
  57141. private static _environmentTextureCDNUrl;
  57142. /**
  57143. * Creates the default options for the helper.
  57144. */
  57145. private static _getDefaultOptions;
  57146. private _rootMesh;
  57147. /**
  57148. * Gets the root mesh created by the helper.
  57149. */
  57150. get rootMesh(): Mesh;
  57151. private _skybox;
  57152. /**
  57153. * Gets the skybox created by the helper.
  57154. */
  57155. get skybox(): Nullable<Mesh>;
  57156. private _skyboxTexture;
  57157. /**
  57158. * Gets the skybox texture created by the helper.
  57159. */
  57160. get skyboxTexture(): Nullable<BaseTexture>;
  57161. private _skyboxMaterial;
  57162. /**
  57163. * Gets the skybox material created by the helper.
  57164. */
  57165. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57166. private _ground;
  57167. /**
  57168. * Gets the ground mesh created by the helper.
  57169. */
  57170. get ground(): Nullable<Mesh>;
  57171. private _groundTexture;
  57172. /**
  57173. * Gets the ground texture created by the helper.
  57174. */
  57175. get groundTexture(): Nullable<BaseTexture>;
  57176. private _groundMirror;
  57177. /**
  57178. * Gets the ground mirror created by the helper.
  57179. */
  57180. get groundMirror(): Nullable<MirrorTexture>;
  57181. /**
  57182. * Gets the ground mirror render list to helps pushing the meshes
  57183. * you wish in the ground reflection.
  57184. */
  57185. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57186. private _groundMaterial;
  57187. /**
  57188. * Gets the ground material created by the helper.
  57189. */
  57190. get groundMaterial(): Nullable<BackgroundMaterial>;
  57191. /**
  57192. * Stores the creation options.
  57193. */
  57194. private readonly _scene;
  57195. private _options;
  57196. /**
  57197. * This observable will be notified with any error during the creation of the environment,
  57198. * mainly texture creation errors.
  57199. */
  57200. onErrorObservable: Observable<{
  57201. message?: string;
  57202. exception?: any;
  57203. }>;
  57204. /**
  57205. * constructor
  57206. * @param options Defines the options we want to customize the helper
  57207. * @param scene The scene to add the material to
  57208. */
  57209. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57210. /**
  57211. * Updates the background according to the new options
  57212. * @param options
  57213. */
  57214. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57215. /**
  57216. * Sets the primary color of all the available elements.
  57217. * @param color the main color to affect to the ground and the background
  57218. */
  57219. setMainColor(color: Color3): void;
  57220. /**
  57221. * Setup the image processing according to the specified options.
  57222. */
  57223. private _setupImageProcessing;
  57224. /**
  57225. * Setup the environment texture according to the specified options.
  57226. */
  57227. private _setupEnvironmentTexture;
  57228. /**
  57229. * Setup the background according to the specified options.
  57230. */
  57231. private _setupBackground;
  57232. /**
  57233. * Get the scene sizes according to the setup.
  57234. */
  57235. private _getSceneSize;
  57236. /**
  57237. * Setup the ground according to the specified options.
  57238. */
  57239. private _setupGround;
  57240. /**
  57241. * Setup the ground material according to the specified options.
  57242. */
  57243. private _setupGroundMaterial;
  57244. /**
  57245. * Setup the ground diffuse texture according to the specified options.
  57246. */
  57247. private _setupGroundDiffuseTexture;
  57248. /**
  57249. * Setup the ground mirror texture according to the specified options.
  57250. */
  57251. private _setupGroundMirrorTexture;
  57252. /**
  57253. * Setup the ground to receive the mirror texture.
  57254. */
  57255. private _setupMirrorInGroundMaterial;
  57256. /**
  57257. * Setup the skybox according to the specified options.
  57258. */
  57259. private _setupSkybox;
  57260. /**
  57261. * Setup the skybox material according to the specified options.
  57262. */
  57263. private _setupSkyboxMaterial;
  57264. /**
  57265. * Setup the skybox reflection texture according to the specified options.
  57266. */
  57267. private _setupSkyboxReflectionTexture;
  57268. private _errorHandler;
  57269. /**
  57270. * Dispose all the elements created by the Helper.
  57271. */
  57272. dispose(): void;
  57273. }
  57274. }
  57275. declare module "babylonjs/Helpers/textureDome" {
  57276. import { Scene } from "babylonjs/scene";
  57277. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57278. import { Mesh } from "babylonjs/Meshes/mesh";
  57279. import { Texture } from "babylonjs/Materials/Textures/texture";
  57280. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57281. import "babylonjs/Meshes/Builders/sphereBuilder";
  57282. import { Nullable } from "babylonjs/types";
  57283. import { Observable } from "babylonjs/Misc/observable";
  57284. /**
  57285. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  57286. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  57287. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57288. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57289. */
  57290. export abstract class TextureDome<T extends Texture> extends TransformNode {
  57291. protected onError: Nullable<(message?: string, exception?: any) => void>;
  57292. /**
  57293. * Define the source as a Monoscopic panoramic 360/180.
  57294. */
  57295. static readonly MODE_MONOSCOPIC: number;
  57296. /**
  57297. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  57298. */
  57299. static readonly MODE_TOPBOTTOM: number;
  57300. /**
  57301. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  57302. */
  57303. static readonly MODE_SIDEBYSIDE: number;
  57304. private _halfDome;
  57305. protected _useDirectMapping: boolean;
  57306. /**
  57307. * The texture being displayed on the sphere
  57308. */
  57309. protected _texture: T;
  57310. /**
  57311. * Gets the texture being displayed on the sphere
  57312. */
  57313. get texture(): T;
  57314. /**
  57315. * Sets the texture being displayed on the sphere
  57316. */
  57317. set texture(newTexture: T);
  57318. /**
  57319. * The skybox material
  57320. */
  57321. protected _material: BackgroundMaterial;
  57322. /**
  57323. * The surface used for the dome
  57324. */
  57325. protected _mesh: Mesh;
  57326. /**
  57327. * Gets the mesh used for the dome.
  57328. */
  57329. get mesh(): Mesh;
  57330. /**
  57331. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  57332. */
  57333. private _halfDomeMask;
  57334. /**
  57335. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57336. * Also see the options.resolution property.
  57337. */
  57338. get fovMultiplier(): number;
  57339. set fovMultiplier(value: number);
  57340. protected _textureMode: number;
  57341. /**
  57342. * Gets or set the current texture mode for the texture. It can be:
  57343. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57344. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57345. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57346. */
  57347. get textureMode(): number;
  57348. /**
  57349. * Sets the current texture mode for the texture. It can be:
  57350. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57351. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57352. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57353. */
  57354. set textureMode(value: number);
  57355. /**
  57356. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  57357. */
  57358. get halfDome(): boolean;
  57359. /**
  57360. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57361. */
  57362. set halfDome(enabled: boolean);
  57363. /**
  57364. * Oberserver used in Stereoscopic VR Mode.
  57365. */
  57366. private _onBeforeCameraRenderObserver;
  57367. /**
  57368. * Observable raised when an error occured while loading the 360 image
  57369. */
  57370. onLoadErrorObservable: Observable<string>;
  57371. /**
  57372. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  57373. * @param name Element's name, child elements will append suffixes for their own names.
  57374. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  57375. * @param options An object containing optional or exposed sub element properties
  57376. */
  57377. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  57378. resolution?: number;
  57379. clickToPlay?: boolean;
  57380. autoPlay?: boolean;
  57381. loop?: boolean;
  57382. size?: number;
  57383. poster?: string;
  57384. faceForward?: boolean;
  57385. useDirectMapping?: boolean;
  57386. halfDomeMode?: boolean;
  57387. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57388. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  57389. protected _changeTextureMode(value: number): void;
  57390. /**
  57391. * Releases resources associated with this node.
  57392. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57393. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57394. */
  57395. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57396. }
  57397. }
  57398. declare module "babylonjs/Helpers/photoDome" {
  57399. import { Scene } from "babylonjs/scene";
  57400. import { Texture } from "babylonjs/Materials/Textures/texture";
  57401. import { TextureDome } from "babylonjs/Helpers/textureDome";
  57402. /**
  57403. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57404. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57405. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57406. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57407. */
  57408. export class PhotoDome extends TextureDome<Texture> {
  57409. /**
  57410. * Define the image as a Monoscopic panoramic 360 image.
  57411. */
  57412. static readonly MODE_MONOSCOPIC: number;
  57413. /**
  57414. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57415. */
  57416. static readonly MODE_TOPBOTTOM: number;
  57417. /**
  57418. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57419. */
  57420. static readonly MODE_SIDEBYSIDE: number;
  57421. /**
  57422. * Gets or sets the texture being displayed on the sphere
  57423. */
  57424. get photoTexture(): Texture;
  57425. /**
  57426. * sets the texture being displayed on the sphere
  57427. */
  57428. set photoTexture(value: Texture);
  57429. /**
  57430. * Gets the current video mode for the video. It can be:
  57431. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57432. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57433. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57434. */
  57435. get imageMode(): number;
  57436. /**
  57437. * Sets the current video mode for the video. It can be:
  57438. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57439. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57440. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57441. */
  57442. set imageMode(value: number);
  57443. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  57444. }
  57445. }
  57446. declare module "babylonjs/Misc/rgbdTextureTools" {
  57447. import "babylonjs/Shaders/rgbdDecode.fragment";
  57448. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57449. import { Texture } from "babylonjs/Materials/Textures/texture";
  57450. /**
  57451. * Class used to host RGBD texture specific utilities
  57452. */
  57453. export class RGBDTextureTools {
  57454. /**
  57455. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57456. * @param texture the texture to expand.
  57457. */
  57458. static ExpandRGBDTexture(texture: Texture): void;
  57459. }
  57460. }
  57461. declare module "babylonjs/Misc/brdfTextureTools" {
  57462. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57463. import { Scene } from "babylonjs/scene";
  57464. /**
  57465. * Class used to host texture specific utilities
  57466. */
  57467. export class BRDFTextureTools {
  57468. /**
  57469. * Prevents texture cache collision
  57470. */
  57471. private static _instanceNumber;
  57472. /**
  57473. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57474. * @param scene defines the hosting scene
  57475. * @returns the environment BRDF texture
  57476. */
  57477. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57478. private static _environmentBRDFBase64Texture;
  57479. }
  57480. }
  57481. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57482. import { Nullable } from "babylonjs/types";
  57483. import { Color3 } from "babylonjs/Maths/math.color";
  57484. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57485. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57486. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57487. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57488. import { Engine } from "babylonjs/Engines/engine";
  57489. import { Scene } from "babylonjs/scene";
  57490. /**
  57491. * @hidden
  57492. */
  57493. export interface IMaterialClearCoatDefines {
  57494. CLEARCOAT: boolean;
  57495. CLEARCOAT_DEFAULTIOR: boolean;
  57496. CLEARCOAT_TEXTURE: boolean;
  57497. CLEARCOAT_TEXTUREDIRECTUV: number;
  57498. CLEARCOAT_BUMP: boolean;
  57499. CLEARCOAT_BUMPDIRECTUV: number;
  57500. CLEARCOAT_TINT: boolean;
  57501. CLEARCOAT_TINT_TEXTURE: boolean;
  57502. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57503. /** @hidden */
  57504. _areTexturesDirty: boolean;
  57505. }
  57506. /**
  57507. * Define the code related to the clear coat parameters of the pbr material.
  57508. */
  57509. export class PBRClearCoatConfiguration {
  57510. /**
  57511. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57512. * The default fits with a polyurethane material.
  57513. */
  57514. private static readonly _DefaultIndexOfRefraction;
  57515. private _isEnabled;
  57516. /**
  57517. * Defines if the clear coat is enabled in the material.
  57518. */
  57519. isEnabled: boolean;
  57520. /**
  57521. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57522. */
  57523. intensity: number;
  57524. /**
  57525. * Defines the clear coat layer roughness.
  57526. */
  57527. roughness: number;
  57528. private _indexOfRefraction;
  57529. /**
  57530. * Defines the index of refraction of the clear coat.
  57531. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57532. * The default fits with a polyurethane material.
  57533. * Changing the default value is more performance intensive.
  57534. */
  57535. indexOfRefraction: number;
  57536. private _texture;
  57537. /**
  57538. * Stores the clear coat values in a texture.
  57539. */
  57540. texture: Nullable<BaseTexture>;
  57541. private _bumpTexture;
  57542. /**
  57543. * Define the clear coat specific bump texture.
  57544. */
  57545. bumpTexture: Nullable<BaseTexture>;
  57546. private _isTintEnabled;
  57547. /**
  57548. * Defines if the clear coat tint is enabled in the material.
  57549. */
  57550. isTintEnabled: boolean;
  57551. /**
  57552. * Defines the clear coat tint of the material.
  57553. * This is only use if tint is enabled
  57554. */
  57555. tintColor: Color3;
  57556. /**
  57557. * Defines the distance at which the tint color should be found in the
  57558. * clear coat media.
  57559. * This is only use if tint is enabled
  57560. */
  57561. tintColorAtDistance: number;
  57562. /**
  57563. * Defines the clear coat layer thickness.
  57564. * This is only use if tint is enabled
  57565. */
  57566. tintThickness: number;
  57567. private _tintTexture;
  57568. /**
  57569. * Stores the clear tint values in a texture.
  57570. * rgb is tint
  57571. * a is a thickness factor
  57572. */
  57573. tintTexture: Nullable<BaseTexture>;
  57574. /** @hidden */
  57575. private _internalMarkAllSubMeshesAsTexturesDirty;
  57576. /** @hidden */
  57577. _markAllSubMeshesAsTexturesDirty(): void;
  57578. /**
  57579. * Instantiate a new istance of clear coat configuration.
  57580. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57581. */
  57582. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57583. /**
  57584. * Gets wehter the submesh is ready to be used or not.
  57585. * @param defines the list of "defines" to update.
  57586. * @param scene defines the scene the material belongs to.
  57587. * @param engine defines the engine the material belongs to.
  57588. * @param disableBumpMap defines wether the material disables bump or not.
  57589. * @returns - boolean indicating that the submesh is ready or not.
  57590. */
  57591. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57592. /**
  57593. * Checks to see if a texture is used in the material.
  57594. * @param defines the list of "defines" to update.
  57595. * @param scene defines the scene to the material belongs to.
  57596. */
  57597. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57598. /**
  57599. * Binds the material data.
  57600. * @param uniformBuffer defines the Uniform buffer to fill in.
  57601. * @param scene defines the scene the material belongs to.
  57602. * @param engine defines the engine the material belongs to.
  57603. * @param disableBumpMap defines wether the material disables bump or not.
  57604. * @param isFrozen defines wether the material is frozen or not.
  57605. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57606. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57607. */
  57608. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57609. /**
  57610. * Checks to see if a texture is used in the material.
  57611. * @param texture - Base texture to use.
  57612. * @returns - Boolean specifying if a texture is used in the material.
  57613. */
  57614. hasTexture(texture: BaseTexture): boolean;
  57615. /**
  57616. * Returns an array of the actively used textures.
  57617. * @param activeTextures Array of BaseTextures
  57618. */
  57619. getActiveTextures(activeTextures: BaseTexture[]): void;
  57620. /**
  57621. * Returns the animatable textures.
  57622. * @param animatables Array of animatable textures.
  57623. */
  57624. getAnimatables(animatables: IAnimatable[]): void;
  57625. /**
  57626. * Disposes the resources of the material.
  57627. * @param forceDisposeTextures - Forces the disposal of all textures.
  57628. */
  57629. dispose(forceDisposeTextures?: boolean): void;
  57630. /**
  57631. * Get the current class name of the texture useful for serialization or dynamic coding.
  57632. * @returns "PBRClearCoatConfiguration"
  57633. */
  57634. getClassName(): string;
  57635. /**
  57636. * Add fallbacks to the effect fallbacks list.
  57637. * @param defines defines the Base texture to use.
  57638. * @param fallbacks defines the current fallback list.
  57639. * @param currentRank defines the current fallback rank.
  57640. * @returns the new fallback rank.
  57641. */
  57642. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57643. /**
  57644. * Add the required uniforms to the current list.
  57645. * @param uniforms defines the current uniform list.
  57646. */
  57647. static AddUniforms(uniforms: string[]): void;
  57648. /**
  57649. * Add the required samplers to the current list.
  57650. * @param samplers defines the current sampler list.
  57651. */
  57652. static AddSamplers(samplers: string[]): void;
  57653. /**
  57654. * Add the required uniforms to the current buffer.
  57655. * @param uniformBuffer defines the current uniform buffer.
  57656. */
  57657. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57658. /**
  57659. * Makes a duplicate of the current configuration into another one.
  57660. * @param clearCoatConfiguration define the config where to copy the info
  57661. */
  57662. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57663. /**
  57664. * Serializes this clear coat configuration.
  57665. * @returns - An object with the serialized config.
  57666. */
  57667. serialize(): any;
  57668. /**
  57669. * Parses a anisotropy Configuration from a serialized object.
  57670. * @param source - Serialized object.
  57671. * @param scene Defines the scene we are parsing for
  57672. * @param rootUrl Defines the rootUrl to load from
  57673. */
  57674. parse(source: any, scene: Scene, rootUrl: string): void;
  57675. }
  57676. }
  57677. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57678. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57680. import { Vector2 } from "babylonjs/Maths/math.vector";
  57681. import { Scene } from "babylonjs/scene";
  57682. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57683. import { Nullable } from "babylonjs/types";
  57684. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57685. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57686. /**
  57687. * @hidden
  57688. */
  57689. export interface IMaterialAnisotropicDefines {
  57690. ANISOTROPIC: boolean;
  57691. ANISOTROPIC_TEXTURE: boolean;
  57692. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57693. MAINUV1: boolean;
  57694. _areTexturesDirty: boolean;
  57695. _needUVs: boolean;
  57696. }
  57697. /**
  57698. * Define the code related to the anisotropic parameters of the pbr material.
  57699. */
  57700. export class PBRAnisotropicConfiguration {
  57701. private _isEnabled;
  57702. /**
  57703. * Defines if the anisotropy is enabled in the material.
  57704. */
  57705. isEnabled: boolean;
  57706. /**
  57707. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  57708. */
  57709. intensity: number;
  57710. /**
  57711. * Defines if the effect is along the tangents, bitangents or in between.
  57712. * By default, the effect is "strectching" the highlights along the tangents.
  57713. */
  57714. direction: Vector2;
  57715. private _texture;
  57716. /**
  57717. * Stores the anisotropy values in a texture.
  57718. * rg is direction (like normal from -1 to 1)
  57719. * b is a intensity
  57720. */
  57721. texture: Nullable<BaseTexture>;
  57722. /** @hidden */
  57723. private _internalMarkAllSubMeshesAsTexturesDirty;
  57724. /** @hidden */
  57725. _markAllSubMeshesAsTexturesDirty(): void;
  57726. /**
  57727. * Instantiate a new istance of anisotropy configuration.
  57728. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57729. */
  57730. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57731. /**
  57732. * Specifies that the submesh is ready to be used.
  57733. * @param defines the list of "defines" to update.
  57734. * @param scene defines the scene the material belongs to.
  57735. * @returns - boolean indicating that the submesh is ready or not.
  57736. */
  57737. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  57738. /**
  57739. * Checks to see if a texture is used in the material.
  57740. * @param defines the list of "defines" to update.
  57741. * @param mesh the mesh we are preparing the defines for.
  57742. * @param scene defines the scene the material belongs to.
  57743. */
  57744. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  57745. /**
  57746. * Binds the material data.
  57747. * @param uniformBuffer defines the Uniform buffer to fill in.
  57748. * @param scene defines the scene the material belongs to.
  57749. * @param isFrozen defines wether the material is frozen or not.
  57750. */
  57751. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57752. /**
  57753. * Checks to see if a texture is used in the material.
  57754. * @param texture - Base texture to use.
  57755. * @returns - Boolean specifying if a texture is used in the material.
  57756. */
  57757. hasTexture(texture: BaseTexture): boolean;
  57758. /**
  57759. * Returns an array of the actively used textures.
  57760. * @param activeTextures Array of BaseTextures
  57761. */
  57762. getActiveTextures(activeTextures: BaseTexture[]): void;
  57763. /**
  57764. * Returns the animatable textures.
  57765. * @param animatables Array of animatable textures.
  57766. */
  57767. getAnimatables(animatables: IAnimatable[]): void;
  57768. /**
  57769. * Disposes the resources of the material.
  57770. * @param forceDisposeTextures - Forces the disposal of all textures.
  57771. */
  57772. dispose(forceDisposeTextures?: boolean): void;
  57773. /**
  57774. * Get the current class name of the texture useful for serialization or dynamic coding.
  57775. * @returns "PBRAnisotropicConfiguration"
  57776. */
  57777. getClassName(): string;
  57778. /**
  57779. * Add fallbacks to the effect fallbacks list.
  57780. * @param defines defines the Base texture to use.
  57781. * @param fallbacks defines the current fallback list.
  57782. * @param currentRank defines the current fallback rank.
  57783. * @returns the new fallback rank.
  57784. */
  57785. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57786. /**
  57787. * Add the required uniforms to the current list.
  57788. * @param uniforms defines the current uniform list.
  57789. */
  57790. static AddUniforms(uniforms: string[]): void;
  57791. /**
  57792. * Add the required uniforms to the current buffer.
  57793. * @param uniformBuffer defines the current uniform buffer.
  57794. */
  57795. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57796. /**
  57797. * Add the required samplers to the current list.
  57798. * @param samplers defines the current sampler list.
  57799. */
  57800. static AddSamplers(samplers: string[]): void;
  57801. /**
  57802. * Makes a duplicate of the current configuration into another one.
  57803. * @param anisotropicConfiguration define the config where to copy the info
  57804. */
  57805. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  57806. /**
  57807. * Serializes this anisotropy configuration.
  57808. * @returns - An object with the serialized config.
  57809. */
  57810. serialize(): any;
  57811. /**
  57812. * Parses a anisotropy Configuration from a serialized object.
  57813. * @param source - Serialized object.
  57814. * @param scene Defines the scene we are parsing for
  57815. * @param rootUrl Defines the rootUrl to load from
  57816. */
  57817. parse(source: any, scene: Scene, rootUrl: string): void;
  57818. }
  57819. }
  57820. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  57821. import { Scene } from "babylonjs/scene";
  57822. /**
  57823. * @hidden
  57824. */
  57825. export interface IMaterialBRDFDefines {
  57826. BRDF_V_HEIGHT_CORRELATED: boolean;
  57827. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57828. SPHERICAL_HARMONICS: boolean;
  57829. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57830. /** @hidden */
  57831. _areMiscDirty: boolean;
  57832. }
  57833. /**
  57834. * Define the code related to the BRDF parameters of the pbr material.
  57835. */
  57836. export class PBRBRDFConfiguration {
  57837. /**
  57838. * Default value used for the energy conservation.
  57839. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57840. */
  57841. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  57842. /**
  57843. * Default value used for the Smith Visibility Height Correlated mode.
  57844. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57845. */
  57846. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  57847. /**
  57848. * Default value used for the IBL diffuse part.
  57849. * This can help switching back to the polynomials mode globally which is a tiny bit
  57850. * less GPU intensive at the drawback of a lower quality.
  57851. */
  57852. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  57853. /**
  57854. * Default value used for activating energy conservation for the specular workflow.
  57855. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57856. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57857. */
  57858. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  57859. private _useEnergyConservation;
  57860. /**
  57861. * Defines if the material uses energy conservation.
  57862. */
  57863. useEnergyConservation: boolean;
  57864. private _useSmithVisibilityHeightCorrelated;
  57865. /**
  57866. * LEGACY Mode set to false
  57867. * Defines if the material uses height smith correlated visibility term.
  57868. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  57869. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  57870. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  57871. * Not relying on height correlated will also disable energy conservation.
  57872. */
  57873. useSmithVisibilityHeightCorrelated: boolean;
  57874. private _useSphericalHarmonics;
  57875. /**
  57876. * LEGACY Mode set to false
  57877. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  57878. * diffuse part of the IBL.
  57879. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  57880. * to the ground truth.
  57881. */
  57882. useSphericalHarmonics: boolean;
  57883. private _useSpecularGlossinessInputEnergyConservation;
  57884. /**
  57885. * Defines if the material uses energy conservation, when the specular workflow is active.
  57886. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57887. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57888. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  57889. */
  57890. useSpecularGlossinessInputEnergyConservation: boolean;
  57891. /** @hidden */
  57892. private _internalMarkAllSubMeshesAsMiscDirty;
  57893. /** @hidden */
  57894. _markAllSubMeshesAsMiscDirty(): void;
  57895. /**
  57896. * Instantiate a new istance of clear coat configuration.
  57897. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  57898. */
  57899. constructor(markAllSubMeshesAsMiscDirty: () => void);
  57900. /**
  57901. * Checks to see if a texture is used in the material.
  57902. * @param defines the list of "defines" to update.
  57903. */
  57904. prepareDefines(defines: IMaterialBRDFDefines): void;
  57905. /**
  57906. * Get the current class name of the texture useful for serialization or dynamic coding.
  57907. * @returns "PBRClearCoatConfiguration"
  57908. */
  57909. getClassName(): string;
  57910. /**
  57911. * Makes a duplicate of the current configuration into another one.
  57912. * @param brdfConfiguration define the config where to copy the info
  57913. */
  57914. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  57915. /**
  57916. * Serializes this BRDF configuration.
  57917. * @returns - An object with the serialized config.
  57918. */
  57919. serialize(): any;
  57920. /**
  57921. * Parses a anisotropy Configuration from a serialized object.
  57922. * @param source - Serialized object.
  57923. * @param scene Defines the scene we are parsing for
  57924. * @param rootUrl Defines the rootUrl to load from
  57925. */
  57926. parse(source: any, scene: Scene, rootUrl: string): void;
  57927. }
  57928. }
  57929. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  57930. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57931. import { Color3 } from "babylonjs/Maths/math.color";
  57932. import { Scene } from "babylonjs/scene";
  57933. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57934. import { Nullable } from "babylonjs/types";
  57935. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57936. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57937. /**
  57938. * @hidden
  57939. */
  57940. export interface IMaterialSheenDefines {
  57941. SHEEN: boolean;
  57942. SHEEN_TEXTURE: boolean;
  57943. SHEEN_TEXTUREDIRECTUV: number;
  57944. SHEEN_LINKWITHALBEDO: boolean;
  57945. SHEEN_ROUGHNESS: boolean;
  57946. SHEEN_ALBEDOSCALING: boolean;
  57947. /** @hidden */
  57948. _areTexturesDirty: boolean;
  57949. }
  57950. /**
  57951. * Define the code related to the Sheen parameters of the pbr material.
  57952. */
  57953. export class PBRSheenConfiguration {
  57954. private _isEnabled;
  57955. /**
  57956. * Defines if the material uses sheen.
  57957. */
  57958. isEnabled: boolean;
  57959. private _linkSheenWithAlbedo;
  57960. /**
  57961. * Defines if the sheen is linked to the sheen color.
  57962. */
  57963. linkSheenWithAlbedo: boolean;
  57964. /**
  57965. * Defines the sheen intensity.
  57966. */
  57967. intensity: number;
  57968. /**
  57969. * Defines the sheen color.
  57970. */
  57971. color: Color3;
  57972. private _texture;
  57973. /**
  57974. * Stores the sheen tint values in a texture.
  57975. * rgb is tint
  57976. * a is a intensity or roughness if roughness has been defined
  57977. */
  57978. texture: Nullable<BaseTexture>;
  57979. private _roughness;
  57980. /**
  57981. * Defines the sheen roughness.
  57982. * It is not taken into account if linkSheenWithAlbedo is true.
  57983. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  57984. */
  57985. roughness: Nullable<number>;
  57986. private _albedoScaling;
  57987. /**
  57988. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  57989. * It allows the strength of the sheen effect to not depend on the base color of the material,
  57990. * making it easier to setup and tweak the effect
  57991. */
  57992. albedoScaling: boolean;
  57993. /** @hidden */
  57994. private _internalMarkAllSubMeshesAsTexturesDirty;
  57995. /** @hidden */
  57996. _markAllSubMeshesAsTexturesDirty(): void;
  57997. /**
  57998. * Instantiate a new istance of clear coat configuration.
  57999. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58000. */
  58001. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58002. /**
  58003. * Specifies that the submesh is ready to be used.
  58004. * @param defines the list of "defines" to update.
  58005. * @param scene defines the scene the material belongs to.
  58006. * @returns - boolean indicating that the submesh is ready or not.
  58007. */
  58008. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  58009. /**
  58010. * Checks to see if a texture is used in the material.
  58011. * @param defines the list of "defines" to update.
  58012. * @param scene defines the scene the material belongs to.
  58013. */
  58014. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  58015. /**
  58016. * Binds the material data.
  58017. * @param uniformBuffer defines the Uniform buffer to fill in.
  58018. * @param scene defines the scene the material belongs to.
  58019. * @param isFrozen defines wether the material is frozen or not.
  58020. */
  58021. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58022. /**
  58023. * Checks to see if a texture is used in the material.
  58024. * @param texture - Base texture to use.
  58025. * @returns - Boolean specifying if a texture is used in the material.
  58026. */
  58027. hasTexture(texture: BaseTexture): boolean;
  58028. /**
  58029. * Returns an array of the actively used textures.
  58030. * @param activeTextures Array of BaseTextures
  58031. */
  58032. getActiveTextures(activeTextures: BaseTexture[]): void;
  58033. /**
  58034. * Returns the animatable textures.
  58035. * @param animatables Array of animatable textures.
  58036. */
  58037. getAnimatables(animatables: IAnimatable[]): void;
  58038. /**
  58039. * Disposes the resources of the material.
  58040. * @param forceDisposeTextures - Forces the disposal of all textures.
  58041. */
  58042. dispose(forceDisposeTextures?: boolean): void;
  58043. /**
  58044. * Get the current class name of the texture useful for serialization or dynamic coding.
  58045. * @returns "PBRSheenConfiguration"
  58046. */
  58047. getClassName(): string;
  58048. /**
  58049. * Add fallbacks to the effect fallbacks list.
  58050. * @param defines defines the Base texture to use.
  58051. * @param fallbacks defines the current fallback list.
  58052. * @param currentRank defines the current fallback rank.
  58053. * @returns the new fallback rank.
  58054. */
  58055. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58056. /**
  58057. * Add the required uniforms to the current list.
  58058. * @param uniforms defines the current uniform list.
  58059. */
  58060. static AddUniforms(uniforms: string[]): void;
  58061. /**
  58062. * Add the required uniforms to the current buffer.
  58063. * @param uniformBuffer defines the current uniform buffer.
  58064. */
  58065. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58066. /**
  58067. * Add the required samplers to the current list.
  58068. * @param samplers defines the current sampler list.
  58069. */
  58070. static AddSamplers(samplers: string[]): void;
  58071. /**
  58072. * Makes a duplicate of the current configuration into another one.
  58073. * @param sheenConfiguration define the config where to copy the info
  58074. */
  58075. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  58076. /**
  58077. * Serializes this BRDF configuration.
  58078. * @returns - An object with the serialized config.
  58079. */
  58080. serialize(): any;
  58081. /**
  58082. * Parses a anisotropy Configuration from a serialized object.
  58083. * @param source - Serialized object.
  58084. * @param scene Defines the scene we are parsing for
  58085. * @param rootUrl Defines the rootUrl to load from
  58086. */
  58087. parse(source: any, scene: Scene, rootUrl: string): void;
  58088. }
  58089. }
  58090. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  58091. import { Nullable } from "babylonjs/types";
  58092. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58093. import { Color3 } from "babylonjs/Maths/math.color";
  58094. import { SmartArray } from "babylonjs/Misc/smartArray";
  58095. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58096. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58097. import { Effect } from "babylonjs/Materials/effect";
  58098. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58099. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58100. import { Engine } from "babylonjs/Engines/engine";
  58101. import { Scene } from "babylonjs/scene";
  58102. /**
  58103. * @hidden
  58104. */
  58105. export interface IMaterialSubSurfaceDefines {
  58106. SUBSURFACE: boolean;
  58107. SS_REFRACTION: boolean;
  58108. SS_TRANSLUCENCY: boolean;
  58109. SS_SCATTERING: boolean;
  58110. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58111. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58112. SS_REFRACTIONMAP_3D: boolean;
  58113. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58114. SS_LODINREFRACTIONALPHA: boolean;
  58115. SS_GAMMAREFRACTION: boolean;
  58116. SS_RGBDREFRACTION: boolean;
  58117. SS_LINEARSPECULARREFRACTION: boolean;
  58118. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58119. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58120. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58121. /** @hidden */
  58122. _areTexturesDirty: boolean;
  58123. }
  58124. /**
  58125. * Define the code related to the sub surface parameters of the pbr material.
  58126. */
  58127. export class PBRSubSurfaceConfiguration {
  58128. private _isRefractionEnabled;
  58129. /**
  58130. * Defines if the refraction is enabled in the material.
  58131. */
  58132. isRefractionEnabled: boolean;
  58133. private _isTranslucencyEnabled;
  58134. /**
  58135. * Defines if the translucency is enabled in the material.
  58136. */
  58137. isTranslucencyEnabled: boolean;
  58138. private _isScatteringEnabled;
  58139. /**
  58140. * Defines if the sub surface scattering is enabled in the material.
  58141. */
  58142. isScatteringEnabled: boolean;
  58143. private _scatteringDiffusionProfileIndex;
  58144. /**
  58145. * Diffusion profile for subsurface scattering.
  58146. * Useful for better scattering in the skins or foliages.
  58147. */
  58148. get scatteringDiffusionProfile(): Nullable<Color3>;
  58149. set scatteringDiffusionProfile(c: Nullable<Color3>);
  58150. /**
  58151. * Defines the refraction intensity of the material.
  58152. * The refraction when enabled replaces the Diffuse part of the material.
  58153. * The intensity helps transitionning between diffuse and refraction.
  58154. */
  58155. refractionIntensity: number;
  58156. /**
  58157. * Defines the translucency intensity of the material.
  58158. * When translucency has been enabled, this defines how much of the "translucency"
  58159. * is addded to the diffuse part of the material.
  58160. */
  58161. translucencyIntensity: number;
  58162. /**
  58163. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  58164. */
  58165. useAlbedoToTintRefraction: boolean;
  58166. private _thicknessTexture;
  58167. /**
  58168. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  58169. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  58170. * 0 would mean minimumThickness
  58171. * 1 would mean maximumThickness
  58172. * The other channels might be use as a mask to vary the different effects intensity.
  58173. */
  58174. thicknessTexture: Nullable<BaseTexture>;
  58175. private _refractionTexture;
  58176. /**
  58177. * Defines the texture to use for refraction.
  58178. */
  58179. refractionTexture: Nullable<BaseTexture>;
  58180. private _indexOfRefraction;
  58181. /**
  58182. * Index of refraction of the material base layer.
  58183. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58184. *
  58185. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58186. *
  58187. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58188. */
  58189. indexOfRefraction: number;
  58190. private _volumeIndexOfRefraction;
  58191. /**
  58192. * Index of refraction of the material's volume.
  58193. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58194. *
  58195. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58196. * the volume will use the same IOR as the surface.
  58197. */
  58198. get volumeIndexOfRefraction(): number;
  58199. set volumeIndexOfRefraction(value: number);
  58200. private _invertRefractionY;
  58201. /**
  58202. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58203. */
  58204. invertRefractionY: boolean;
  58205. private _linkRefractionWithTransparency;
  58206. /**
  58207. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58208. * Materials half opaque for instance using refraction could benefit from this control.
  58209. */
  58210. linkRefractionWithTransparency: boolean;
  58211. /**
  58212. * Defines the minimum thickness stored in the thickness map.
  58213. * If no thickness map is defined, this value will be used to simulate thickness.
  58214. */
  58215. minimumThickness: number;
  58216. /**
  58217. * Defines the maximum thickness stored in the thickness map.
  58218. */
  58219. maximumThickness: number;
  58220. /**
  58221. * Defines the volume tint of the material.
  58222. * This is used for both translucency and scattering.
  58223. */
  58224. tintColor: Color3;
  58225. /**
  58226. * Defines the distance at which the tint color should be found in the media.
  58227. * This is used for refraction only.
  58228. */
  58229. tintColorAtDistance: number;
  58230. /**
  58231. * Defines how far each channel transmit through the media.
  58232. * It is defined as a color to simplify it selection.
  58233. */
  58234. diffusionDistance: Color3;
  58235. private _useMaskFromThicknessTexture;
  58236. /**
  58237. * Stores the intensity of the different subsurface effects in the thickness texture.
  58238. * * the green channel is the translucency intensity.
  58239. * * the blue channel is the scattering intensity.
  58240. * * the alpha channel is the refraction intensity.
  58241. */
  58242. useMaskFromThicknessTexture: boolean;
  58243. private _scene;
  58244. /** @hidden */
  58245. private _internalMarkAllSubMeshesAsTexturesDirty;
  58246. private _internalMarkScenePrePassDirty;
  58247. /** @hidden */
  58248. _markAllSubMeshesAsTexturesDirty(): void;
  58249. /** @hidden */
  58250. _markScenePrePassDirty(): void;
  58251. /**
  58252. * Instantiate a new istance of sub surface configuration.
  58253. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58254. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58255. * @param scene The scene
  58256. */
  58257. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58258. /**
  58259. * Gets wehter the submesh is ready to be used or not.
  58260. * @param defines the list of "defines" to update.
  58261. * @param scene defines the scene the material belongs to.
  58262. * @returns - boolean indicating that the submesh is ready or not.
  58263. */
  58264. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58265. /**
  58266. * Checks to see if a texture is used in the material.
  58267. * @param defines the list of "defines" to update.
  58268. * @param scene defines the scene to the material belongs to.
  58269. */
  58270. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58271. /**
  58272. * Binds the material data.
  58273. * @param uniformBuffer defines the Uniform buffer to fill in.
  58274. * @param scene defines the scene the material belongs to.
  58275. * @param engine defines the engine the material belongs to.
  58276. * @param isFrozen defines whether the material is frozen or not.
  58277. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58278. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58279. */
  58280. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58281. /**
  58282. * Unbinds the material from the mesh.
  58283. * @param activeEffect defines the effect that should be unbound from.
  58284. * @returns true if unbound, otherwise false
  58285. */
  58286. unbind(activeEffect: Effect): boolean;
  58287. /**
  58288. * Returns the texture used for refraction or null if none is used.
  58289. * @param scene defines the scene the material belongs to.
  58290. * @returns - Refraction texture if present. If no refraction texture and refraction
  58291. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58292. */
  58293. private _getRefractionTexture;
  58294. /**
  58295. * Returns true if alpha blending should be disabled.
  58296. */
  58297. get disableAlphaBlending(): boolean;
  58298. /**
  58299. * Fills the list of render target textures.
  58300. * @param renderTargets the list of render targets to update
  58301. */
  58302. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58303. /**
  58304. * Checks to see if a texture is used in the material.
  58305. * @param texture - Base texture to use.
  58306. * @returns - Boolean specifying if a texture is used in the material.
  58307. */
  58308. hasTexture(texture: BaseTexture): boolean;
  58309. /**
  58310. * Gets a boolean indicating that current material needs to register RTT
  58311. * @returns true if this uses a render target otherwise false.
  58312. */
  58313. hasRenderTargetTextures(): boolean;
  58314. /**
  58315. * Returns an array of the actively used textures.
  58316. * @param activeTextures Array of BaseTextures
  58317. */
  58318. getActiveTextures(activeTextures: BaseTexture[]): void;
  58319. /**
  58320. * Returns the animatable textures.
  58321. * @param animatables Array of animatable textures.
  58322. */
  58323. getAnimatables(animatables: IAnimatable[]): void;
  58324. /**
  58325. * Disposes the resources of the material.
  58326. * @param forceDisposeTextures - Forces the disposal of all textures.
  58327. */
  58328. dispose(forceDisposeTextures?: boolean): void;
  58329. /**
  58330. * Get the current class name of the texture useful for serialization or dynamic coding.
  58331. * @returns "PBRSubSurfaceConfiguration"
  58332. */
  58333. getClassName(): string;
  58334. /**
  58335. * Add fallbacks to the effect fallbacks list.
  58336. * @param defines defines the Base texture to use.
  58337. * @param fallbacks defines the current fallback list.
  58338. * @param currentRank defines the current fallback rank.
  58339. * @returns the new fallback rank.
  58340. */
  58341. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58342. /**
  58343. * Add the required uniforms to the current list.
  58344. * @param uniforms defines the current uniform list.
  58345. */
  58346. static AddUniforms(uniforms: string[]): void;
  58347. /**
  58348. * Add the required samplers to the current list.
  58349. * @param samplers defines the current sampler list.
  58350. */
  58351. static AddSamplers(samplers: string[]): void;
  58352. /**
  58353. * Add the required uniforms to the current buffer.
  58354. * @param uniformBuffer defines the current uniform buffer.
  58355. */
  58356. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58357. /**
  58358. * Makes a duplicate of the current configuration into another one.
  58359. * @param configuration define the config where to copy the info
  58360. */
  58361. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58362. /**
  58363. * Serializes this Sub Surface configuration.
  58364. * @returns - An object with the serialized config.
  58365. */
  58366. serialize(): any;
  58367. /**
  58368. * Parses a anisotropy Configuration from a serialized object.
  58369. * @param source - Serialized object.
  58370. * @param scene Defines the scene we are parsing for
  58371. * @param rootUrl Defines the rootUrl to load from
  58372. */
  58373. parse(source: any, scene: Scene, rootUrl: string): void;
  58374. }
  58375. }
  58376. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58377. /** @hidden */
  58378. export var pbrFragmentDeclaration: {
  58379. name: string;
  58380. shader: string;
  58381. };
  58382. }
  58383. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58384. /** @hidden */
  58385. export var pbrUboDeclaration: {
  58386. name: string;
  58387. shader: string;
  58388. };
  58389. }
  58390. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58391. /** @hidden */
  58392. export var pbrFragmentExtraDeclaration: {
  58393. name: string;
  58394. shader: string;
  58395. };
  58396. }
  58397. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58398. /** @hidden */
  58399. export var pbrFragmentSamplersDeclaration: {
  58400. name: string;
  58401. shader: string;
  58402. };
  58403. }
  58404. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58405. /** @hidden */
  58406. export var importanceSampling: {
  58407. name: string;
  58408. shader: string;
  58409. };
  58410. }
  58411. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58412. /** @hidden */
  58413. export var pbrHelperFunctions: {
  58414. name: string;
  58415. shader: string;
  58416. };
  58417. }
  58418. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58419. /** @hidden */
  58420. export var harmonicsFunctions: {
  58421. name: string;
  58422. shader: string;
  58423. };
  58424. }
  58425. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58426. /** @hidden */
  58427. export var pbrDirectLightingSetupFunctions: {
  58428. name: string;
  58429. shader: string;
  58430. };
  58431. }
  58432. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58433. /** @hidden */
  58434. export var pbrDirectLightingFalloffFunctions: {
  58435. name: string;
  58436. shader: string;
  58437. };
  58438. }
  58439. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58440. /** @hidden */
  58441. export var pbrBRDFFunctions: {
  58442. name: string;
  58443. shader: string;
  58444. };
  58445. }
  58446. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58447. /** @hidden */
  58448. export var hdrFilteringFunctions: {
  58449. name: string;
  58450. shader: string;
  58451. };
  58452. }
  58453. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58454. /** @hidden */
  58455. export var pbrDirectLightingFunctions: {
  58456. name: string;
  58457. shader: string;
  58458. };
  58459. }
  58460. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58461. /** @hidden */
  58462. export var pbrIBLFunctions: {
  58463. name: string;
  58464. shader: string;
  58465. };
  58466. }
  58467. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58468. /** @hidden */
  58469. export var pbrBlockAlbedoOpacity: {
  58470. name: string;
  58471. shader: string;
  58472. };
  58473. }
  58474. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58475. /** @hidden */
  58476. export var pbrBlockReflectivity: {
  58477. name: string;
  58478. shader: string;
  58479. };
  58480. }
  58481. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58482. /** @hidden */
  58483. export var pbrBlockAmbientOcclusion: {
  58484. name: string;
  58485. shader: string;
  58486. };
  58487. }
  58488. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58489. /** @hidden */
  58490. export var pbrBlockAlphaFresnel: {
  58491. name: string;
  58492. shader: string;
  58493. };
  58494. }
  58495. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58496. /** @hidden */
  58497. export var pbrBlockAnisotropic: {
  58498. name: string;
  58499. shader: string;
  58500. };
  58501. }
  58502. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58503. /** @hidden */
  58504. export var pbrBlockReflection: {
  58505. name: string;
  58506. shader: string;
  58507. };
  58508. }
  58509. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58510. /** @hidden */
  58511. export var pbrBlockSheen: {
  58512. name: string;
  58513. shader: string;
  58514. };
  58515. }
  58516. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58517. /** @hidden */
  58518. export var pbrBlockClearcoat: {
  58519. name: string;
  58520. shader: string;
  58521. };
  58522. }
  58523. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58524. /** @hidden */
  58525. export var pbrBlockSubSurface: {
  58526. name: string;
  58527. shader: string;
  58528. };
  58529. }
  58530. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58531. /** @hidden */
  58532. export var pbrBlockNormalGeometric: {
  58533. name: string;
  58534. shader: string;
  58535. };
  58536. }
  58537. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58538. /** @hidden */
  58539. export var pbrBlockNormalFinal: {
  58540. name: string;
  58541. shader: string;
  58542. };
  58543. }
  58544. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58545. /** @hidden */
  58546. export var pbrBlockLightmapInit: {
  58547. name: string;
  58548. shader: string;
  58549. };
  58550. }
  58551. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58552. /** @hidden */
  58553. export var pbrBlockGeometryInfo: {
  58554. name: string;
  58555. shader: string;
  58556. };
  58557. }
  58558. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58559. /** @hidden */
  58560. export var pbrBlockReflectance0: {
  58561. name: string;
  58562. shader: string;
  58563. };
  58564. }
  58565. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58566. /** @hidden */
  58567. export var pbrBlockReflectance: {
  58568. name: string;
  58569. shader: string;
  58570. };
  58571. }
  58572. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58573. /** @hidden */
  58574. export var pbrBlockDirectLighting: {
  58575. name: string;
  58576. shader: string;
  58577. };
  58578. }
  58579. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58580. /** @hidden */
  58581. export var pbrBlockFinalLitComponents: {
  58582. name: string;
  58583. shader: string;
  58584. };
  58585. }
  58586. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58587. /** @hidden */
  58588. export var pbrBlockFinalUnlitComponents: {
  58589. name: string;
  58590. shader: string;
  58591. };
  58592. }
  58593. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58594. /** @hidden */
  58595. export var pbrBlockFinalColorComposition: {
  58596. name: string;
  58597. shader: string;
  58598. };
  58599. }
  58600. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58601. /** @hidden */
  58602. export var pbrBlockImageProcessing: {
  58603. name: string;
  58604. shader: string;
  58605. };
  58606. }
  58607. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58608. /** @hidden */
  58609. export var pbrDebug: {
  58610. name: string;
  58611. shader: string;
  58612. };
  58613. }
  58614. declare module "babylonjs/Shaders/pbr.fragment" {
  58615. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58616. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58617. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58618. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58619. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58620. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58621. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58622. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58623. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58624. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58625. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58626. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58627. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58628. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58629. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58630. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58631. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58632. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58633. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58634. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58635. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58636. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58637. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58638. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58639. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58640. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58641. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58642. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58643. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58644. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58645. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58646. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58647. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58648. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58649. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58650. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58651. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58652. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58653. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58654. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58655. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58656. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58657. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58658. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58659. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58660. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58661. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58662. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58663. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58664. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58665. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58666. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58667. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58668. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58669. /** @hidden */
  58670. export var pbrPixelShader: {
  58671. name: string;
  58672. shader: string;
  58673. };
  58674. }
  58675. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58676. /** @hidden */
  58677. export var pbrVertexDeclaration: {
  58678. name: string;
  58679. shader: string;
  58680. };
  58681. }
  58682. declare module "babylonjs/Shaders/pbr.vertex" {
  58683. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58684. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58685. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58686. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58687. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58688. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58689. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  58690. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  58691. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  58692. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58693. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58694. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58695. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58696. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58697. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58698. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58699. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58700. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  58701. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58702. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  58703. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58704. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  58705. /** @hidden */
  58706. export var pbrVertexShader: {
  58707. name: string;
  58708. shader: string;
  58709. };
  58710. }
  58711. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  58712. import { Nullable } from "babylonjs/types";
  58713. import { Scene } from "babylonjs/scene";
  58714. import { Matrix } from "babylonjs/Maths/math.vector";
  58715. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58717. import { Mesh } from "babylonjs/Meshes/mesh";
  58718. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  58719. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  58720. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  58721. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  58722. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  58723. import { Color3 } from "babylonjs/Maths/math.color";
  58724. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58725. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  58726. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58727. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  58728. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58729. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58730. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58731. import "babylonjs/Shaders/pbr.fragment";
  58732. import "babylonjs/Shaders/pbr.vertex";
  58733. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  58734. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  58735. /**
  58736. * Manages the defines for the PBR Material.
  58737. * @hidden
  58738. */
  58739. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  58740. PBR: boolean;
  58741. NUM_SAMPLES: string;
  58742. REALTIME_FILTERING: boolean;
  58743. MAINUV1: boolean;
  58744. MAINUV2: boolean;
  58745. UV1: boolean;
  58746. UV2: boolean;
  58747. ALBEDO: boolean;
  58748. GAMMAALBEDO: boolean;
  58749. ALBEDODIRECTUV: number;
  58750. VERTEXCOLOR: boolean;
  58751. DETAIL: boolean;
  58752. DETAILDIRECTUV: number;
  58753. DETAIL_NORMALBLENDMETHOD: number;
  58754. AMBIENT: boolean;
  58755. AMBIENTDIRECTUV: number;
  58756. AMBIENTINGRAYSCALE: boolean;
  58757. OPACITY: boolean;
  58758. VERTEXALPHA: boolean;
  58759. OPACITYDIRECTUV: number;
  58760. OPACITYRGB: boolean;
  58761. ALPHATEST: boolean;
  58762. DEPTHPREPASS: boolean;
  58763. ALPHABLEND: boolean;
  58764. ALPHAFROMALBEDO: boolean;
  58765. ALPHATESTVALUE: string;
  58766. SPECULAROVERALPHA: boolean;
  58767. RADIANCEOVERALPHA: boolean;
  58768. ALPHAFRESNEL: boolean;
  58769. LINEARALPHAFRESNEL: boolean;
  58770. PREMULTIPLYALPHA: boolean;
  58771. EMISSIVE: boolean;
  58772. EMISSIVEDIRECTUV: number;
  58773. REFLECTIVITY: boolean;
  58774. REFLECTIVITYDIRECTUV: number;
  58775. SPECULARTERM: boolean;
  58776. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  58777. MICROSURFACEAUTOMATIC: boolean;
  58778. LODBASEDMICROSFURACE: boolean;
  58779. MICROSURFACEMAP: boolean;
  58780. MICROSURFACEMAPDIRECTUV: number;
  58781. METALLICWORKFLOW: boolean;
  58782. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  58783. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  58784. METALLNESSSTOREINMETALMAPBLUE: boolean;
  58785. AOSTOREINMETALMAPRED: boolean;
  58786. METALLIC_REFLECTANCE: boolean;
  58787. METALLIC_REFLECTANCEDIRECTUV: number;
  58788. ENVIRONMENTBRDF: boolean;
  58789. ENVIRONMENTBRDF_RGBD: boolean;
  58790. NORMAL: boolean;
  58791. TANGENT: boolean;
  58792. BUMP: boolean;
  58793. BUMPDIRECTUV: number;
  58794. OBJECTSPACE_NORMALMAP: boolean;
  58795. PARALLAX: boolean;
  58796. PARALLAXOCCLUSION: boolean;
  58797. NORMALXYSCALE: boolean;
  58798. LIGHTMAP: boolean;
  58799. LIGHTMAPDIRECTUV: number;
  58800. USELIGHTMAPASSHADOWMAP: boolean;
  58801. GAMMALIGHTMAP: boolean;
  58802. RGBDLIGHTMAP: boolean;
  58803. REFLECTION: boolean;
  58804. REFLECTIONMAP_3D: boolean;
  58805. REFLECTIONMAP_SPHERICAL: boolean;
  58806. REFLECTIONMAP_PLANAR: boolean;
  58807. REFLECTIONMAP_CUBIC: boolean;
  58808. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  58809. REFLECTIONMAP_PROJECTION: boolean;
  58810. REFLECTIONMAP_SKYBOX: boolean;
  58811. REFLECTIONMAP_EXPLICIT: boolean;
  58812. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  58813. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  58814. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  58815. INVERTCUBICMAP: boolean;
  58816. USESPHERICALFROMREFLECTIONMAP: boolean;
  58817. USEIRRADIANCEMAP: boolean;
  58818. SPHERICAL_HARMONICS: boolean;
  58819. USESPHERICALINVERTEX: boolean;
  58820. REFLECTIONMAP_OPPOSITEZ: boolean;
  58821. LODINREFLECTIONALPHA: boolean;
  58822. GAMMAREFLECTION: boolean;
  58823. RGBDREFLECTION: boolean;
  58824. LINEARSPECULARREFLECTION: boolean;
  58825. RADIANCEOCCLUSION: boolean;
  58826. HORIZONOCCLUSION: boolean;
  58827. INSTANCES: boolean;
  58828. THIN_INSTANCES: boolean;
  58829. PREPASS: boolean;
  58830. SCENE_MRT_COUNT: number;
  58831. NUM_BONE_INFLUENCERS: number;
  58832. BonesPerMesh: number;
  58833. BONETEXTURE: boolean;
  58834. NONUNIFORMSCALING: boolean;
  58835. MORPHTARGETS: boolean;
  58836. MORPHTARGETS_NORMAL: boolean;
  58837. MORPHTARGETS_TANGENT: boolean;
  58838. MORPHTARGETS_UV: boolean;
  58839. NUM_MORPH_INFLUENCERS: number;
  58840. IMAGEPROCESSING: boolean;
  58841. VIGNETTE: boolean;
  58842. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58843. VIGNETTEBLENDMODEOPAQUE: boolean;
  58844. TONEMAPPING: boolean;
  58845. TONEMAPPING_ACES: boolean;
  58846. CONTRAST: boolean;
  58847. COLORCURVES: boolean;
  58848. COLORGRADING: boolean;
  58849. COLORGRADING3D: boolean;
  58850. SAMPLER3DGREENDEPTH: boolean;
  58851. SAMPLER3DBGRMAP: boolean;
  58852. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58853. EXPOSURE: boolean;
  58854. MULTIVIEW: boolean;
  58855. USEPHYSICALLIGHTFALLOFF: boolean;
  58856. USEGLTFLIGHTFALLOFF: boolean;
  58857. TWOSIDEDLIGHTING: boolean;
  58858. SHADOWFLOAT: boolean;
  58859. CLIPPLANE: boolean;
  58860. CLIPPLANE2: boolean;
  58861. CLIPPLANE3: boolean;
  58862. CLIPPLANE4: boolean;
  58863. CLIPPLANE5: boolean;
  58864. CLIPPLANE6: boolean;
  58865. POINTSIZE: boolean;
  58866. FOG: boolean;
  58867. LOGARITHMICDEPTH: boolean;
  58868. FORCENORMALFORWARD: boolean;
  58869. SPECULARAA: boolean;
  58870. CLEARCOAT: boolean;
  58871. CLEARCOAT_DEFAULTIOR: boolean;
  58872. CLEARCOAT_TEXTURE: boolean;
  58873. CLEARCOAT_TEXTUREDIRECTUV: number;
  58874. CLEARCOAT_BUMP: boolean;
  58875. CLEARCOAT_BUMPDIRECTUV: number;
  58876. CLEARCOAT_TINT: boolean;
  58877. CLEARCOAT_TINT_TEXTURE: boolean;
  58878. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  58879. ANISOTROPIC: boolean;
  58880. ANISOTROPIC_TEXTURE: boolean;
  58881. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58882. BRDF_V_HEIGHT_CORRELATED: boolean;
  58883. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58884. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58885. SHEEN: boolean;
  58886. SHEEN_TEXTURE: boolean;
  58887. SHEEN_TEXTUREDIRECTUV: number;
  58888. SHEEN_LINKWITHALBEDO: boolean;
  58889. SHEEN_ROUGHNESS: boolean;
  58890. SHEEN_ALBEDOSCALING: boolean;
  58891. SUBSURFACE: boolean;
  58892. SS_REFRACTION: boolean;
  58893. SS_TRANSLUCENCY: boolean;
  58894. SS_SCATTERING: boolean;
  58895. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58896. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58897. SS_REFRACTIONMAP_3D: boolean;
  58898. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58899. SS_LODINREFRACTIONALPHA: boolean;
  58900. SS_GAMMAREFRACTION: boolean;
  58901. SS_RGBDREFRACTION: boolean;
  58902. SS_LINEARSPECULARREFRACTION: boolean;
  58903. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58904. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58905. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58906. UNLIT: boolean;
  58907. DEBUGMODE: number;
  58908. /**
  58909. * Initializes the PBR Material defines.
  58910. */
  58911. constructor();
  58912. /**
  58913. * Resets the PBR Material defines.
  58914. */
  58915. reset(): void;
  58916. }
  58917. /**
  58918. * The Physically based material base class of BJS.
  58919. *
  58920. * This offers the main features of a standard PBR material.
  58921. * For more information, please refer to the documentation :
  58922. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58923. */
  58924. export abstract class PBRBaseMaterial extends PushMaterial {
  58925. /**
  58926. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58927. */
  58928. static readonly PBRMATERIAL_OPAQUE: number;
  58929. /**
  58930. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58931. */
  58932. static readonly PBRMATERIAL_ALPHATEST: number;
  58933. /**
  58934. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58935. */
  58936. static readonly PBRMATERIAL_ALPHABLEND: number;
  58937. /**
  58938. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58939. * They are also discarded below the alpha cutoff threshold to improve performances.
  58940. */
  58941. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58942. /**
  58943. * Defines the default value of how much AO map is occluding the analytical lights
  58944. * (point spot...).
  58945. */
  58946. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58947. /**
  58948. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  58949. */
  58950. static readonly LIGHTFALLOFF_PHYSICAL: number;
  58951. /**
  58952. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  58953. * to enhance interoperability with other engines.
  58954. */
  58955. static readonly LIGHTFALLOFF_GLTF: number;
  58956. /**
  58957. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  58958. * to enhance interoperability with other materials.
  58959. */
  58960. static readonly LIGHTFALLOFF_STANDARD: number;
  58961. /**
  58962. * Intensity of the direct lights e.g. the four lights available in your scene.
  58963. * This impacts both the direct diffuse and specular highlights.
  58964. */
  58965. protected _directIntensity: number;
  58966. /**
  58967. * Intensity of the emissive part of the material.
  58968. * This helps controlling the emissive effect without modifying the emissive color.
  58969. */
  58970. protected _emissiveIntensity: number;
  58971. /**
  58972. * Intensity of the environment e.g. how much the environment will light the object
  58973. * either through harmonics for rough material or through the refelction for shiny ones.
  58974. */
  58975. protected _environmentIntensity: number;
  58976. /**
  58977. * This is a special control allowing the reduction of the specular highlights coming from the
  58978. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58979. */
  58980. protected _specularIntensity: number;
  58981. /**
  58982. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  58983. */
  58984. private _lightingInfos;
  58985. /**
  58986. * Debug Control allowing disabling the bump map on this material.
  58987. */
  58988. protected _disableBumpMap: boolean;
  58989. /**
  58990. * AKA Diffuse Texture in standard nomenclature.
  58991. */
  58992. protected _albedoTexture: Nullable<BaseTexture>;
  58993. /**
  58994. * AKA Occlusion Texture in other nomenclature.
  58995. */
  58996. protected _ambientTexture: Nullable<BaseTexture>;
  58997. /**
  58998. * AKA Occlusion Texture Intensity in other nomenclature.
  58999. */
  59000. protected _ambientTextureStrength: number;
  59001. /**
  59002. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59003. * 1 means it completely occludes it
  59004. * 0 mean it has no impact
  59005. */
  59006. protected _ambientTextureImpactOnAnalyticalLights: number;
  59007. /**
  59008. * Stores the alpha values in a texture.
  59009. */
  59010. protected _opacityTexture: Nullable<BaseTexture>;
  59011. /**
  59012. * Stores the reflection values in a texture.
  59013. */
  59014. protected _reflectionTexture: Nullable<BaseTexture>;
  59015. /**
  59016. * Stores the emissive values in a texture.
  59017. */
  59018. protected _emissiveTexture: Nullable<BaseTexture>;
  59019. /**
  59020. * AKA Specular texture in other nomenclature.
  59021. */
  59022. protected _reflectivityTexture: Nullable<BaseTexture>;
  59023. /**
  59024. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59025. */
  59026. protected _metallicTexture: Nullable<BaseTexture>;
  59027. /**
  59028. * Specifies the metallic scalar of the metallic/roughness workflow.
  59029. * Can also be used to scale the metalness values of the metallic texture.
  59030. */
  59031. protected _metallic: Nullable<number>;
  59032. /**
  59033. * Specifies the roughness scalar of the metallic/roughness workflow.
  59034. * Can also be used to scale the roughness values of the metallic texture.
  59035. */
  59036. protected _roughness: Nullable<number>;
  59037. /**
  59038. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59039. * By default the indexOfrefraction is used to compute F0;
  59040. *
  59041. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59042. *
  59043. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59044. * F90 = metallicReflectanceColor;
  59045. */
  59046. protected _metallicF0Factor: number;
  59047. /**
  59048. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59049. * By default the F90 is always 1;
  59050. *
  59051. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59052. *
  59053. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59054. * F90 = metallicReflectanceColor;
  59055. */
  59056. protected _metallicReflectanceColor: Color3;
  59057. /**
  59058. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59059. * This is multiply against the scalar values defined in the material.
  59060. */
  59061. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  59062. /**
  59063. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59064. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59065. */
  59066. protected _microSurfaceTexture: Nullable<BaseTexture>;
  59067. /**
  59068. * Stores surface normal data used to displace a mesh in a texture.
  59069. */
  59070. protected _bumpTexture: Nullable<BaseTexture>;
  59071. /**
  59072. * Stores the pre-calculated light information of a mesh in a texture.
  59073. */
  59074. protected _lightmapTexture: Nullable<BaseTexture>;
  59075. /**
  59076. * The color of a material in ambient lighting.
  59077. */
  59078. protected _ambientColor: Color3;
  59079. /**
  59080. * AKA Diffuse Color in other nomenclature.
  59081. */
  59082. protected _albedoColor: Color3;
  59083. /**
  59084. * AKA Specular Color in other nomenclature.
  59085. */
  59086. protected _reflectivityColor: Color3;
  59087. /**
  59088. * The color applied when light is reflected from a material.
  59089. */
  59090. protected _reflectionColor: Color3;
  59091. /**
  59092. * The color applied when light is emitted from a material.
  59093. */
  59094. protected _emissiveColor: Color3;
  59095. /**
  59096. * AKA Glossiness in other nomenclature.
  59097. */
  59098. protected _microSurface: number;
  59099. /**
  59100. * Specifies that the material will use the light map as a show map.
  59101. */
  59102. protected _useLightmapAsShadowmap: boolean;
  59103. /**
  59104. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59105. * makes the reflect vector face the model (under horizon).
  59106. */
  59107. protected _useHorizonOcclusion: boolean;
  59108. /**
  59109. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59110. * too much the area relying on ambient texture to define their ambient occlusion.
  59111. */
  59112. protected _useRadianceOcclusion: boolean;
  59113. /**
  59114. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59115. */
  59116. protected _useAlphaFromAlbedoTexture: boolean;
  59117. /**
  59118. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  59119. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59120. */
  59121. protected _useSpecularOverAlpha: boolean;
  59122. /**
  59123. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59124. */
  59125. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59126. /**
  59127. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59128. */
  59129. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59130. /**
  59131. * Specifies if the metallic texture contains the roughness information in its green channel.
  59132. */
  59133. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59134. /**
  59135. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59136. */
  59137. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59138. /**
  59139. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59140. */
  59141. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59142. /**
  59143. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59144. */
  59145. protected _useAmbientInGrayScale: boolean;
  59146. /**
  59147. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59148. * The material will try to infer what glossiness each pixel should be.
  59149. */
  59150. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59151. /**
  59152. * Defines the falloff type used in this material.
  59153. * It by default is Physical.
  59154. */
  59155. protected _lightFalloff: number;
  59156. /**
  59157. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59158. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59159. */
  59160. protected _useRadianceOverAlpha: boolean;
  59161. /**
  59162. * Allows using an object space normal map (instead of tangent space).
  59163. */
  59164. protected _useObjectSpaceNormalMap: boolean;
  59165. /**
  59166. * Allows using the bump map in parallax mode.
  59167. */
  59168. protected _useParallax: boolean;
  59169. /**
  59170. * Allows using the bump map in parallax occlusion mode.
  59171. */
  59172. protected _useParallaxOcclusion: boolean;
  59173. /**
  59174. * Controls the scale bias of the parallax mode.
  59175. */
  59176. protected _parallaxScaleBias: number;
  59177. /**
  59178. * If sets to true, disables all the lights affecting the material.
  59179. */
  59180. protected _disableLighting: boolean;
  59181. /**
  59182. * Number of Simultaneous lights allowed on the material.
  59183. */
  59184. protected _maxSimultaneousLights: number;
  59185. /**
  59186. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59187. */
  59188. protected _invertNormalMapX: boolean;
  59189. /**
  59190. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59191. */
  59192. protected _invertNormalMapY: boolean;
  59193. /**
  59194. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59195. */
  59196. protected _twoSidedLighting: boolean;
  59197. /**
  59198. * Defines the alpha limits in alpha test mode.
  59199. */
  59200. protected _alphaCutOff: number;
  59201. /**
  59202. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59203. */
  59204. protected _forceAlphaTest: boolean;
  59205. /**
  59206. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59207. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59208. */
  59209. protected _useAlphaFresnel: boolean;
  59210. /**
  59211. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59212. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59213. */
  59214. protected _useLinearAlphaFresnel: boolean;
  59215. /**
  59216. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59217. * from cos thetav and roughness:
  59218. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59219. */
  59220. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59221. /**
  59222. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59223. */
  59224. protected _forceIrradianceInFragment: boolean;
  59225. private _realTimeFiltering;
  59226. /**
  59227. * Enables realtime filtering on the texture.
  59228. */
  59229. get realTimeFiltering(): boolean;
  59230. set realTimeFiltering(b: boolean);
  59231. private _realTimeFilteringQuality;
  59232. /**
  59233. * Quality switch for realtime filtering
  59234. */
  59235. get realTimeFilteringQuality(): number;
  59236. set realTimeFilteringQuality(n: number);
  59237. /**
  59238. * Can this material render to several textures at once
  59239. */
  59240. get canRenderToMRT(): boolean;
  59241. /**
  59242. * Force normal to face away from face.
  59243. */
  59244. protected _forceNormalForward: boolean;
  59245. /**
  59246. * Enables specular anti aliasing in the PBR shader.
  59247. * It will both interacts on the Geometry for analytical and IBL lighting.
  59248. * It also prefilter the roughness map based on the bump values.
  59249. */
  59250. protected _enableSpecularAntiAliasing: boolean;
  59251. /**
  59252. * Default configuration related to image processing available in the PBR Material.
  59253. */
  59254. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59255. /**
  59256. * Keep track of the image processing observer to allow dispose and replace.
  59257. */
  59258. private _imageProcessingObserver;
  59259. /**
  59260. * Attaches a new image processing configuration to the PBR Material.
  59261. * @param configuration
  59262. */
  59263. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59264. /**
  59265. * Stores the available render targets.
  59266. */
  59267. private _renderTargets;
  59268. /**
  59269. * Sets the global ambient color for the material used in lighting calculations.
  59270. */
  59271. private _globalAmbientColor;
  59272. /**
  59273. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59274. */
  59275. private _useLogarithmicDepth;
  59276. /**
  59277. * If set to true, no lighting calculations will be applied.
  59278. */
  59279. private _unlit;
  59280. private _debugMode;
  59281. /**
  59282. * @hidden
  59283. * This is reserved for the inspector.
  59284. * Defines the material debug mode.
  59285. * It helps seeing only some components of the material while troubleshooting.
  59286. */
  59287. debugMode: number;
  59288. /**
  59289. * @hidden
  59290. * This is reserved for the inspector.
  59291. * Specify from where on screen the debug mode should start.
  59292. * The value goes from -1 (full screen) to 1 (not visible)
  59293. * It helps with side by side comparison against the final render
  59294. * This defaults to -1
  59295. */
  59296. private debugLimit;
  59297. /**
  59298. * @hidden
  59299. * This is reserved for the inspector.
  59300. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59301. * You can use the factor to better multiply the final value.
  59302. */
  59303. private debugFactor;
  59304. /**
  59305. * Defines the clear coat layer parameters for the material.
  59306. */
  59307. readonly clearCoat: PBRClearCoatConfiguration;
  59308. /**
  59309. * Defines the anisotropic parameters for the material.
  59310. */
  59311. readonly anisotropy: PBRAnisotropicConfiguration;
  59312. /**
  59313. * Defines the BRDF parameters for the material.
  59314. */
  59315. readonly brdf: PBRBRDFConfiguration;
  59316. /**
  59317. * Defines the Sheen parameters for the material.
  59318. */
  59319. readonly sheen: PBRSheenConfiguration;
  59320. /**
  59321. * Defines the SubSurface parameters for the material.
  59322. */
  59323. readonly subSurface: PBRSubSurfaceConfiguration;
  59324. /**
  59325. * Defines the detail map parameters for the material.
  59326. */
  59327. readonly detailMap: DetailMapConfiguration;
  59328. protected _rebuildInParallel: boolean;
  59329. /**
  59330. * Instantiates a new PBRMaterial instance.
  59331. *
  59332. * @param name The material name
  59333. * @param scene The scene the material will be use in.
  59334. */
  59335. constructor(name: string, scene: Scene);
  59336. /**
  59337. * Gets a boolean indicating that current material needs to register RTT
  59338. */
  59339. get hasRenderTargetTextures(): boolean;
  59340. /**
  59341. * Gets the name of the material class.
  59342. */
  59343. getClassName(): string;
  59344. /**
  59345. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59346. */
  59347. get useLogarithmicDepth(): boolean;
  59348. /**
  59349. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59350. */
  59351. set useLogarithmicDepth(value: boolean);
  59352. /**
  59353. * Returns true if alpha blending should be disabled.
  59354. */
  59355. protected get _disableAlphaBlending(): boolean;
  59356. /**
  59357. * Specifies whether or not this material should be rendered in alpha blend mode.
  59358. */
  59359. needAlphaBlending(): boolean;
  59360. /**
  59361. * Specifies whether or not this material should be rendered in alpha test mode.
  59362. */
  59363. needAlphaTesting(): boolean;
  59364. /**
  59365. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59366. */
  59367. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59368. /**
  59369. * Gets the texture used for the alpha test.
  59370. */
  59371. getAlphaTestTexture(): Nullable<BaseTexture>;
  59372. /**
  59373. * Specifies that the submesh is ready to be used.
  59374. * @param mesh - BJS mesh.
  59375. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59376. * @param useInstances - Specifies that instances should be used.
  59377. * @returns - boolean indicating that the submesh is ready or not.
  59378. */
  59379. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59380. /**
  59381. * Specifies if the material uses metallic roughness workflow.
  59382. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59383. */
  59384. isMetallicWorkflow(): boolean;
  59385. private _prepareEffect;
  59386. private _prepareDefines;
  59387. /**
  59388. * Force shader compilation
  59389. */
  59390. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59391. /**
  59392. * Initializes the uniform buffer layout for the shader.
  59393. */
  59394. buildUniformLayout(): void;
  59395. /**
  59396. * Unbinds the material from the mesh
  59397. */
  59398. unbind(): void;
  59399. /**
  59400. * Binds the submesh data.
  59401. * @param world - The world matrix.
  59402. * @param mesh - The BJS mesh.
  59403. * @param subMesh - A submesh of the BJS mesh.
  59404. */
  59405. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59406. /**
  59407. * Returns the animatable textures.
  59408. * @returns - Array of animatable textures.
  59409. */
  59410. getAnimatables(): IAnimatable[];
  59411. /**
  59412. * Returns the texture used for reflections.
  59413. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59414. */
  59415. private _getReflectionTexture;
  59416. /**
  59417. * Returns an array of the actively used textures.
  59418. * @returns - Array of BaseTextures
  59419. */
  59420. getActiveTextures(): BaseTexture[];
  59421. /**
  59422. * Checks to see if a texture is used in the material.
  59423. * @param texture - Base texture to use.
  59424. * @returns - Boolean specifying if a texture is used in the material.
  59425. */
  59426. hasTexture(texture: BaseTexture): boolean;
  59427. /**
  59428. * Sets the required values to the prepass renderer.
  59429. * @param prePassRenderer defines the prepass renderer to setup
  59430. */
  59431. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59432. /**
  59433. * Disposes the resources of the material.
  59434. * @param forceDisposeEffect - Forces the disposal of effects.
  59435. * @param forceDisposeTextures - Forces the disposal of all textures.
  59436. */
  59437. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59438. }
  59439. }
  59440. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59441. import { Nullable } from "babylonjs/types";
  59442. import { Scene } from "babylonjs/scene";
  59443. import { Color3 } from "babylonjs/Maths/math.color";
  59444. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59445. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59446. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59447. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59448. /**
  59449. * The Physically based material of BJS.
  59450. *
  59451. * This offers the main features of a standard PBR material.
  59452. * For more information, please refer to the documentation :
  59453. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59454. */
  59455. export class PBRMaterial extends PBRBaseMaterial {
  59456. /**
  59457. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59458. */
  59459. static readonly PBRMATERIAL_OPAQUE: number;
  59460. /**
  59461. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59462. */
  59463. static readonly PBRMATERIAL_ALPHATEST: number;
  59464. /**
  59465. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59466. */
  59467. static readonly PBRMATERIAL_ALPHABLEND: number;
  59468. /**
  59469. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59470. * They are also discarded below the alpha cutoff threshold to improve performances.
  59471. */
  59472. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59473. /**
  59474. * Defines the default value of how much AO map is occluding the analytical lights
  59475. * (point spot...).
  59476. */
  59477. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59478. /**
  59479. * Intensity of the direct lights e.g. the four lights available in your scene.
  59480. * This impacts both the direct diffuse and specular highlights.
  59481. */
  59482. directIntensity: number;
  59483. /**
  59484. * Intensity of the emissive part of the material.
  59485. * This helps controlling the emissive effect without modifying the emissive color.
  59486. */
  59487. emissiveIntensity: number;
  59488. /**
  59489. * Intensity of the environment e.g. how much the environment will light the object
  59490. * either through harmonics for rough material or through the refelction for shiny ones.
  59491. */
  59492. environmentIntensity: number;
  59493. /**
  59494. * This is a special control allowing the reduction of the specular highlights coming from the
  59495. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59496. */
  59497. specularIntensity: number;
  59498. /**
  59499. * Debug Control allowing disabling the bump map on this material.
  59500. */
  59501. disableBumpMap: boolean;
  59502. /**
  59503. * AKA Diffuse Texture in standard nomenclature.
  59504. */
  59505. albedoTexture: BaseTexture;
  59506. /**
  59507. * AKA Occlusion Texture in other nomenclature.
  59508. */
  59509. ambientTexture: BaseTexture;
  59510. /**
  59511. * AKA Occlusion Texture Intensity in other nomenclature.
  59512. */
  59513. ambientTextureStrength: number;
  59514. /**
  59515. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59516. * 1 means it completely occludes it
  59517. * 0 mean it has no impact
  59518. */
  59519. ambientTextureImpactOnAnalyticalLights: number;
  59520. /**
  59521. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59522. */
  59523. opacityTexture: BaseTexture;
  59524. /**
  59525. * Stores the reflection values in a texture.
  59526. */
  59527. reflectionTexture: Nullable<BaseTexture>;
  59528. /**
  59529. * Stores the emissive values in a texture.
  59530. */
  59531. emissiveTexture: BaseTexture;
  59532. /**
  59533. * AKA Specular texture in other nomenclature.
  59534. */
  59535. reflectivityTexture: BaseTexture;
  59536. /**
  59537. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59538. */
  59539. metallicTexture: BaseTexture;
  59540. /**
  59541. * Specifies the metallic scalar of the metallic/roughness workflow.
  59542. * Can also be used to scale the metalness values of the metallic texture.
  59543. */
  59544. metallic: Nullable<number>;
  59545. /**
  59546. * Specifies the roughness scalar of the metallic/roughness workflow.
  59547. * Can also be used to scale the roughness values of the metallic texture.
  59548. */
  59549. roughness: Nullable<number>;
  59550. /**
  59551. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59552. * By default the indexOfrefraction is used to compute F0;
  59553. *
  59554. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59555. *
  59556. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59557. * F90 = metallicReflectanceColor;
  59558. */
  59559. metallicF0Factor: number;
  59560. /**
  59561. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59562. * By default the F90 is always 1;
  59563. *
  59564. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59565. *
  59566. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59567. * F90 = metallicReflectanceColor;
  59568. */
  59569. metallicReflectanceColor: Color3;
  59570. /**
  59571. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59572. * This is multiply against the scalar values defined in the material.
  59573. */
  59574. metallicReflectanceTexture: Nullable<BaseTexture>;
  59575. /**
  59576. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59577. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59578. */
  59579. microSurfaceTexture: BaseTexture;
  59580. /**
  59581. * Stores surface normal data used to displace a mesh in a texture.
  59582. */
  59583. bumpTexture: BaseTexture;
  59584. /**
  59585. * Stores the pre-calculated light information of a mesh in a texture.
  59586. */
  59587. lightmapTexture: BaseTexture;
  59588. /**
  59589. * Stores the refracted light information in a texture.
  59590. */
  59591. get refractionTexture(): Nullable<BaseTexture>;
  59592. set refractionTexture(value: Nullable<BaseTexture>);
  59593. /**
  59594. * The color of a material in ambient lighting.
  59595. */
  59596. ambientColor: Color3;
  59597. /**
  59598. * AKA Diffuse Color in other nomenclature.
  59599. */
  59600. albedoColor: Color3;
  59601. /**
  59602. * AKA Specular Color in other nomenclature.
  59603. */
  59604. reflectivityColor: Color3;
  59605. /**
  59606. * The color reflected from the material.
  59607. */
  59608. reflectionColor: Color3;
  59609. /**
  59610. * The color emitted from the material.
  59611. */
  59612. emissiveColor: Color3;
  59613. /**
  59614. * AKA Glossiness in other nomenclature.
  59615. */
  59616. microSurface: number;
  59617. /**
  59618. * Index of refraction of the material base layer.
  59619. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59620. *
  59621. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59622. *
  59623. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59624. */
  59625. get indexOfRefraction(): number;
  59626. set indexOfRefraction(value: number);
  59627. /**
  59628. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59629. */
  59630. get invertRefractionY(): boolean;
  59631. set invertRefractionY(value: boolean);
  59632. /**
  59633. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59634. * Materials half opaque for instance using refraction could benefit from this control.
  59635. */
  59636. get linkRefractionWithTransparency(): boolean;
  59637. set linkRefractionWithTransparency(value: boolean);
  59638. /**
  59639. * If true, the light map contains occlusion information instead of lighting info.
  59640. */
  59641. useLightmapAsShadowmap: boolean;
  59642. /**
  59643. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59644. */
  59645. useAlphaFromAlbedoTexture: boolean;
  59646. /**
  59647. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59648. */
  59649. forceAlphaTest: boolean;
  59650. /**
  59651. * Defines the alpha limits in alpha test mode.
  59652. */
  59653. alphaCutOff: number;
  59654. /**
  59655. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59656. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59657. */
  59658. useSpecularOverAlpha: boolean;
  59659. /**
  59660. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59661. */
  59662. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59663. /**
  59664. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59665. */
  59666. useRoughnessFromMetallicTextureAlpha: boolean;
  59667. /**
  59668. * Specifies if the metallic texture contains the roughness information in its green channel.
  59669. */
  59670. useRoughnessFromMetallicTextureGreen: boolean;
  59671. /**
  59672. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59673. */
  59674. useMetallnessFromMetallicTextureBlue: boolean;
  59675. /**
  59676. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59677. */
  59678. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59679. /**
  59680. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59681. */
  59682. useAmbientInGrayScale: boolean;
  59683. /**
  59684. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59685. * The material will try to infer what glossiness each pixel should be.
  59686. */
  59687. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59688. /**
  59689. * BJS is using an harcoded light falloff based on a manually sets up range.
  59690. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59691. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59692. */
  59693. get usePhysicalLightFalloff(): boolean;
  59694. /**
  59695. * BJS is using an harcoded light falloff based on a manually sets up range.
  59696. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59697. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59698. */
  59699. set usePhysicalLightFalloff(value: boolean);
  59700. /**
  59701. * In order to support the falloff compatibility with gltf, a special mode has been added
  59702. * to reproduce the gltf light falloff.
  59703. */
  59704. get useGLTFLightFalloff(): boolean;
  59705. /**
  59706. * In order to support the falloff compatibility with gltf, a special mode has been added
  59707. * to reproduce the gltf light falloff.
  59708. */
  59709. set useGLTFLightFalloff(value: boolean);
  59710. /**
  59711. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59712. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59713. */
  59714. useRadianceOverAlpha: boolean;
  59715. /**
  59716. * Allows using an object space normal map (instead of tangent space).
  59717. */
  59718. useObjectSpaceNormalMap: boolean;
  59719. /**
  59720. * Allows using the bump map in parallax mode.
  59721. */
  59722. useParallax: boolean;
  59723. /**
  59724. * Allows using the bump map in parallax occlusion mode.
  59725. */
  59726. useParallaxOcclusion: boolean;
  59727. /**
  59728. * Controls the scale bias of the parallax mode.
  59729. */
  59730. parallaxScaleBias: number;
  59731. /**
  59732. * If sets to true, disables all the lights affecting the material.
  59733. */
  59734. disableLighting: boolean;
  59735. /**
  59736. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59737. */
  59738. forceIrradianceInFragment: boolean;
  59739. /**
  59740. * Number of Simultaneous lights allowed on the material.
  59741. */
  59742. maxSimultaneousLights: number;
  59743. /**
  59744. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59745. */
  59746. invertNormalMapX: boolean;
  59747. /**
  59748. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59749. */
  59750. invertNormalMapY: boolean;
  59751. /**
  59752. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59753. */
  59754. twoSidedLighting: boolean;
  59755. /**
  59756. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59757. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59758. */
  59759. useAlphaFresnel: boolean;
  59760. /**
  59761. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59762. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59763. */
  59764. useLinearAlphaFresnel: boolean;
  59765. /**
  59766. * Let user defines the brdf lookup texture used for IBL.
  59767. * A default 8bit version is embedded but you could point at :
  59768. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  59769. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  59770. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  59771. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  59772. */
  59773. environmentBRDFTexture: Nullable<BaseTexture>;
  59774. /**
  59775. * Force normal to face away from face.
  59776. */
  59777. forceNormalForward: boolean;
  59778. /**
  59779. * Enables specular anti aliasing in the PBR shader.
  59780. * It will both interacts on the Geometry for analytical and IBL lighting.
  59781. * It also prefilter the roughness map based on the bump values.
  59782. */
  59783. enableSpecularAntiAliasing: boolean;
  59784. /**
  59785. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59786. * makes the reflect vector face the model (under horizon).
  59787. */
  59788. useHorizonOcclusion: boolean;
  59789. /**
  59790. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59791. * too much the area relying on ambient texture to define their ambient occlusion.
  59792. */
  59793. useRadianceOcclusion: boolean;
  59794. /**
  59795. * If set to true, no lighting calculations will be applied.
  59796. */
  59797. unlit: boolean;
  59798. /**
  59799. * Gets the image processing configuration used either in this material.
  59800. */
  59801. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59802. /**
  59803. * Sets the Default image processing configuration used either in the this material.
  59804. *
  59805. * If sets to null, the scene one is in use.
  59806. */
  59807. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59808. /**
  59809. * Gets wether the color curves effect is enabled.
  59810. */
  59811. get cameraColorCurvesEnabled(): boolean;
  59812. /**
  59813. * Sets wether the color curves effect is enabled.
  59814. */
  59815. set cameraColorCurvesEnabled(value: boolean);
  59816. /**
  59817. * Gets wether the color grading effect is enabled.
  59818. */
  59819. get cameraColorGradingEnabled(): boolean;
  59820. /**
  59821. * Gets wether the color grading effect is enabled.
  59822. */
  59823. set cameraColorGradingEnabled(value: boolean);
  59824. /**
  59825. * Gets wether tonemapping is enabled or not.
  59826. */
  59827. get cameraToneMappingEnabled(): boolean;
  59828. /**
  59829. * Sets wether tonemapping is enabled or not
  59830. */
  59831. set cameraToneMappingEnabled(value: boolean);
  59832. /**
  59833. * The camera exposure used on this material.
  59834. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59835. * This corresponds to a photographic exposure.
  59836. */
  59837. get cameraExposure(): number;
  59838. /**
  59839. * The camera exposure used on this material.
  59840. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59841. * This corresponds to a photographic exposure.
  59842. */
  59843. set cameraExposure(value: number);
  59844. /**
  59845. * Gets The camera contrast used on this material.
  59846. */
  59847. get cameraContrast(): number;
  59848. /**
  59849. * Sets The camera contrast used on this material.
  59850. */
  59851. set cameraContrast(value: number);
  59852. /**
  59853. * Gets the Color Grading 2D Lookup Texture.
  59854. */
  59855. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  59856. /**
  59857. * Sets the Color Grading 2D Lookup Texture.
  59858. */
  59859. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  59860. /**
  59861. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59862. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59863. * 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;
  59864. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59865. */
  59866. get cameraColorCurves(): Nullable<ColorCurves>;
  59867. /**
  59868. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59869. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59870. * 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;
  59871. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59872. */
  59873. set cameraColorCurves(value: Nullable<ColorCurves>);
  59874. /**
  59875. * Instantiates a new PBRMaterial instance.
  59876. *
  59877. * @param name The material name
  59878. * @param scene The scene the material will be use in.
  59879. */
  59880. constructor(name: string, scene: Scene);
  59881. /**
  59882. * Returns the name of this material class.
  59883. */
  59884. getClassName(): string;
  59885. /**
  59886. * Makes a duplicate of the current material.
  59887. * @param name - name to use for the new material.
  59888. */
  59889. clone(name: string): PBRMaterial;
  59890. /**
  59891. * Serializes this PBR Material.
  59892. * @returns - An object with the serialized material.
  59893. */
  59894. serialize(): any;
  59895. /**
  59896. * Parses a PBR Material from a serialized object.
  59897. * @param source - Serialized object.
  59898. * @param scene - BJS scene instance.
  59899. * @param rootUrl - url for the scene object
  59900. * @returns - PBRMaterial
  59901. */
  59902. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  59903. }
  59904. }
  59905. declare module "babylonjs/Misc/dds" {
  59906. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59907. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59908. import { Nullable } from "babylonjs/types";
  59909. import { Scene } from "babylonjs/scene";
  59910. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  59911. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59912. /**
  59913. * Direct draw surface info
  59914. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59915. */
  59916. export interface DDSInfo {
  59917. /**
  59918. * Width of the texture
  59919. */
  59920. width: number;
  59921. /**
  59922. * Width of the texture
  59923. */
  59924. height: number;
  59925. /**
  59926. * Number of Mipmaps for the texture
  59927. * @see https://en.wikipedia.org/wiki/Mipmap
  59928. */
  59929. mipmapCount: number;
  59930. /**
  59931. * If the textures format is a known fourCC format
  59932. * @see https://www.fourcc.org/
  59933. */
  59934. isFourCC: boolean;
  59935. /**
  59936. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59937. */
  59938. isRGB: boolean;
  59939. /**
  59940. * If the texture is a lumincance format
  59941. */
  59942. isLuminance: boolean;
  59943. /**
  59944. * If this is a cube texture
  59945. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59946. */
  59947. isCube: boolean;
  59948. /**
  59949. * If the texture is a compressed format eg. FOURCC_DXT1
  59950. */
  59951. isCompressed: boolean;
  59952. /**
  59953. * The dxgiFormat of the texture
  59954. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59955. */
  59956. dxgiFormat: number;
  59957. /**
  59958. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59959. */
  59960. textureType: number;
  59961. /**
  59962. * Sphericle polynomial created for the dds texture
  59963. */
  59964. sphericalPolynomial?: SphericalPolynomial;
  59965. }
  59966. /**
  59967. * Class used to provide DDS decompression tools
  59968. */
  59969. export class DDSTools {
  59970. /**
  59971. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59972. */
  59973. static StoreLODInAlphaChannel: boolean;
  59974. /**
  59975. * Gets DDS information from an array buffer
  59976. * @param data defines the array buffer view to read data from
  59977. * @returns the DDS information
  59978. */
  59979. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59980. private static _FloatView;
  59981. private static _Int32View;
  59982. private static _ToHalfFloat;
  59983. private static _FromHalfFloat;
  59984. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59985. private static _GetHalfFloatRGBAArrayBuffer;
  59986. private static _GetFloatRGBAArrayBuffer;
  59987. private static _GetFloatAsUIntRGBAArrayBuffer;
  59988. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59989. private static _GetRGBAArrayBuffer;
  59990. private static _ExtractLongWordOrder;
  59991. private static _GetRGBArrayBuffer;
  59992. private static _GetLuminanceArrayBuffer;
  59993. /**
  59994. * Uploads DDS Levels to a Babylon Texture
  59995. * @hidden
  59996. */
  59997. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59998. }
  59999. module "babylonjs/Engines/thinEngine" {
  60000. interface ThinEngine {
  60001. /**
  60002. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60003. * @param rootUrl defines the url where the file to load is located
  60004. * @param scene defines the current scene
  60005. * @param lodScale defines scale to apply to the mip map selection
  60006. * @param lodOffset defines offset to apply to the mip map selection
  60007. * @param onLoad defines an optional callback raised when the texture is loaded
  60008. * @param onError defines an optional callback raised if there is an issue to load the texture
  60009. * @param format defines the format of the data
  60010. * @param forcedExtension defines the extension to use to pick the right loader
  60011. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60012. * @returns the cube texture as an InternalTexture
  60013. */
  60014. 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;
  60015. }
  60016. }
  60017. }
  60018. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60019. import { Nullable } from "babylonjs/types";
  60020. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60021. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60022. /**
  60023. * Implementation of the DDS Texture Loader.
  60024. * @hidden
  60025. */
  60026. export class _DDSTextureLoader implements IInternalTextureLoader {
  60027. /**
  60028. * Defines wether the loader supports cascade loading the different faces.
  60029. */
  60030. readonly supportCascades: boolean;
  60031. /**
  60032. * This returns if the loader support the current file information.
  60033. * @param extension defines the file extension of the file being loaded
  60034. * @returns true if the loader can load the specified file
  60035. */
  60036. canLoad(extension: string): boolean;
  60037. /**
  60038. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60039. * @param data contains the texture data
  60040. * @param texture defines the BabylonJS internal texture
  60041. * @param createPolynomials will be true if polynomials have been requested
  60042. * @param onLoad defines the callback to trigger once the texture is ready
  60043. * @param onError defines the callback to trigger in case of error
  60044. */
  60045. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60046. /**
  60047. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60048. * @param data contains the texture data
  60049. * @param texture defines the BabylonJS internal texture
  60050. * @param callback defines the method to call once ready to upload
  60051. */
  60052. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60053. }
  60054. }
  60055. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60056. import { Nullable } from "babylonjs/types";
  60057. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60058. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60059. /**
  60060. * Implementation of the ENV Texture Loader.
  60061. * @hidden
  60062. */
  60063. export class _ENVTextureLoader implements IInternalTextureLoader {
  60064. /**
  60065. * Defines wether the loader supports cascade loading the different faces.
  60066. */
  60067. readonly supportCascades: boolean;
  60068. /**
  60069. * This returns if the loader support the current file information.
  60070. * @param extension defines the file extension of the file being loaded
  60071. * @returns true if the loader can load the specified file
  60072. */
  60073. canLoad(extension: string): boolean;
  60074. /**
  60075. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60076. * @param data contains the texture data
  60077. * @param texture defines the BabylonJS internal texture
  60078. * @param createPolynomials will be true if polynomials have been requested
  60079. * @param onLoad defines the callback to trigger once the texture is ready
  60080. * @param onError defines the callback to trigger in case of error
  60081. */
  60082. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60083. /**
  60084. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60085. * @param data contains the texture data
  60086. * @param texture defines the BabylonJS internal texture
  60087. * @param callback defines the method to call once ready to upload
  60088. */
  60089. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60090. }
  60091. }
  60092. declare module "babylonjs/Misc/khronosTextureContainer" {
  60093. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60094. /**
  60095. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60096. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60097. */
  60098. export class KhronosTextureContainer {
  60099. /** contents of the KTX container file */
  60100. data: ArrayBufferView;
  60101. private static HEADER_LEN;
  60102. private static COMPRESSED_2D;
  60103. private static COMPRESSED_3D;
  60104. private static TEX_2D;
  60105. private static TEX_3D;
  60106. /**
  60107. * Gets the openGL type
  60108. */
  60109. glType: number;
  60110. /**
  60111. * Gets the openGL type size
  60112. */
  60113. glTypeSize: number;
  60114. /**
  60115. * Gets the openGL format
  60116. */
  60117. glFormat: number;
  60118. /**
  60119. * Gets the openGL internal format
  60120. */
  60121. glInternalFormat: number;
  60122. /**
  60123. * Gets the base internal format
  60124. */
  60125. glBaseInternalFormat: number;
  60126. /**
  60127. * Gets image width in pixel
  60128. */
  60129. pixelWidth: number;
  60130. /**
  60131. * Gets image height in pixel
  60132. */
  60133. pixelHeight: number;
  60134. /**
  60135. * Gets image depth in pixels
  60136. */
  60137. pixelDepth: number;
  60138. /**
  60139. * Gets the number of array elements
  60140. */
  60141. numberOfArrayElements: number;
  60142. /**
  60143. * Gets the number of faces
  60144. */
  60145. numberOfFaces: number;
  60146. /**
  60147. * Gets the number of mipmap levels
  60148. */
  60149. numberOfMipmapLevels: number;
  60150. /**
  60151. * Gets the bytes of key value data
  60152. */
  60153. bytesOfKeyValueData: number;
  60154. /**
  60155. * Gets the load type
  60156. */
  60157. loadType: number;
  60158. /**
  60159. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60160. */
  60161. isInvalid: boolean;
  60162. /**
  60163. * Creates a new KhronosTextureContainer
  60164. * @param data contents of the KTX container file
  60165. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60166. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60167. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60168. */
  60169. constructor(
  60170. /** contents of the KTX container file */
  60171. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60172. /**
  60173. * Uploads KTX content to a Babylon Texture.
  60174. * It is assumed that the texture has already been created & is currently bound
  60175. * @hidden
  60176. */
  60177. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60178. private _upload2DCompressedLevels;
  60179. /**
  60180. * Checks if the given data starts with a KTX file identifier.
  60181. * @param data the data to check
  60182. * @returns true if the data is a KTX file or false otherwise
  60183. */
  60184. static IsValid(data: ArrayBufferView): boolean;
  60185. }
  60186. }
  60187. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60188. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60189. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60190. /**
  60191. * Class for loading KTX2 files
  60192. * !!! Experimental Extension Subject to Changes !!!
  60193. * @hidden
  60194. */
  60195. export class KhronosTextureContainer2 {
  60196. private static _ModulePromise;
  60197. private static _TranscodeFormat;
  60198. constructor(engine: ThinEngine);
  60199. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60200. private _determineTranscodeFormat;
  60201. /**
  60202. * Checks if the given data starts with a KTX2 file identifier.
  60203. * @param data the data to check
  60204. * @returns true if the data is a KTX2 file or false otherwise
  60205. */
  60206. static IsValid(data: ArrayBufferView): boolean;
  60207. }
  60208. }
  60209. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60210. import { Nullable } from "babylonjs/types";
  60211. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60212. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60213. /**
  60214. * Implementation of the KTX Texture Loader.
  60215. * @hidden
  60216. */
  60217. export class _KTXTextureLoader implements IInternalTextureLoader {
  60218. /**
  60219. * Defines wether the loader supports cascade loading the different faces.
  60220. */
  60221. readonly supportCascades: boolean;
  60222. /**
  60223. * This returns if the loader support the current file information.
  60224. * @param extension defines the file extension of the file being loaded
  60225. * @param mimeType defines the optional mime type of the file being loaded
  60226. * @returns true if the loader can load the specified file
  60227. */
  60228. canLoad(extension: string, mimeType?: string): boolean;
  60229. /**
  60230. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60231. * @param data contains the texture data
  60232. * @param texture defines the BabylonJS internal texture
  60233. * @param createPolynomials will be true if polynomials have been requested
  60234. * @param onLoad defines the callback to trigger once the texture is ready
  60235. * @param onError defines the callback to trigger in case of error
  60236. */
  60237. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60238. /**
  60239. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60240. * @param data contains the texture data
  60241. * @param texture defines the BabylonJS internal texture
  60242. * @param callback defines the method to call once ready to upload
  60243. */
  60244. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60245. }
  60246. }
  60247. declare module "babylonjs/Helpers/sceneHelpers" {
  60248. import { Nullable } from "babylonjs/types";
  60249. import { Mesh } from "babylonjs/Meshes/mesh";
  60250. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60251. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60252. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60253. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60254. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60255. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60256. import "babylonjs/Meshes/Builders/boxBuilder";
  60257. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60258. /** @hidden */
  60259. export var _forceSceneHelpersToBundle: boolean;
  60260. module "babylonjs/scene" {
  60261. interface Scene {
  60262. /**
  60263. * Creates a default light for the scene.
  60264. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60265. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60266. */
  60267. createDefaultLight(replace?: boolean): void;
  60268. /**
  60269. * Creates a default camera for the scene.
  60270. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60271. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60272. * @param replace has default false, when true replaces the active camera in the scene
  60273. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60274. */
  60275. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60276. /**
  60277. * Creates a default camera and a default light.
  60278. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60279. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60280. * @param replace has the default false, when true replaces the active camera/light in the scene
  60281. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60282. */
  60283. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60284. /**
  60285. * Creates a new sky box
  60286. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60287. * @param environmentTexture defines the texture to use as environment texture
  60288. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60289. * @param scale defines the overall scale of the skybox
  60290. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60291. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60292. * @returns a new mesh holding the sky box
  60293. */
  60294. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60295. /**
  60296. * Creates a new environment
  60297. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60298. * @param options defines the options you can use to configure the environment
  60299. * @returns the new EnvironmentHelper
  60300. */
  60301. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60302. /**
  60303. * Creates a new VREXperienceHelper
  60304. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60305. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60306. * @returns a new VREXperienceHelper
  60307. */
  60308. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60309. /**
  60310. * Creates a new WebXRDefaultExperience
  60311. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60312. * @param options experience options
  60313. * @returns a promise for a new WebXRDefaultExperience
  60314. */
  60315. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60316. }
  60317. }
  60318. }
  60319. declare module "babylonjs/Helpers/videoDome" {
  60320. import { Scene } from "babylonjs/scene";
  60321. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60322. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60323. /**
  60324. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60325. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60326. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60327. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60328. */
  60329. export class VideoDome extends TextureDome<VideoTexture> {
  60330. /**
  60331. * Define the video source as a Monoscopic panoramic 360 video.
  60332. */
  60333. static readonly MODE_MONOSCOPIC: number;
  60334. /**
  60335. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60336. */
  60337. static readonly MODE_TOPBOTTOM: number;
  60338. /**
  60339. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60340. */
  60341. static readonly MODE_SIDEBYSIDE: number;
  60342. /**
  60343. * Get the video texture associated with this video dome
  60344. */
  60345. get videoTexture(): VideoTexture;
  60346. /**
  60347. * Get the video mode of this dome
  60348. */
  60349. get videoMode(): number;
  60350. /**
  60351. * Set the video mode of this dome.
  60352. * @see textureMode
  60353. */
  60354. set videoMode(value: number);
  60355. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  60356. }
  60357. }
  60358. declare module "babylonjs/Helpers/index" {
  60359. export * from "babylonjs/Helpers/environmentHelper";
  60360. export * from "babylonjs/Helpers/photoDome";
  60361. export * from "babylonjs/Helpers/sceneHelpers";
  60362. export * from "babylonjs/Helpers/videoDome";
  60363. }
  60364. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60365. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60366. import { IDisposable } from "babylonjs/scene";
  60367. import { Engine } from "babylonjs/Engines/engine";
  60368. /**
  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. */
  60372. export class EngineInstrumentation implements IDisposable {
  60373. /**
  60374. * Define the instrumented engine.
  60375. */
  60376. engine: Engine;
  60377. private _captureGPUFrameTime;
  60378. private _gpuFrameTimeToken;
  60379. private _gpuFrameTime;
  60380. private _captureShaderCompilationTime;
  60381. private _shaderCompilationTime;
  60382. private _onBeginFrameObserver;
  60383. private _onEndFrameObserver;
  60384. private _onBeforeShaderCompilationObserver;
  60385. private _onAfterShaderCompilationObserver;
  60386. /**
  60387. * Gets the perf counter used for GPU frame time
  60388. */
  60389. get gpuFrameTimeCounter(): PerfCounter;
  60390. /**
  60391. * Gets the GPU frame time capture status
  60392. */
  60393. get captureGPUFrameTime(): boolean;
  60394. /**
  60395. * Enable or disable the GPU frame time capture
  60396. */
  60397. set captureGPUFrameTime(value: boolean);
  60398. /**
  60399. * Gets the perf counter used for shader compilation time
  60400. */
  60401. get shaderCompilationTimeCounter(): PerfCounter;
  60402. /**
  60403. * Gets the shader compilation time capture status
  60404. */
  60405. get captureShaderCompilationTime(): boolean;
  60406. /**
  60407. * Enable or disable the shader compilation time capture
  60408. */
  60409. set captureShaderCompilationTime(value: boolean);
  60410. /**
  60411. * Instantiates a new engine instrumentation.
  60412. * This class can be used to get instrumentation data from a Babylon engine
  60413. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60414. * @param engine Defines the engine to instrument
  60415. */
  60416. constructor(
  60417. /**
  60418. * Define the instrumented engine.
  60419. */
  60420. engine: Engine);
  60421. /**
  60422. * Dispose and release associated resources.
  60423. */
  60424. dispose(): void;
  60425. }
  60426. }
  60427. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60428. import { Scene, IDisposable } from "babylonjs/scene";
  60429. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60430. /**
  60431. * This class can be used to get instrumentation data from a Babylon engine
  60432. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60433. */
  60434. export class SceneInstrumentation implements IDisposable {
  60435. /**
  60436. * Defines the scene to instrument
  60437. */
  60438. scene: Scene;
  60439. private _captureActiveMeshesEvaluationTime;
  60440. private _activeMeshesEvaluationTime;
  60441. private _captureRenderTargetsRenderTime;
  60442. private _renderTargetsRenderTime;
  60443. private _captureFrameTime;
  60444. private _frameTime;
  60445. private _captureRenderTime;
  60446. private _renderTime;
  60447. private _captureInterFrameTime;
  60448. private _interFrameTime;
  60449. private _captureParticlesRenderTime;
  60450. private _particlesRenderTime;
  60451. private _captureSpritesRenderTime;
  60452. private _spritesRenderTime;
  60453. private _capturePhysicsTime;
  60454. private _physicsTime;
  60455. private _captureAnimationsTime;
  60456. private _animationsTime;
  60457. private _captureCameraRenderTime;
  60458. private _cameraRenderTime;
  60459. private _onBeforeActiveMeshesEvaluationObserver;
  60460. private _onAfterActiveMeshesEvaluationObserver;
  60461. private _onBeforeRenderTargetsRenderObserver;
  60462. private _onAfterRenderTargetsRenderObserver;
  60463. private _onAfterRenderObserver;
  60464. private _onBeforeDrawPhaseObserver;
  60465. private _onAfterDrawPhaseObserver;
  60466. private _onBeforeAnimationsObserver;
  60467. private _onBeforeParticlesRenderingObserver;
  60468. private _onAfterParticlesRenderingObserver;
  60469. private _onBeforeSpritesRenderingObserver;
  60470. private _onAfterSpritesRenderingObserver;
  60471. private _onBeforePhysicsObserver;
  60472. private _onAfterPhysicsObserver;
  60473. private _onAfterAnimationsObserver;
  60474. private _onBeforeCameraRenderObserver;
  60475. private _onAfterCameraRenderObserver;
  60476. /**
  60477. * Gets the perf counter used for active meshes evaluation time
  60478. */
  60479. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60480. /**
  60481. * Gets the active meshes evaluation time capture status
  60482. */
  60483. get captureActiveMeshesEvaluationTime(): boolean;
  60484. /**
  60485. * Enable or disable the active meshes evaluation time capture
  60486. */
  60487. set captureActiveMeshesEvaluationTime(value: boolean);
  60488. /**
  60489. * Gets the perf counter used for render targets render time
  60490. */
  60491. get renderTargetsRenderTimeCounter(): PerfCounter;
  60492. /**
  60493. * Gets the render targets render time capture status
  60494. */
  60495. get captureRenderTargetsRenderTime(): boolean;
  60496. /**
  60497. * Enable or disable the render targets render time capture
  60498. */
  60499. set captureRenderTargetsRenderTime(value: boolean);
  60500. /**
  60501. * Gets the perf counter used for particles render time
  60502. */
  60503. get particlesRenderTimeCounter(): PerfCounter;
  60504. /**
  60505. * Gets the particles render time capture status
  60506. */
  60507. get captureParticlesRenderTime(): boolean;
  60508. /**
  60509. * Enable or disable the particles render time capture
  60510. */
  60511. set captureParticlesRenderTime(value: boolean);
  60512. /**
  60513. * Gets the perf counter used for sprites render time
  60514. */
  60515. get spritesRenderTimeCounter(): PerfCounter;
  60516. /**
  60517. * Gets the sprites render time capture status
  60518. */
  60519. get captureSpritesRenderTime(): boolean;
  60520. /**
  60521. * Enable or disable the sprites render time capture
  60522. */
  60523. set captureSpritesRenderTime(value: boolean);
  60524. /**
  60525. * Gets the perf counter used for physics time
  60526. */
  60527. get physicsTimeCounter(): PerfCounter;
  60528. /**
  60529. * Gets the physics time capture status
  60530. */
  60531. get capturePhysicsTime(): boolean;
  60532. /**
  60533. * Enable or disable the physics time capture
  60534. */
  60535. set capturePhysicsTime(value: boolean);
  60536. /**
  60537. * Gets the perf counter used for animations time
  60538. */
  60539. get animationsTimeCounter(): PerfCounter;
  60540. /**
  60541. * Gets the animations time capture status
  60542. */
  60543. get captureAnimationsTime(): boolean;
  60544. /**
  60545. * Enable or disable the animations time capture
  60546. */
  60547. set captureAnimationsTime(value: boolean);
  60548. /**
  60549. * Gets the perf counter used for frame time capture
  60550. */
  60551. get frameTimeCounter(): PerfCounter;
  60552. /**
  60553. * Gets the frame time capture status
  60554. */
  60555. get captureFrameTime(): boolean;
  60556. /**
  60557. * Enable or disable the frame time capture
  60558. */
  60559. set captureFrameTime(value: boolean);
  60560. /**
  60561. * Gets the perf counter used for inter-frames time capture
  60562. */
  60563. get interFrameTimeCounter(): PerfCounter;
  60564. /**
  60565. * Gets the inter-frames time capture status
  60566. */
  60567. get captureInterFrameTime(): boolean;
  60568. /**
  60569. * Enable or disable the inter-frames time capture
  60570. */
  60571. set captureInterFrameTime(value: boolean);
  60572. /**
  60573. * Gets the perf counter used for render time capture
  60574. */
  60575. get renderTimeCounter(): PerfCounter;
  60576. /**
  60577. * Gets the render time capture status
  60578. */
  60579. get captureRenderTime(): boolean;
  60580. /**
  60581. * Enable or disable the render time capture
  60582. */
  60583. set captureRenderTime(value: boolean);
  60584. /**
  60585. * Gets the perf counter used for camera render time capture
  60586. */
  60587. get cameraRenderTimeCounter(): PerfCounter;
  60588. /**
  60589. * Gets the camera render time capture status
  60590. */
  60591. get captureCameraRenderTime(): boolean;
  60592. /**
  60593. * Enable or disable the camera render time capture
  60594. */
  60595. set captureCameraRenderTime(value: boolean);
  60596. /**
  60597. * Gets the perf counter used for draw calls
  60598. */
  60599. get drawCallsCounter(): PerfCounter;
  60600. /**
  60601. * Instantiates a new scene instrumentation.
  60602. * This class can be used to get instrumentation data from a Babylon engine
  60603. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60604. * @param scene Defines the scene to instrument
  60605. */
  60606. constructor(
  60607. /**
  60608. * Defines the scene to instrument
  60609. */
  60610. scene: Scene);
  60611. /**
  60612. * Dispose and release associated resources.
  60613. */
  60614. dispose(): void;
  60615. }
  60616. }
  60617. declare module "babylonjs/Instrumentation/index" {
  60618. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60619. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60620. export * from "babylonjs/Instrumentation/timeToken";
  60621. }
  60622. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60623. /** @hidden */
  60624. export var glowMapGenerationPixelShader: {
  60625. name: string;
  60626. shader: string;
  60627. };
  60628. }
  60629. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60630. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60631. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60632. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60633. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60634. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60635. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60636. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60637. /** @hidden */
  60638. export var glowMapGenerationVertexShader: {
  60639. name: string;
  60640. shader: string;
  60641. };
  60642. }
  60643. declare module "babylonjs/Layers/effectLayer" {
  60644. import { Observable } from "babylonjs/Misc/observable";
  60645. import { Nullable } from "babylonjs/types";
  60646. import { Camera } from "babylonjs/Cameras/camera";
  60647. import { Scene } from "babylonjs/scene";
  60648. import { ISize } from "babylonjs/Maths/math.size";
  60649. import { Color4 } from "babylonjs/Maths/math.color";
  60650. import { Engine } from "babylonjs/Engines/engine";
  60651. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60653. import { Mesh } from "babylonjs/Meshes/mesh";
  60654. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60655. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60656. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60657. import { Effect } from "babylonjs/Materials/effect";
  60658. import { Material } from "babylonjs/Materials/material";
  60659. import "babylonjs/Shaders/glowMapGeneration.fragment";
  60660. import "babylonjs/Shaders/glowMapGeneration.vertex";
  60661. /**
  60662. * Effect layer options. This helps customizing the behaviour
  60663. * of the effect layer.
  60664. */
  60665. export interface IEffectLayerOptions {
  60666. /**
  60667. * Multiplication factor apply to the canvas size to compute the render target size
  60668. * used to generated the objects (the smaller the faster).
  60669. */
  60670. mainTextureRatio: number;
  60671. /**
  60672. * Enforces a fixed size texture to ensure effect stability across devices.
  60673. */
  60674. mainTextureFixedSize?: number;
  60675. /**
  60676. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  60677. */
  60678. alphaBlendingMode: number;
  60679. /**
  60680. * The camera attached to the layer.
  60681. */
  60682. camera: Nullable<Camera>;
  60683. /**
  60684. * The rendering group to draw the layer in.
  60685. */
  60686. renderingGroupId: number;
  60687. }
  60688. /**
  60689. * The effect layer Helps adding post process effect blended with the main pass.
  60690. *
  60691. * This can be for instance use to generate glow or higlight effects on the scene.
  60692. *
  60693. * The effect layer class can not be used directly and is intented to inherited from to be
  60694. * customized per effects.
  60695. */
  60696. export abstract class EffectLayer {
  60697. private _vertexBuffers;
  60698. private _indexBuffer;
  60699. private _cachedDefines;
  60700. private _effectLayerMapGenerationEffect;
  60701. private _effectLayerOptions;
  60702. private _mergeEffect;
  60703. protected _scene: Scene;
  60704. protected _engine: Engine;
  60705. protected _maxSize: number;
  60706. protected _mainTextureDesiredSize: ISize;
  60707. protected _mainTexture: RenderTargetTexture;
  60708. protected _shouldRender: boolean;
  60709. protected _postProcesses: PostProcess[];
  60710. protected _textures: BaseTexture[];
  60711. protected _emissiveTextureAndColor: {
  60712. texture: Nullable<BaseTexture>;
  60713. color: Color4;
  60714. };
  60715. /**
  60716. * The name of the layer
  60717. */
  60718. name: string;
  60719. /**
  60720. * The clear color of the texture used to generate the glow map.
  60721. */
  60722. neutralColor: Color4;
  60723. /**
  60724. * Specifies whether the highlight layer is enabled or not.
  60725. */
  60726. isEnabled: boolean;
  60727. /**
  60728. * Gets the camera attached to the layer.
  60729. */
  60730. get camera(): Nullable<Camera>;
  60731. /**
  60732. * Gets the rendering group id the layer should render in.
  60733. */
  60734. get renderingGroupId(): number;
  60735. set renderingGroupId(renderingGroupId: number);
  60736. /**
  60737. * An event triggered when the effect layer has been disposed.
  60738. */
  60739. onDisposeObservable: Observable<EffectLayer>;
  60740. /**
  60741. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  60742. */
  60743. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  60744. /**
  60745. * An event triggered when the generated texture is being merged in the scene.
  60746. */
  60747. onBeforeComposeObservable: Observable<EffectLayer>;
  60748. /**
  60749. * An event triggered when the mesh is rendered into the effect render target.
  60750. */
  60751. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  60752. /**
  60753. * An event triggered after the mesh has been rendered into the effect render target.
  60754. */
  60755. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  60756. /**
  60757. * An event triggered when the generated texture has been merged in the scene.
  60758. */
  60759. onAfterComposeObservable: Observable<EffectLayer>;
  60760. /**
  60761. * An event triggered when the efffect layer changes its size.
  60762. */
  60763. onSizeChangedObservable: Observable<EffectLayer>;
  60764. /** @hidden */
  60765. static _SceneComponentInitialization: (scene: Scene) => void;
  60766. /**
  60767. * Instantiates a new effect Layer and references it in the scene.
  60768. * @param name The name of the layer
  60769. * @param scene The scene to use the layer in
  60770. */
  60771. constructor(
  60772. /** The Friendly of the effect in the scene */
  60773. name: string, scene: Scene);
  60774. /**
  60775. * Get the effect name of the layer.
  60776. * @return The effect name
  60777. */
  60778. abstract getEffectName(): string;
  60779. /**
  60780. * Checks for the readiness of the element composing the layer.
  60781. * @param subMesh the mesh to check for
  60782. * @param useInstances specify whether or not to use instances to render the mesh
  60783. * @return true if ready otherwise, false
  60784. */
  60785. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60786. /**
  60787. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60788. * @returns true if the effect requires stencil during the main canvas render pass.
  60789. */
  60790. abstract needStencil(): boolean;
  60791. /**
  60792. * Create the merge effect. This is the shader use to blit the information back
  60793. * to the main canvas at the end of the scene rendering.
  60794. * @returns The effect containing the shader used to merge the effect on the main canvas
  60795. */
  60796. protected abstract _createMergeEffect(): Effect;
  60797. /**
  60798. * Creates the render target textures and post processes used in the effect layer.
  60799. */
  60800. protected abstract _createTextureAndPostProcesses(): void;
  60801. /**
  60802. * Implementation specific of rendering the generating effect on the main canvas.
  60803. * @param effect The effect used to render through
  60804. */
  60805. protected abstract _internalRender(effect: Effect): void;
  60806. /**
  60807. * Sets the required values for both the emissive texture and and the main color.
  60808. */
  60809. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60810. /**
  60811. * Free any resources and references associated to a mesh.
  60812. * Internal use
  60813. * @param mesh The mesh to free.
  60814. */
  60815. abstract _disposeMesh(mesh: Mesh): void;
  60816. /**
  60817. * Serializes this layer (Glow or Highlight for example)
  60818. * @returns a serialized layer object
  60819. */
  60820. abstract serialize?(): any;
  60821. /**
  60822. * Initializes the effect layer with the required options.
  60823. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  60824. */
  60825. protected _init(options: Partial<IEffectLayerOptions>): void;
  60826. /**
  60827. * Generates the index buffer of the full screen quad blending to the main canvas.
  60828. */
  60829. private _generateIndexBuffer;
  60830. /**
  60831. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  60832. */
  60833. private _generateVertexBuffer;
  60834. /**
  60835. * Sets the main texture desired size which is the closest power of two
  60836. * of the engine canvas size.
  60837. */
  60838. private _setMainTextureSize;
  60839. /**
  60840. * Creates the main texture for the effect layer.
  60841. */
  60842. protected _createMainTexture(): void;
  60843. /**
  60844. * Adds specific effects defines.
  60845. * @param defines The defines to add specifics to.
  60846. */
  60847. protected _addCustomEffectDefines(defines: string[]): void;
  60848. /**
  60849. * Checks for the readiness of the element composing the layer.
  60850. * @param subMesh the mesh to check for
  60851. * @param useInstances specify whether or not to use instances to render the mesh
  60852. * @param emissiveTexture the associated emissive texture used to generate the glow
  60853. * @return true if ready otherwise, false
  60854. */
  60855. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  60856. /**
  60857. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  60858. */
  60859. render(): void;
  60860. /**
  60861. * Determine if a given mesh will be used in the current effect.
  60862. * @param mesh mesh to test
  60863. * @returns true if the mesh will be used
  60864. */
  60865. hasMesh(mesh: AbstractMesh): boolean;
  60866. /**
  60867. * Returns true if the layer contains information to display, otherwise false.
  60868. * @returns true if the glow layer should be rendered
  60869. */
  60870. shouldRender(): boolean;
  60871. /**
  60872. * Returns true if the mesh should render, otherwise false.
  60873. * @param mesh The mesh to render
  60874. * @returns true if it should render otherwise false
  60875. */
  60876. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  60877. /**
  60878. * Returns true if the mesh can be rendered, otherwise false.
  60879. * @param mesh The mesh to render
  60880. * @param material The material used on the mesh
  60881. * @returns true if it can be rendered otherwise false
  60882. */
  60883. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60884. /**
  60885. * Returns true if the mesh should render, otherwise false.
  60886. * @param mesh The mesh to render
  60887. * @returns true if it should render otherwise false
  60888. */
  60889. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  60890. /**
  60891. * Renders the submesh passed in parameter to the generation map.
  60892. */
  60893. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60894. /**
  60895. * Defines whether the current material of the mesh should be use to render the effect.
  60896. * @param mesh defines the current mesh to render
  60897. */
  60898. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60899. /**
  60900. * Rebuild the required buffers.
  60901. * @hidden Internal use only.
  60902. */
  60903. _rebuild(): void;
  60904. /**
  60905. * Dispose only the render target textures and post process.
  60906. */
  60907. private _disposeTextureAndPostProcesses;
  60908. /**
  60909. * Dispose the highlight layer and free resources.
  60910. */
  60911. dispose(): void;
  60912. /**
  60913. * Gets the class name of the effect layer
  60914. * @returns the string with the class name of the effect layer
  60915. */
  60916. getClassName(): string;
  60917. /**
  60918. * Creates an effect layer from parsed effect layer data
  60919. * @param parsedEffectLayer defines effect layer data
  60920. * @param scene defines the current scene
  60921. * @param rootUrl defines the root URL containing the effect layer information
  60922. * @returns a parsed effect Layer
  60923. */
  60924. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60925. }
  60926. }
  60927. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  60928. import { Scene } from "babylonjs/scene";
  60929. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60930. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60931. import { AbstractScene } from "babylonjs/abstractScene";
  60932. module "babylonjs/abstractScene" {
  60933. interface AbstractScene {
  60934. /**
  60935. * The list of effect layers (highlights/glow) added to the scene
  60936. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60937. * @see https://doc.babylonjs.com/how_to/glow_layer
  60938. */
  60939. effectLayers: Array<EffectLayer>;
  60940. /**
  60941. * Removes the given effect layer from this scene.
  60942. * @param toRemove defines the effect layer to remove
  60943. * @returns the index of the removed effect layer
  60944. */
  60945. removeEffectLayer(toRemove: EffectLayer): number;
  60946. /**
  60947. * Adds the given effect layer to this scene
  60948. * @param newEffectLayer defines the effect layer to add
  60949. */
  60950. addEffectLayer(newEffectLayer: EffectLayer): void;
  60951. }
  60952. }
  60953. /**
  60954. * Defines the layer scene component responsible to manage any effect layers
  60955. * in a given scene.
  60956. */
  60957. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60958. /**
  60959. * The component name helpfull to identify the component in the list of scene components.
  60960. */
  60961. readonly name: string;
  60962. /**
  60963. * The scene the component belongs to.
  60964. */
  60965. scene: Scene;
  60966. private _engine;
  60967. private _renderEffects;
  60968. private _needStencil;
  60969. private _previousStencilState;
  60970. /**
  60971. * Creates a new instance of the component for the given scene
  60972. * @param scene Defines the scene to register the component in
  60973. */
  60974. constructor(scene: Scene);
  60975. /**
  60976. * Registers the component in a given scene
  60977. */
  60978. register(): void;
  60979. /**
  60980. * Rebuilds the elements related to this component in case of
  60981. * context lost for instance.
  60982. */
  60983. rebuild(): void;
  60984. /**
  60985. * Serializes the component data to the specified json object
  60986. * @param serializationObject The object to serialize to
  60987. */
  60988. serialize(serializationObject: any): void;
  60989. /**
  60990. * Adds all the elements from the container to the scene
  60991. * @param container the container holding the elements
  60992. */
  60993. addFromContainer(container: AbstractScene): void;
  60994. /**
  60995. * Removes all the elements in the container from the scene
  60996. * @param container contains the elements to remove
  60997. * @param dispose if the removed element should be disposed (default: false)
  60998. */
  60999. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61000. /**
  61001. * Disposes the component and the associated ressources.
  61002. */
  61003. dispose(): void;
  61004. private _isReadyForMesh;
  61005. private _renderMainTexture;
  61006. private _setStencil;
  61007. private _setStencilBack;
  61008. private _draw;
  61009. private _drawCamera;
  61010. private _drawRenderingGroup;
  61011. }
  61012. }
  61013. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61014. /** @hidden */
  61015. export var glowMapMergePixelShader: {
  61016. name: string;
  61017. shader: string;
  61018. };
  61019. }
  61020. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61021. /** @hidden */
  61022. export var glowMapMergeVertexShader: {
  61023. name: string;
  61024. shader: string;
  61025. };
  61026. }
  61027. declare module "babylonjs/Layers/glowLayer" {
  61028. import { Nullable } from "babylonjs/types";
  61029. import { Camera } from "babylonjs/Cameras/camera";
  61030. import { Scene } from "babylonjs/scene";
  61031. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61033. import { Mesh } from "babylonjs/Meshes/mesh";
  61034. import { Texture } from "babylonjs/Materials/Textures/texture";
  61035. import { Effect } from "babylonjs/Materials/effect";
  61036. import { Material } from "babylonjs/Materials/material";
  61037. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61038. import { Color4 } from "babylonjs/Maths/math.color";
  61039. import "babylonjs/Shaders/glowMapMerge.fragment";
  61040. import "babylonjs/Shaders/glowMapMerge.vertex";
  61041. import "babylonjs/Layers/effectLayerSceneComponent";
  61042. module "babylonjs/abstractScene" {
  61043. interface AbstractScene {
  61044. /**
  61045. * Return a the first highlight layer of the scene with a given name.
  61046. * @param name The name of the highlight layer to look for.
  61047. * @return The highlight layer if found otherwise null.
  61048. */
  61049. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61050. }
  61051. }
  61052. /**
  61053. * Glow layer options. This helps customizing the behaviour
  61054. * of the glow layer.
  61055. */
  61056. export interface IGlowLayerOptions {
  61057. /**
  61058. * Multiplication factor apply to the canvas size to compute the render target size
  61059. * used to generated the glowing objects (the smaller the faster).
  61060. */
  61061. mainTextureRatio: number;
  61062. /**
  61063. * Enforces a fixed size texture to ensure resize independant blur.
  61064. */
  61065. mainTextureFixedSize?: number;
  61066. /**
  61067. * How big is the kernel of the blur texture.
  61068. */
  61069. blurKernelSize: number;
  61070. /**
  61071. * The camera attached to the layer.
  61072. */
  61073. camera: Nullable<Camera>;
  61074. /**
  61075. * Enable MSAA by chosing the number of samples.
  61076. */
  61077. mainTextureSamples?: number;
  61078. /**
  61079. * The rendering group to draw the layer in.
  61080. */
  61081. renderingGroupId: number;
  61082. }
  61083. /**
  61084. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61085. *
  61086. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61087. *
  61088. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61089. */
  61090. export class GlowLayer extends EffectLayer {
  61091. /**
  61092. * Effect Name of the layer.
  61093. */
  61094. static readonly EffectName: string;
  61095. /**
  61096. * The default blur kernel size used for the glow.
  61097. */
  61098. static DefaultBlurKernelSize: number;
  61099. /**
  61100. * The default texture size ratio used for the glow.
  61101. */
  61102. static DefaultTextureRatio: number;
  61103. /**
  61104. * Sets the kernel size of the blur.
  61105. */
  61106. set blurKernelSize(value: number);
  61107. /**
  61108. * Gets the kernel size of the blur.
  61109. */
  61110. get blurKernelSize(): number;
  61111. /**
  61112. * Sets the glow intensity.
  61113. */
  61114. set intensity(value: number);
  61115. /**
  61116. * Gets the glow intensity.
  61117. */
  61118. get intensity(): number;
  61119. private _options;
  61120. private _intensity;
  61121. private _horizontalBlurPostprocess1;
  61122. private _verticalBlurPostprocess1;
  61123. private _horizontalBlurPostprocess2;
  61124. private _verticalBlurPostprocess2;
  61125. private _blurTexture1;
  61126. private _blurTexture2;
  61127. private _postProcesses1;
  61128. private _postProcesses2;
  61129. private _includedOnlyMeshes;
  61130. private _excludedMeshes;
  61131. private _meshesUsingTheirOwnMaterials;
  61132. /**
  61133. * Callback used to let the user override the color selection on a per mesh basis
  61134. */
  61135. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61136. /**
  61137. * Callback used to let the user override the texture selection on a per mesh basis
  61138. */
  61139. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61140. /**
  61141. * Instantiates a new glow Layer and references it to the scene.
  61142. * @param name The name of the layer
  61143. * @param scene The scene to use the layer in
  61144. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61145. */
  61146. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61147. /**
  61148. * Get the effect name of the layer.
  61149. * @return The effect name
  61150. */
  61151. getEffectName(): string;
  61152. /**
  61153. * Create the merge effect. This is the shader use to blit the information back
  61154. * to the main canvas at the end of the scene rendering.
  61155. */
  61156. protected _createMergeEffect(): Effect;
  61157. /**
  61158. * Creates the render target textures and post processes used in the glow layer.
  61159. */
  61160. protected _createTextureAndPostProcesses(): void;
  61161. /**
  61162. * Checks for the readiness of the element composing the layer.
  61163. * @param subMesh the mesh to check for
  61164. * @param useInstances specify wether or not to use instances to render the mesh
  61165. * @param emissiveTexture the associated emissive texture used to generate the glow
  61166. * @return true if ready otherwise, false
  61167. */
  61168. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61169. /**
  61170. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61171. */
  61172. needStencil(): boolean;
  61173. /**
  61174. * Returns true if the mesh can be rendered, otherwise false.
  61175. * @param mesh The mesh to render
  61176. * @param material The material used on the mesh
  61177. * @returns true if it can be rendered otherwise false
  61178. */
  61179. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61180. /**
  61181. * Implementation specific of rendering the generating effect on the main canvas.
  61182. * @param effect The effect used to render through
  61183. */
  61184. protected _internalRender(effect: Effect): void;
  61185. /**
  61186. * Sets the required values for both the emissive texture and and the main color.
  61187. */
  61188. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61189. /**
  61190. * Returns true if the mesh should render, otherwise false.
  61191. * @param mesh The mesh to render
  61192. * @returns true if it should render otherwise false
  61193. */
  61194. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61195. /**
  61196. * Adds specific effects defines.
  61197. * @param defines The defines to add specifics to.
  61198. */
  61199. protected _addCustomEffectDefines(defines: string[]): void;
  61200. /**
  61201. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61202. * @param mesh The mesh to exclude from the glow layer
  61203. */
  61204. addExcludedMesh(mesh: Mesh): void;
  61205. /**
  61206. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61207. * @param mesh The mesh to remove
  61208. */
  61209. removeExcludedMesh(mesh: Mesh): void;
  61210. /**
  61211. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61212. * @param mesh The mesh to include in the glow layer
  61213. */
  61214. addIncludedOnlyMesh(mesh: Mesh): void;
  61215. /**
  61216. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61217. * @param mesh The mesh to remove
  61218. */
  61219. removeIncludedOnlyMesh(mesh: Mesh): void;
  61220. /**
  61221. * Determine if a given mesh will be used in the glow layer
  61222. * @param mesh The mesh to test
  61223. * @returns true if the mesh will be highlighted by the current glow layer
  61224. */
  61225. hasMesh(mesh: AbstractMesh): boolean;
  61226. /**
  61227. * Defines whether the current material of the mesh should be use to render the effect.
  61228. * @param mesh defines the current mesh to render
  61229. */
  61230. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61231. /**
  61232. * Add a mesh to be rendered through its own material and not with emissive only.
  61233. * @param mesh The mesh for which we need to use its material
  61234. */
  61235. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61236. /**
  61237. * Remove a mesh from being rendered through its own material and not with emissive only.
  61238. * @param mesh The mesh for which we need to not use its material
  61239. */
  61240. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61241. /**
  61242. * Free any resources and references associated to a mesh.
  61243. * Internal use
  61244. * @param mesh The mesh to free.
  61245. * @hidden
  61246. */
  61247. _disposeMesh(mesh: Mesh): void;
  61248. /**
  61249. * Gets the class name of the effect layer
  61250. * @returns the string with the class name of the effect layer
  61251. */
  61252. getClassName(): string;
  61253. /**
  61254. * Serializes this glow layer
  61255. * @returns a serialized glow layer object
  61256. */
  61257. serialize(): any;
  61258. /**
  61259. * Creates a Glow Layer from parsed glow layer data
  61260. * @param parsedGlowLayer defines glow layer data
  61261. * @param scene defines the current scene
  61262. * @param rootUrl defines the root URL containing the glow layer information
  61263. * @returns a parsed Glow Layer
  61264. */
  61265. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61266. }
  61267. }
  61268. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61269. /** @hidden */
  61270. export var glowBlurPostProcessPixelShader: {
  61271. name: string;
  61272. shader: string;
  61273. };
  61274. }
  61275. declare module "babylonjs/Layers/highlightLayer" {
  61276. import { Observable } from "babylonjs/Misc/observable";
  61277. import { Nullable } from "babylonjs/types";
  61278. import { Camera } from "babylonjs/Cameras/camera";
  61279. import { Scene } from "babylonjs/scene";
  61280. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61282. import { Mesh } from "babylonjs/Meshes/mesh";
  61283. import { Effect } from "babylonjs/Materials/effect";
  61284. import { Material } from "babylonjs/Materials/material";
  61285. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61286. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61287. import "babylonjs/Shaders/glowMapMerge.fragment";
  61288. import "babylonjs/Shaders/glowMapMerge.vertex";
  61289. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61290. module "babylonjs/abstractScene" {
  61291. interface AbstractScene {
  61292. /**
  61293. * Return a the first highlight layer of the scene with a given name.
  61294. * @param name The name of the highlight layer to look for.
  61295. * @return The highlight layer if found otherwise null.
  61296. */
  61297. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61298. }
  61299. }
  61300. /**
  61301. * Highlight layer options. This helps customizing the behaviour
  61302. * of the highlight layer.
  61303. */
  61304. export interface IHighlightLayerOptions {
  61305. /**
  61306. * Multiplication factor apply to the canvas size to compute the render target size
  61307. * used to generated the glowing objects (the smaller the faster).
  61308. */
  61309. mainTextureRatio: number;
  61310. /**
  61311. * Enforces a fixed size texture to ensure resize independant blur.
  61312. */
  61313. mainTextureFixedSize?: number;
  61314. /**
  61315. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61316. * of the picture to blur (the smaller the faster).
  61317. */
  61318. blurTextureSizeRatio: number;
  61319. /**
  61320. * How big in texel of the blur texture is the vertical blur.
  61321. */
  61322. blurVerticalSize: number;
  61323. /**
  61324. * How big in texel of the blur texture is the horizontal blur.
  61325. */
  61326. blurHorizontalSize: number;
  61327. /**
  61328. * Alpha blending mode used to apply the blur. Default is combine.
  61329. */
  61330. alphaBlendingMode: number;
  61331. /**
  61332. * The camera attached to the layer.
  61333. */
  61334. camera: Nullable<Camera>;
  61335. /**
  61336. * Should we display highlight as a solid stroke?
  61337. */
  61338. isStroke?: boolean;
  61339. /**
  61340. * The rendering group to draw the layer in.
  61341. */
  61342. renderingGroupId: number;
  61343. }
  61344. /**
  61345. * The highlight layer Helps adding a glow effect around a mesh.
  61346. *
  61347. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61348. * glowy meshes to your scene.
  61349. *
  61350. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61351. */
  61352. export class HighlightLayer extends EffectLayer {
  61353. name: string;
  61354. /**
  61355. * Effect Name of the highlight layer.
  61356. */
  61357. static readonly EffectName: string;
  61358. /**
  61359. * The neutral color used during the preparation of the glow effect.
  61360. * This is black by default as the blend operation is a blend operation.
  61361. */
  61362. static NeutralColor: Color4;
  61363. /**
  61364. * Stencil value used for glowing meshes.
  61365. */
  61366. static GlowingMeshStencilReference: number;
  61367. /**
  61368. * Stencil value used for the other meshes in the scene.
  61369. */
  61370. static NormalMeshStencilReference: number;
  61371. /**
  61372. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61373. */
  61374. innerGlow: boolean;
  61375. /**
  61376. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61377. */
  61378. outerGlow: boolean;
  61379. /**
  61380. * Specifies the horizontal size of the blur.
  61381. */
  61382. set blurHorizontalSize(value: number);
  61383. /**
  61384. * Specifies the vertical size of the blur.
  61385. */
  61386. set blurVerticalSize(value: number);
  61387. /**
  61388. * Gets the horizontal size of the blur.
  61389. */
  61390. get blurHorizontalSize(): number;
  61391. /**
  61392. * Gets the vertical size of the blur.
  61393. */
  61394. get blurVerticalSize(): number;
  61395. /**
  61396. * An event triggered when the highlight layer is being blurred.
  61397. */
  61398. onBeforeBlurObservable: Observable<HighlightLayer>;
  61399. /**
  61400. * An event triggered when the highlight layer has been blurred.
  61401. */
  61402. onAfterBlurObservable: Observable<HighlightLayer>;
  61403. private _instanceGlowingMeshStencilReference;
  61404. private _options;
  61405. private _downSamplePostprocess;
  61406. private _horizontalBlurPostprocess;
  61407. private _verticalBlurPostprocess;
  61408. private _blurTexture;
  61409. private _meshes;
  61410. private _excludedMeshes;
  61411. /**
  61412. * Instantiates a new highlight Layer and references it to the scene..
  61413. * @param name The name of the layer
  61414. * @param scene The scene to use the layer in
  61415. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61416. */
  61417. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61418. /**
  61419. * Get the effect name of the layer.
  61420. * @return The effect name
  61421. */
  61422. getEffectName(): string;
  61423. /**
  61424. * Create the merge effect. This is the shader use to blit the information back
  61425. * to the main canvas at the end of the scene rendering.
  61426. */
  61427. protected _createMergeEffect(): Effect;
  61428. /**
  61429. * Creates the render target textures and post processes used in the highlight layer.
  61430. */
  61431. protected _createTextureAndPostProcesses(): void;
  61432. /**
  61433. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61434. */
  61435. needStencil(): boolean;
  61436. /**
  61437. * Checks for the readiness of the element composing the layer.
  61438. * @param subMesh the mesh to check for
  61439. * @param useInstances specify wether or not to use instances to render the mesh
  61440. * @param emissiveTexture the associated emissive texture used to generate the glow
  61441. * @return true if ready otherwise, false
  61442. */
  61443. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61444. /**
  61445. * Implementation specific of rendering the generating effect on the main canvas.
  61446. * @param effect The effect used to render through
  61447. */
  61448. protected _internalRender(effect: Effect): void;
  61449. /**
  61450. * Returns true if the layer contains information to display, otherwise false.
  61451. */
  61452. shouldRender(): boolean;
  61453. /**
  61454. * Returns true if the mesh should render, otherwise false.
  61455. * @param mesh The mesh to render
  61456. * @returns true if it should render otherwise false
  61457. */
  61458. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61459. /**
  61460. * Returns true if the mesh can be rendered, otherwise false.
  61461. * @param mesh The mesh to render
  61462. * @param material The material used on the mesh
  61463. * @returns true if it can be rendered otherwise false
  61464. */
  61465. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61466. /**
  61467. * Adds specific effects defines.
  61468. * @param defines The defines to add specifics to.
  61469. */
  61470. protected _addCustomEffectDefines(defines: string[]): void;
  61471. /**
  61472. * Sets the required values for both the emissive texture and and the main color.
  61473. */
  61474. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61475. /**
  61476. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61477. * @param mesh The mesh to exclude from the highlight layer
  61478. */
  61479. addExcludedMesh(mesh: Mesh): void;
  61480. /**
  61481. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61482. * @param mesh The mesh to highlight
  61483. */
  61484. removeExcludedMesh(mesh: Mesh): void;
  61485. /**
  61486. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61487. * @param mesh mesh to test
  61488. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61489. */
  61490. hasMesh(mesh: AbstractMesh): boolean;
  61491. /**
  61492. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61493. * @param mesh The mesh to highlight
  61494. * @param color The color of the highlight
  61495. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61496. */
  61497. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61498. /**
  61499. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61500. * @param mesh The mesh to highlight
  61501. */
  61502. removeMesh(mesh: Mesh): void;
  61503. /**
  61504. * Remove all the meshes currently referenced in the highlight layer
  61505. */
  61506. removeAllMeshes(): void;
  61507. /**
  61508. * Force the stencil to the normal expected value for none glowing parts
  61509. */
  61510. private _defaultStencilReference;
  61511. /**
  61512. * Free any resources and references associated to a mesh.
  61513. * Internal use
  61514. * @param mesh The mesh to free.
  61515. * @hidden
  61516. */
  61517. _disposeMesh(mesh: Mesh): void;
  61518. /**
  61519. * Dispose the highlight layer and free resources.
  61520. */
  61521. dispose(): void;
  61522. /**
  61523. * Gets the class name of the effect layer
  61524. * @returns the string with the class name of the effect layer
  61525. */
  61526. getClassName(): string;
  61527. /**
  61528. * Serializes this Highlight layer
  61529. * @returns a serialized Highlight layer object
  61530. */
  61531. serialize(): any;
  61532. /**
  61533. * Creates a Highlight layer from parsed Highlight layer data
  61534. * @param parsedHightlightLayer defines the Highlight layer data
  61535. * @param scene defines the current scene
  61536. * @param rootUrl defines the root URL containing the Highlight layer information
  61537. * @returns a parsed Highlight layer
  61538. */
  61539. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61540. }
  61541. }
  61542. declare module "babylonjs/Layers/layerSceneComponent" {
  61543. import { Scene } from "babylonjs/scene";
  61544. import { ISceneComponent } from "babylonjs/sceneComponent";
  61545. import { Layer } from "babylonjs/Layers/layer";
  61546. import { AbstractScene } from "babylonjs/abstractScene";
  61547. module "babylonjs/abstractScene" {
  61548. interface AbstractScene {
  61549. /**
  61550. * The list of layers (background and foreground) of the scene
  61551. */
  61552. layers: Array<Layer>;
  61553. }
  61554. }
  61555. /**
  61556. * Defines the layer scene component responsible to manage any layers
  61557. * in a given scene.
  61558. */
  61559. export class LayerSceneComponent implements ISceneComponent {
  61560. /**
  61561. * The component name helpfull to identify the component in the list of scene components.
  61562. */
  61563. readonly name: string;
  61564. /**
  61565. * The scene the component belongs to.
  61566. */
  61567. scene: Scene;
  61568. private _engine;
  61569. /**
  61570. * Creates a new instance of the component for the given scene
  61571. * @param scene Defines the scene to register the component in
  61572. */
  61573. constructor(scene: Scene);
  61574. /**
  61575. * Registers the component in a given scene
  61576. */
  61577. register(): void;
  61578. /**
  61579. * Rebuilds the elements related to this component in case of
  61580. * context lost for instance.
  61581. */
  61582. rebuild(): void;
  61583. /**
  61584. * Disposes the component and the associated ressources.
  61585. */
  61586. dispose(): void;
  61587. private _draw;
  61588. private _drawCameraPredicate;
  61589. private _drawCameraBackground;
  61590. private _drawCameraForeground;
  61591. private _drawRenderTargetPredicate;
  61592. private _drawRenderTargetBackground;
  61593. private _drawRenderTargetForeground;
  61594. /**
  61595. * Adds all the elements from the container to the scene
  61596. * @param container the container holding the elements
  61597. */
  61598. addFromContainer(container: AbstractScene): void;
  61599. /**
  61600. * Removes all the elements in the container from the scene
  61601. * @param container contains the elements to remove
  61602. * @param dispose if the removed element should be disposed (default: false)
  61603. */
  61604. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61605. }
  61606. }
  61607. declare module "babylonjs/Shaders/layer.fragment" {
  61608. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61609. /** @hidden */
  61610. export var layerPixelShader: {
  61611. name: string;
  61612. shader: string;
  61613. };
  61614. }
  61615. declare module "babylonjs/Shaders/layer.vertex" {
  61616. /** @hidden */
  61617. export var layerVertexShader: {
  61618. name: string;
  61619. shader: string;
  61620. };
  61621. }
  61622. declare module "babylonjs/Layers/layer" {
  61623. import { Observable } from "babylonjs/Misc/observable";
  61624. import { Nullable } from "babylonjs/types";
  61625. import { Scene } from "babylonjs/scene";
  61626. import { Vector2 } from "babylonjs/Maths/math.vector";
  61627. import { Color4 } from "babylonjs/Maths/math.color";
  61628. import { Texture } from "babylonjs/Materials/Textures/texture";
  61629. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61630. import "babylonjs/Shaders/layer.fragment";
  61631. import "babylonjs/Shaders/layer.vertex";
  61632. /**
  61633. * This represents a full screen 2d layer.
  61634. * This can be useful to display a picture in the background of your scene for instance.
  61635. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61636. */
  61637. export class Layer {
  61638. /**
  61639. * Define the name of the layer.
  61640. */
  61641. name: string;
  61642. /**
  61643. * Define the texture the layer should display.
  61644. */
  61645. texture: Nullable<Texture>;
  61646. /**
  61647. * Is the layer in background or foreground.
  61648. */
  61649. isBackground: boolean;
  61650. /**
  61651. * Define the color of the layer (instead of texture).
  61652. */
  61653. color: Color4;
  61654. /**
  61655. * Define the scale of the layer in order to zoom in out of the texture.
  61656. */
  61657. scale: Vector2;
  61658. /**
  61659. * Define an offset for the layer in order to shift the texture.
  61660. */
  61661. offset: Vector2;
  61662. /**
  61663. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  61664. */
  61665. alphaBlendingMode: number;
  61666. /**
  61667. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  61668. * Alpha test will not mix with the background color in case of transparency.
  61669. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  61670. */
  61671. alphaTest: boolean;
  61672. /**
  61673. * Define a mask to restrict the layer to only some of the scene cameras.
  61674. */
  61675. layerMask: number;
  61676. /**
  61677. * Define the list of render target the layer is visible into.
  61678. */
  61679. renderTargetTextures: RenderTargetTexture[];
  61680. /**
  61681. * Define if the layer is only used in renderTarget or if it also
  61682. * renders in the main frame buffer of the canvas.
  61683. */
  61684. renderOnlyInRenderTargetTextures: boolean;
  61685. private _scene;
  61686. private _vertexBuffers;
  61687. private _indexBuffer;
  61688. private _effect;
  61689. private _previousDefines;
  61690. /**
  61691. * An event triggered when the layer is disposed.
  61692. */
  61693. onDisposeObservable: Observable<Layer>;
  61694. private _onDisposeObserver;
  61695. /**
  61696. * Back compatibility with callback before the onDisposeObservable existed.
  61697. * The set callback will be triggered when the layer has been disposed.
  61698. */
  61699. set onDispose(callback: () => void);
  61700. /**
  61701. * An event triggered before rendering the scene
  61702. */
  61703. onBeforeRenderObservable: Observable<Layer>;
  61704. private _onBeforeRenderObserver;
  61705. /**
  61706. * Back compatibility with callback before the onBeforeRenderObservable existed.
  61707. * The set callback will be triggered just before rendering the layer.
  61708. */
  61709. set onBeforeRender(callback: () => void);
  61710. /**
  61711. * An event triggered after rendering the scene
  61712. */
  61713. onAfterRenderObservable: Observable<Layer>;
  61714. private _onAfterRenderObserver;
  61715. /**
  61716. * Back compatibility with callback before the onAfterRenderObservable existed.
  61717. * The set callback will be triggered just after rendering the layer.
  61718. */
  61719. set onAfterRender(callback: () => void);
  61720. /**
  61721. * Instantiates a new layer.
  61722. * This represents a full screen 2d layer.
  61723. * This can be useful to display a picture in the background of your scene for instance.
  61724. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61725. * @param name Define the name of the layer in the scene
  61726. * @param imgUrl Define the url of the texture to display in the layer
  61727. * @param scene Define the scene the layer belongs to
  61728. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  61729. * @param color Defines a color for the layer
  61730. */
  61731. constructor(
  61732. /**
  61733. * Define the name of the layer.
  61734. */
  61735. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  61736. private _createIndexBuffer;
  61737. /** @hidden */
  61738. _rebuild(): void;
  61739. /**
  61740. * Renders the layer in the scene.
  61741. */
  61742. render(): void;
  61743. /**
  61744. * Disposes and releases the associated ressources.
  61745. */
  61746. dispose(): void;
  61747. }
  61748. }
  61749. declare module "babylonjs/Layers/index" {
  61750. export * from "babylonjs/Layers/effectLayer";
  61751. export * from "babylonjs/Layers/effectLayerSceneComponent";
  61752. export * from "babylonjs/Layers/glowLayer";
  61753. export * from "babylonjs/Layers/highlightLayer";
  61754. export * from "babylonjs/Layers/layer";
  61755. export * from "babylonjs/Layers/layerSceneComponent";
  61756. }
  61757. declare module "babylonjs/Shaders/lensFlare.fragment" {
  61758. /** @hidden */
  61759. export var lensFlarePixelShader: {
  61760. name: string;
  61761. shader: string;
  61762. };
  61763. }
  61764. declare module "babylonjs/Shaders/lensFlare.vertex" {
  61765. /** @hidden */
  61766. export var lensFlareVertexShader: {
  61767. name: string;
  61768. shader: string;
  61769. };
  61770. }
  61771. declare module "babylonjs/LensFlares/lensFlareSystem" {
  61772. import { Scene } from "babylonjs/scene";
  61773. import { Vector3 } from "babylonjs/Maths/math.vector";
  61774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61775. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  61776. import "babylonjs/Shaders/lensFlare.fragment";
  61777. import "babylonjs/Shaders/lensFlare.vertex";
  61778. import { Viewport } from "babylonjs/Maths/math.viewport";
  61779. /**
  61780. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61781. * It is usually composed of several `lensFlare`.
  61782. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61783. */
  61784. export class LensFlareSystem {
  61785. /**
  61786. * Define the name of the lens flare system
  61787. */
  61788. name: string;
  61789. /**
  61790. * List of lens flares used in this system.
  61791. */
  61792. lensFlares: LensFlare[];
  61793. /**
  61794. * Define a limit from the border the lens flare can be visible.
  61795. */
  61796. borderLimit: number;
  61797. /**
  61798. * Define a viewport border we do not want to see the lens flare in.
  61799. */
  61800. viewportBorder: number;
  61801. /**
  61802. * Define a predicate which could limit the list of meshes able to occlude the effect.
  61803. */
  61804. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  61805. /**
  61806. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  61807. */
  61808. layerMask: number;
  61809. /**
  61810. * Define the id of the lens flare system in the scene.
  61811. * (equal to name by default)
  61812. */
  61813. id: string;
  61814. private _scene;
  61815. private _emitter;
  61816. private _vertexBuffers;
  61817. private _indexBuffer;
  61818. private _effect;
  61819. private _positionX;
  61820. private _positionY;
  61821. private _isEnabled;
  61822. /** @hidden */
  61823. static _SceneComponentInitialization: (scene: Scene) => void;
  61824. /**
  61825. * Instantiates a lens flare system.
  61826. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61827. * It is usually composed of several `lensFlare`.
  61828. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61829. * @param name Define the name of the lens flare system in the scene
  61830. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  61831. * @param scene Define the scene the lens flare system belongs to
  61832. */
  61833. constructor(
  61834. /**
  61835. * Define the name of the lens flare system
  61836. */
  61837. name: string, emitter: any, scene: Scene);
  61838. /**
  61839. * Define if the lens flare system is enabled.
  61840. */
  61841. get isEnabled(): boolean;
  61842. set isEnabled(value: boolean);
  61843. /**
  61844. * Get the scene the effects belongs to.
  61845. * @returns the scene holding the lens flare system
  61846. */
  61847. getScene(): Scene;
  61848. /**
  61849. * Get the emitter of the lens flare system.
  61850. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61851. * @returns the emitter of the lens flare system
  61852. */
  61853. getEmitter(): any;
  61854. /**
  61855. * Set the emitter of the lens flare system.
  61856. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61857. * @param newEmitter Define the new emitter of the system
  61858. */
  61859. setEmitter(newEmitter: any): void;
  61860. /**
  61861. * Get the lens flare system emitter position.
  61862. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  61863. * @returns the position
  61864. */
  61865. getEmitterPosition(): Vector3;
  61866. /**
  61867. * @hidden
  61868. */
  61869. computeEffectivePosition(globalViewport: Viewport): boolean;
  61870. /** @hidden */
  61871. _isVisible(): boolean;
  61872. /**
  61873. * @hidden
  61874. */
  61875. render(): boolean;
  61876. /**
  61877. * Dispose and release the lens flare with its associated resources.
  61878. */
  61879. dispose(): void;
  61880. /**
  61881. * Parse a lens flare system from a JSON repressentation
  61882. * @param parsedLensFlareSystem Define the JSON to parse
  61883. * @param scene Define the scene the parsed system should be instantiated in
  61884. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  61885. * @returns the parsed system
  61886. */
  61887. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  61888. /**
  61889. * Serialize the current Lens Flare System into a JSON representation.
  61890. * @returns the serialized JSON
  61891. */
  61892. serialize(): any;
  61893. }
  61894. }
  61895. declare module "babylonjs/LensFlares/lensFlare" {
  61896. import { Nullable } from "babylonjs/types";
  61897. import { Color3 } from "babylonjs/Maths/math.color";
  61898. import { Texture } from "babylonjs/Materials/Textures/texture";
  61899. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61900. /**
  61901. * This represents one of the lens effect in a `lensFlareSystem`.
  61902. * It controls one of the indiviual texture used in the effect.
  61903. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61904. */
  61905. export class LensFlare {
  61906. /**
  61907. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61908. */
  61909. size: number;
  61910. /**
  61911. * 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.
  61912. */
  61913. position: number;
  61914. /**
  61915. * Define the lens color.
  61916. */
  61917. color: Color3;
  61918. /**
  61919. * Define the lens texture.
  61920. */
  61921. texture: Nullable<Texture>;
  61922. /**
  61923. * Define the alpha mode to render this particular lens.
  61924. */
  61925. alphaMode: number;
  61926. private _system;
  61927. /**
  61928. * Creates a new Lens Flare.
  61929. * This represents one of the lens effect in a `lensFlareSystem`.
  61930. * It controls one of the indiviual texture used in the effect.
  61931. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61932. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  61933. * @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.
  61934. * @param color Define the lens color
  61935. * @param imgUrl Define the lens texture url
  61936. * @param system Define the `lensFlareSystem` this flare is part of
  61937. * @returns The newly created Lens Flare
  61938. */
  61939. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  61940. /**
  61941. * Instantiates a new Lens Flare.
  61942. * This represents one of the lens effect in a `lensFlareSystem`.
  61943. * It controls one of the indiviual texture used in the effect.
  61944. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61945. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  61946. * @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.
  61947. * @param color Define the lens color
  61948. * @param imgUrl Define the lens texture url
  61949. * @param system Define the `lensFlareSystem` this flare is part of
  61950. */
  61951. constructor(
  61952. /**
  61953. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61954. */
  61955. size: number,
  61956. /**
  61957. * 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.
  61958. */
  61959. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  61960. /**
  61961. * Dispose and release the lens flare with its associated resources.
  61962. */
  61963. dispose(): void;
  61964. }
  61965. }
  61966. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  61967. import { Nullable } from "babylonjs/types";
  61968. import { Scene } from "babylonjs/scene";
  61969. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61970. import { AbstractScene } from "babylonjs/abstractScene";
  61971. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61972. module "babylonjs/abstractScene" {
  61973. interface AbstractScene {
  61974. /**
  61975. * The list of lens flare system added to the scene
  61976. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61977. */
  61978. lensFlareSystems: Array<LensFlareSystem>;
  61979. /**
  61980. * Removes the given lens flare system from this scene.
  61981. * @param toRemove The lens flare system to remove
  61982. * @returns The index of the removed lens flare system
  61983. */
  61984. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61985. /**
  61986. * Adds the given lens flare system to this scene
  61987. * @param newLensFlareSystem The lens flare system to add
  61988. */
  61989. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61990. /**
  61991. * Gets a lens flare system using its name
  61992. * @param name defines the name to look for
  61993. * @returns the lens flare system or null if not found
  61994. */
  61995. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61996. /**
  61997. * Gets a lens flare system using its id
  61998. * @param id defines the id to look for
  61999. * @returns the lens flare system or null if not found
  62000. */
  62001. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62002. }
  62003. }
  62004. /**
  62005. * Defines the lens flare scene component responsible to manage any lens flares
  62006. * in a given scene.
  62007. */
  62008. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62009. /**
  62010. * The component name helpfull to identify the component in the list of scene components.
  62011. */
  62012. readonly name: string;
  62013. /**
  62014. * The scene the component belongs to.
  62015. */
  62016. scene: Scene;
  62017. /**
  62018. * Creates a new instance of the component for the given scene
  62019. * @param scene Defines the scene to register the component in
  62020. */
  62021. constructor(scene: Scene);
  62022. /**
  62023. * Registers the component in a given scene
  62024. */
  62025. register(): void;
  62026. /**
  62027. * Rebuilds the elements related to this component in case of
  62028. * context lost for instance.
  62029. */
  62030. rebuild(): void;
  62031. /**
  62032. * Adds all the elements from the container to the scene
  62033. * @param container the container holding the elements
  62034. */
  62035. addFromContainer(container: AbstractScene): void;
  62036. /**
  62037. * Removes all the elements in the container from the scene
  62038. * @param container contains the elements to remove
  62039. * @param dispose if the removed element should be disposed (default: false)
  62040. */
  62041. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62042. /**
  62043. * Serializes the component data to the specified json object
  62044. * @param serializationObject The object to serialize to
  62045. */
  62046. serialize(serializationObject: any): void;
  62047. /**
  62048. * Disposes the component and the associated ressources.
  62049. */
  62050. dispose(): void;
  62051. private _draw;
  62052. }
  62053. }
  62054. declare module "babylonjs/LensFlares/index" {
  62055. export * from "babylonjs/LensFlares/lensFlare";
  62056. export * from "babylonjs/LensFlares/lensFlareSystem";
  62057. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62058. }
  62059. declare module "babylonjs/Shaders/depth.fragment" {
  62060. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62061. /** @hidden */
  62062. export var depthPixelShader: {
  62063. name: string;
  62064. shader: string;
  62065. };
  62066. }
  62067. declare module "babylonjs/Shaders/depth.vertex" {
  62068. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62069. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62070. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62071. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62072. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62073. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62074. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62075. /** @hidden */
  62076. export var depthVertexShader: {
  62077. name: string;
  62078. shader: string;
  62079. };
  62080. }
  62081. declare module "babylonjs/Rendering/depthRenderer" {
  62082. import { Nullable } from "babylonjs/types";
  62083. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62084. import { Scene } from "babylonjs/scene";
  62085. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62086. import { Camera } from "babylonjs/Cameras/camera";
  62087. import "babylonjs/Shaders/depth.fragment";
  62088. import "babylonjs/Shaders/depth.vertex";
  62089. /**
  62090. * This represents a depth renderer in Babylon.
  62091. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62092. */
  62093. export class DepthRenderer {
  62094. private _scene;
  62095. private _depthMap;
  62096. private _effect;
  62097. private readonly _storeNonLinearDepth;
  62098. private readonly _clearColor;
  62099. /** Get if the depth renderer is using packed depth or not */
  62100. readonly isPacked: boolean;
  62101. private _cachedDefines;
  62102. private _camera;
  62103. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62104. enabled: boolean;
  62105. /**
  62106. * Specifiess that the depth renderer will only be used within
  62107. * the camera it is created for.
  62108. * This can help forcing its rendering during the camera processing.
  62109. */
  62110. useOnlyInActiveCamera: boolean;
  62111. /** @hidden */
  62112. static _SceneComponentInitialization: (scene: Scene) => void;
  62113. /**
  62114. * Instantiates a depth renderer
  62115. * @param scene The scene the renderer belongs to
  62116. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62117. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62118. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62119. */
  62120. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62121. /**
  62122. * Creates the depth rendering effect and checks if the effect is ready.
  62123. * @param subMesh The submesh to be used to render the depth map of
  62124. * @param useInstances If multiple world instances should be used
  62125. * @returns if the depth renderer is ready to render the depth map
  62126. */
  62127. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62128. /**
  62129. * Gets the texture which the depth map will be written to.
  62130. * @returns The depth map texture
  62131. */
  62132. getDepthMap(): RenderTargetTexture;
  62133. /**
  62134. * Disposes of the depth renderer.
  62135. */
  62136. dispose(): void;
  62137. }
  62138. }
  62139. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62140. /** @hidden */
  62141. export var minmaxReduxPixelShader: {
  62142. name: string;
  62143. shader: string;
  62144. };
  62145. }
  62146. declare module "babylonjs/Misc/minMaxReducer" {
  62147. import { Nullable } from "babylonjs/types";
  62148. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62149. import { Camera } from "babylonjs/Cameras/camera";
  62150. import { Observer } from "babylonjs/Misc/observable";
  62151. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62152. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62153. import { Observable } from "babylonjs/Misc/observable";
  62154. import "babylonjs/Shaders/minmaxRedux.fragment";
  62155. /**
  62156. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62157. * and maximum values from all values of the texture.
  62158. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62159. * The source values are read from the red channel of the texture.
  62160. */
  62161. export class MinMaxReducer {
  62162. /**
  62163. * Observable triggered when the computation has been performed
  62164. */
  62165. onAfterReductionPerformed: Observable<{
  62166. min: number;
  62167. max: number;
  62168. }>;
  62169. protected _camera: Camera;
  62170. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62171. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62172. protected _postProcessManager: PostProcessManager;
  62173. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62174. protected _forceFullscreenViewport: boolean;
  62175. /**
  62176. * Creates a min/max reducer
  62177. * @param camera The camera to use for the post processes
  62178. */
  62179. constructor(camera: Camera);
  62180. /**
  62181. * Gets the texture used to read the values from.
  62182. */
  62183. get sourceTexture(): Nullable<RenderTargetTexture>;
  62184. /**
  62185. * Sets the source texture to read the values from.
  62186. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62187. * because in such textures '1' value must not be taken into account to compute the maximum
  62188. * as this value is used to clear the texture.
  62189. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62190. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62191. * @param depthRedux Indicates if the texture is a depth texture or not
  62192. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62193. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62194. */
  62195. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62196. /**
  62197. * Defines the refresh rate of the computation.
  62198. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62199. */
  62200. get refreshRate(): number;
  62201. set refreshRate(value: number);
  62202. protected _activated: boolean;
  62203. /**
  62204. * Gets the activation status of the reducer
  62205. */
  62206. get activated(): boolean;
  62207. /**
  62208. * Activates the reduction computation.
  62209. * When activated, the observers registered in onAfterReductionPerformed are
  62210. * called after the compuation is performed
  62211. */
  62212. activate(): void;
  62213. /**
  62214. * Deactivates the reduction computation.
  62215. */
  62216. deactivate(): void;
  62217. /**
  62218. * Disposes the min/max reducer
  62219. * @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.
  62220. */
  62221. dispose(disposeAll?: boolean): void;
  62222. }
  62223. }
  62224. declare module "babylonjs/Misc/depthReducer" {
  62225. import { Nullable } from "babylonjs/types";
  62226. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62227. import { Camera } from "babylonjs/Cameras/camera";
  62228. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62229. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62230. /**
  62231. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62232. */
  62233. export class DepthReducer extends MinMaxReducer {
  62234. private _depthRenderer;
  62235. private _depthRendererId;
  62236. /**
  62237. * Gets the depth renderer used for the computation.
  62238. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62239. */
  62240. get depthRenderer(): Nullable<DepthRenderer>;
  62241. /**
  62242. * Creates a depth reducer
  62243. * @param camera The camera used to render the depth texture
  62244. */
  62245. constructor(camera: Camera);
  62246. /**
  62247. * Sets the depth renderer to use to generate the depth map
  62248. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62249. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62250. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62251. */
  62252. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62253. /** @hidden */
  62254. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62255. /**
  62256. * Activates the reduction computation.
  62257. * When activated, the observers registered in onAfterReductionPerformed are
  62258. * called after the compuation is performed
  62259. */
  62260. activate(): void;
  62261. /**
  62262. * Deactivates the reduction computation.
  62263. */
  62264. deactivate(): void;
  62265. /**
  62266. * Disposes the depth reducer
  62267. * @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.
  62268. */
  62269. dispose(disposeAll?: boolean): void;
  62270. }
  62271. }
  62272. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62273. import { Nullable } from "babylonjs/types";
  62274. import { Scene } from "babylonjs/scene";
  62275. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62276. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62278. import { Effect } from "babylonjs/Materials/effect";
  62279. import "babylonjs/Shaders/shadowMap.fragment";
  62280. import "babylonjs/Shaders/shadowMap.vertex";
  62281. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62282. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62283. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62284. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62285. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62286. /**
  62287. * A CSM implementation allowing casting shadows on large scenes.
  62288. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62289. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62290. */
  62291. export class CascadedShadowGenerator extends ShadowGenerator {
  62292. private static readonly frustumCornersNDCSpace;
  62293. /**
  62294. * Name of the CSM class
  62295. */
  62296. static CLASSNAME: string;
  62297. /**
  62298. * Defines the default number of cascades used by the CSM.
  62299. */
  62300. static readonly DEFAULT_CASCADES_COUNT: number;
  62301. /**
  62302. * Defines the minimum number of cascades used by the CSM.
  62303. */
  62304. static readonly MIN_CASCADES_COUNT: number;
  62305. /**
  62306. * Defines the maximum number of cascades used by the CSM.
  62307. */
  62308. static readonly MAX_CASCADES_COUNT: number;
  62309. protected _validateFilter(filter: number): number;
  62310. /**
  62311. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62312. */
  62313. penumbraDarkness: number;
  62314. private _numCascades;
  62315. /**
  62316. * Gets or set the number of cascades used by the CSM.
  62317. */
  62318. get numCascades(): number;
  62319. set numCascades(value: number);
  62320. /**
  62321. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62322. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62323. */
  62324. stabilizeCascades: boolean;
  62325. private _freezeShadowCastersBoundingInfo;
  62326. private _freezeShadowCastersBoundingInfoObservable;
  62327. /**
  62328. * Enables or disables the shadow casters bounding info computation.
  62329. * If your shadow casters don't move, you can disable this feature.
  62330. * If it is enabled, the bounding box computation is done every frame.
  62331. */
  62332. get freezeShadowCastersBoundingInfo(): boolean;
  62333. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62334. private _scbiMin;
  62335. private _scbiMax;
  62336. protected _computeShadowCastersBoundingInfo(): void;
  62337. protected _shadowCastersBoundingInfo: BoundingInfo;
  62338. /**
  62339. * Gets or sets the shadow casters bounding info.
  62340. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62341. * so that the system won't overwrite the bounds you provide
  62342. */
  62343. get shadowCastersBoundingInfo(): BoundingInfo;
  62344. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62345. protected _breaksAreDirty: boolean;
  62346. protected _minDistance: number;
  62347. protected _maxDistance: number;
  62348. /**
  62349. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62350. *
  62351. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62352. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62353. * @param min minimal distance for the breaks (default to 0.)
  62354. * @param max maximal distance for the breaks (default to 1.)
  62355. */
  62356. setMinMaxDistance(min: number, max: number): void;
  62357. /** Gets the minimal distance used in the cascade break computation */
  62358. get minDistance(): number;
  62359. /** Gets the maximal distance used in the cascade break computation */
  62360. get maxDistance(): number;
  62361. /**
  62362. * Gets the class name of that object
  62363. * @returns "CascadedShadowGenerator"
  62364. */
  62365. getClassName(): string;
  62366. private _cascadeMinExtents;
  62367. private _cascadeMaxExtents;
  62368. /**
  62369. * Gets a cascade minimum extents
  62370. * @param cascadeIndex index of the cascade
  62371. * @returns the minimum cascade extents
  62372. */
  62373. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62374. /**
  62375. * Gets a cascade maximum extents
  62376. * @param cascadeIndex index of the cascade
  62377. * @returns the maximum cascade extents
  62378. */
  62379. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62380. private _cascades;
  62381. private _currentLayer;
  62382. private _viewSpaceFrustumsZ;
  62383. private _viewMatrices;
  62384. private _projectionMatrices;
  62385. private _transformMatrices;
  62386. private _transformMatricesAsArray;
  62387. private _frustumLengths;
  62388. private _lightSizeUVCorrection;
  62389. private _depthCorrection;
  62390. private _frustumCornersWorldSpace;
  62391. private _frustumCenter;
  62392. private _shadowCameraPos;
  62393. private _shadowMaxZ;
  62394. /**
  62395. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62396. * It defaults to camera.maxZ
  62397. */
  62398. get shadowMaxZ(): number;
  62399. /**
  62400. * Sets the shadow max z distance.
  62401. */
  62402. set shadowMaxZ(value: number);
  62403. protected _debug: boolean;
  62404. /**
  62405. * Gets or sets the debug flag.
  62406. * When enabled, the cascades are materialized by different colors on the screen.
  62407. */
  62408. get debug(): boolean;
  62409. set debug(dbg: boolean);
  62410. private _depthClamp;
  62411. /**
  62412. * Gets or sets the depth clamping value.
  62413. *
  62414. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62415. * to account for the shadow casters far away.
  62416. *
  62417. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62418. */
  62419. get depthClamp(): boolean;
  62420. set depthClamp(value: boolean);
  62421. private _cascadeBlendPercentage;
  62422. /**
  62423. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62424. * It defaults to 0.1 (10% blending).
  62425. */
  62426. get cascadeBlendPercentage(): number;
  62427. set cascadeBlendPercentage(value: number);
  62428. private _lambda;
  62429. /**
  62430. * Gets or set the lambda parameter.
  62431. * This parameter is used to split the camera frustum and create the cascades.
  62432. * 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.
  62433. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62434. */
  62435. get lambda(): number;
  62436. set lambda(value: number);
  62437. /**
  62438. * Gets the view matrix corresponding to a given cascade
  62439. * @param cascadeNum cascade to retrieve the view matrix from
  62440. * @returns the cascade view matrix
  62441. */
  62442. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62443. /**
  62444. * Gets the projection matrix corresponding to a given cascade
  62445. * @param cascadeNum cascade to retrieve the projection matrix from
  62446. * @returns the cascade projection matrix
  62447. */
  62448. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62449. /**
  62450. * Gets the transformation matrix corresponding to a given cascade
  62451. * @param cascadeNum cascade to retrieve the transformation matrix from
  62452. * @returns the cascade transformation matrix
  62453. */
  62454. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62455. private _depthRenderer;
  62456. /**
  62457. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62458. *
  62459. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62460. *
  62461. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62462. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62463. * @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
  62464. */
  62465. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62466. private _depthReducer;
  62467. private _autoCalcDepthBounds;
  62468. /**
  62469. * Gets or sets the autoCalcDepthBounds property.
  62470. *
  62471. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62472. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62473. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62474. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62475. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62476. */
  62477. get autoCalcDepthBounds(): boolean;
  62478. set autoCalcDepthBounds(value: boolean);
  62479. /**
  62480. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62481. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62482. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62483. * for setting the refresh rate on the renderer yourself!
  62484. */
  62485. get autoCalcDepthBoundsRefreshRate(): number;
  62486. set autoCalcDepthBoundsRefreshRate(value: number);
  62487. /**
  62488. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62489. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62490. * you change the camera near/far planes!
  62491. */
  62492. splitFrustum(): void;
  62493. private _splitFrustum;
  62494. private _computeMatrices;
  62495. private _computeFrustumInWorldSpace;
  62496. private _computeCascadeFrustum;
  62497. /**
  62498. * Support test.
  62499. */
  62500. static get IsSupported(): boolean;
  62501. /** @hidden */
  62502. static _SceneComponentInitialization: (scene: Scene) => void;
  62503. /**
  62504. * Creates a Cascaded Shadow Generator object.
  62505. * A ShadowGenerator is the required tool to use the shadows.
  62506. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62507. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62508. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62509. * @param light The directional light object generating the shadows.
  62510. * @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.
  62511. */
  62512. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62513. protected _initializeGenerator(): void;
  62514. protected _createTargetRenderTexture(): void;
  62515. protected _initializeShadowMap(): void;
  62516. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62517. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62518. /**
  62519. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62520. * @param defines Defines of the material we want to update
  62521. * @param lightIndex Index of the light in the enabled light list of the material
  62522. */
  62523. prepareDefines(defines: any, lightIndex: number): void;
  62524. /**
  62525. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62526. * defined in the generator but impacting the effect).
  62527. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62528. * @param effect The effect we are binfing the information for
  62529. */
  62530. bindShadowLight(lightIndex: string, effect: Effect): void;
  62531. /**
  62532. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62533. * (eq to view projection * shadow projection matrices)
  62534. * @returns The transform matrix used to create the shadow map
  62535. */
  62536. getTransformMatrix(): Matrix;
  62537. /**
  62538. * Disposes the ShadowGenerator.
  62539. * Returns nothing.
  62540. */
  62541. dispose(): void;
  62542. /**
  62543. * Serializes the shadow generator setup to a json object.
  62544. * @returns The serialized JSON object
  62545. */
  62546. serialize(): any;
  62547. /**
  62548. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62549. * @param parsedShadowGenerator The JSON object to parse
  62550. * @param scene The scene to create the shadow map for
  62551. * @returns The parsed shadow generator
  62552. */
  62553. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62554. }
  62555. }
  62556. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62557. import { Scene } from "babylonjs/scene";
  62558. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62559. import { AbstractScene } from "babylonjs/abstractScene";
  62560. /**
  62561. * Defines the shadow generator component responsible to manage any shadow generators
  62562. * in a given scene.
  62563. */
  62564. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62565. /**
  62566. * The component name helpfull to identify the component in the list of scene components.
  62567. */
  62568. readonly name: string;
  62569. /**
  62570. * The scene the component belongs to.
  62571. */
  62572. scene: Scene;
  62573. /**
  62574. * Creates a new instance of the component for the given scene
  62575. * @param scene Defines the scene to register the component in
  62576. */
  62577. constructor(scene: Scene);
  62578. /**
  62579. * Registers the component in a given scene
  62580. */
  62581. register(): void;
  62582. /**
  62583. * Rebuilds the elements related to this component in case of
  62584. * context lost for instance.
  62585. */
  62586. rebuild(): void;
  62587. /**
  62588. * Serializes the component data to the specified json object
  62589. * @param serializationObject The object to serialize to
  62590. */
  62591. serialize(serializationObject: any): void;
  62592. /**
  62593. * Adds all the elements from the container to the scene
  62594. * @param container the container holding the elements
  62595. */
  62596. addFromContainer(container: AbstractScene): void;
  62597. /**
  62598. * Removes all the elements in the container from the scene
  62599. * @param container contains the elements to remove
  62600. * @param dispose if the removed element should be disposed (default: false)
  62601. */
  62602. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62603. /**
  62604. * Rebuilds the elements related to this component in case of
  62605. * context lost for instance.
  62606. */
  62607. dispose(): void;
  62608. private _gatherRenderTargets;
  62609. }
  62610. }
  62611. declare module "babylonjs/Lights/Shadows/index" {
  62612. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62613. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62614. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62615. }
  62616. declare module "babylonjs/Lights/pointLight" {
  62617. import { Scene } from "babylonjs/scene";
  62618. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62620. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62621. import { Effect } from "babylonjs/Materials/effect";
  62622. /**
  62623. * A point light is a light defined by an unique point in world space.
  62624. * The light is emitted in every direction from this point.
  62625. * A good example of a point light is a standard light bulb.
  62626. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62627. */
  62628. export class PointLight extends ShadowLight {
  62629. private _shadowAngle;
  62630. /**
  62631. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62632. * This specifies what angle the shadow will use to be created.
  62633. *
  62634. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62635. */
  62636. get shadowAngle(): number;
  62637. /**
  62638. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62639. * This specifies what angle the shadow will use to be created.
  62640. *
  62641. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62642. */
  62643. set shadowAngle(value: number);
  62644. /**
  62645. * Gets the direction if it has been set.
  62646. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62647. */
  62648. get direction(): Vector3;
  62649. /**
  62650. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62651. */
  62652. set direction(value: Vector3);
  62653. /**
  62654. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  62655. * A PointLight emits the light in every direction.
  62656. * It can cast shadows.
  62657. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  62658. * ```javascript
  62659. * var pointLight = new PointLight("pl", camera.position, scene);
  62660. * ```
  62661. * Documentation : https://doc.babylonjs.com/babylon101/lights
  62662. * @param name The light friendly name
  62663. * @param position The position of the point light in the scene
  62664. * @param scene The scene the lights belongs to
  62665. */
  62666. constructor(name: string, position: Vector3, scene: Scene);
  62667. /**
  62668. * Returns the string "PointLight"
  62669. * @returns the class name
  62670. */
  62671. getClassName(): string;
  62672. /**
  62673. * Returns the integer 0.
  62674. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  62675. */
  62676. getTypeID(): number;
  62677. /**
  62678. * Specifies wether or not the shadowmap should be a cube texture.
  62679. * @returns true if the shadowmap needs to be a cube texture.
  62680. */
  62681. needCube(): boolean;
  62682. /**
  62683. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  62684. * @param faceIndex The index of the face we are computed the direction to generate shadow
  62685. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  62686. */
  62687. getShadowDirection(faceIndex?: number): Vector3;
  62688. /**
  62689. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  62690. * - fov = PI / 2
  62691. * - aspect ratio : 1.0
  62692. * - z-near and far equal to the active camera minZ and maxZ.
  62693. * Returns the PointLight.
  62694. */
  62695. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  62696. protected _buildUniformLayout(): void;
  62697. /**
  62698. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  62699. * @param effect The effect to update
  62700. * @param lightIndex The index of the light in the effect to update
  62701. * @returns The point light
  62702. */
  62703. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  62704. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  62705. /**
  62706. * Prepares the list of defines specific to the light type.
  62707. * @param defines the list of defines
  62708. * @param lightIndex defines the index of the light for the effect
  62709. */
  62710. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  62711. }
  62712. }
  62713. declare module "babylonjs/Lights/index" {
  62714. export * from "babylonjs/Lights/light";
  62715. export * from "babylonjs/Lights/shadowLight";
  62716. export * from "babylonjs/Lights/Shadows/index";
  62717. export * from "babylonjs/Lights/directionalLight";
  62718. export * from "babylonjs/Lights/hemisphericLight";
  62719. export * from "babylonjs/Lights/pointLight";
  62720. export * from "babylonjs/Lights/spotLight";
  62721. }
  62722. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  62723. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62724. /**
  62725. * Header information of HDR texture files.
  62726. */
  62727. export interface HDRInfo {
  62728. /**
  62729. * The height of the texture in pixels.
  62730. */
  62731. height: number;
  62732. /**
  62733. * The width of the texture in pixels.
  62734. */
  62735. width: number;
  62736. /**
  62737. * The index of the beginning of the data in the binary file.
  62738. */
  62739. dataPosition: number;
  62740. }
  62741. /**
  62742. * This groups tools to convert HDR texture to native colors array.
  62743. */
  62744. export class HDRTools {
  62745. private static Ldexp;
  62746. private static Rgbe2float;
  62747. private static readStringLine;
  62748. /**
  62749. * Reads header information from an RGBE texture stored in a native array.
  62750. * More information on this format are available here:
  62751. * https://en.wikipedia.org/wiki/RGBE_image_format
  62752. *
  62753. * @param uint8array The binary file stored in native array.
  62754. * @return The header information.
  62755. */
  62756. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  62757. /**
  62758. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  62759. * This RGBE texture needs to store the information as a panorama.
  62760. *
  62761. * More information on this format are available here:
  62762. * https://en.wikipedia.org/wiki/RGBE_image_format
  62763. *
  62764. * @param buffer The binary file stored in an array buffer.
  62765. * @param size The expected size of the extracted cubemap.
  62766. * @return The Cube Map information.
  62767. */
  62768. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  62769. /**
  62770. * Returns the pixels data extracted from an RGBE texture.
  62771. * This pixels will be stored left to right up to down in the R G B order in one array.
  62772. *
  62773. * More information on this format are available here:
  62774. * https://en.wikipedia.org/wiki/RGBE_image_format
  62775. *
  62776. * @param uint8array The binary file stored in an array buffer.
  62777. * @param hdrInfo The header information of the file.
  62778. * @return The pixels data in RGB right to left up to down order.
  62779. */
  62780. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  62781. private static RGBE_ReadPixels_RLE;
  62782. private static RGBE_ReadPixels_NOT_RLE;
  62783. }
  62784. }
  62785. declare module "babylonjs/Materials/effectRenderer" {
  62786. import { Nullable } from "babylonjs/types";
  62787. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62788. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62789. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62790. import { Viewport } from "babylonjs/Maths/math.viewport";
  62791. import { Observable } from "babylonjs/Misc/observable";
  62792. import { Effect } from "babylonjs/Materials/effect";
  62793. import "babylonjs/Shaders/postprocess.vertex";
  62794. /**
  62795. * Effect Render Options
  62796. */
  62797. export interface IEffectRendererOptions {
  62798. /**
  62799. * Defines the vertices positions.
  62800. */
  62801. positions?: number[];
  62802. /**
  62803. * Defines the indices.
  62804. */
  62805. indices?: number[];
  62806. }
  62807. /**
  62808. * Helper class to render one or more effects.
  62809. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62810. */
  62811. export class EffectRenderer {
  62812. private engine;
  62813. private static _DefaultOptions;
  62814. private _vertexBuffers;
  62815. private _indexBuffer;
  62816. private _fullscreenViewport;
  62817. /**
  62818. * Creates an effect renderer
  62819. * @param engine the engine to use for rendering
  62820. * @param options defines the options of the effect renderer
  62821. */
  62822. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62823. /**
  62824. * Sets the current viewport in normalized coordinates 0-1
  62825. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62826. */
  62827. setViewport(viewport?: Viewport): void;
  62828. /**
  62829. * Binds the embedded attributes buffer to the effect.
  62830. * @param effect Defines the effect to bind the attributes for
  62831. */
  62832. bindBuffers(effect: Effect): void;
  62833. /**
  62834. * Sets the current effect wrapper to use during draw.
  62835. * The effect needs to be ready before calling this api.
  62836. * This also sets the default full screen position attribute.
  62837. * @param effectWrapper Defines the effect to draw with
  62838. */
  62839. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62840. /**
  62841. * Restores engine states
  62842. */
  62843. restoreStates(): void;
  62844. /**
  62845. * Draws a full screen quad.
  62846. */
  62847. draw(): void;
  62848. private isRenderTargetTexture;
  62849. /**
  62850. * renders one or more effects to a specified texture
  62851. * @param effectWrapper the effect to renderer
  62852. * @param outputTexture texture to draw to, if null it will render to the screen.
  62853. */
  62854. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  62855. /**
  62856. * Disposes of the effect renderer
  62857. */
  62858. dispose(): void;
  62859. }
  62860. /**
  62861. * Options to create an EffectWrapper
  62862. */
  62863. interface EffectWrapperCreationOptions {
  62864. /**
  62865. * Engine to use to create the effect
  62866. */
  62867. engine: ThinEngine;
  62868. /**
  62869. * Fragment shader for the effect
  62870. */
  62871. fragmentShader: string;
  62872. /**
  62873. * Use the shader store instead of direct source code
  62874. */
  62875. useShaderStore?: boolean;
  62876. /**
  62877. * Vertex shader for the effect
  62878. */
  62879. vertexShader?: string;
  62880. /**
  62881. * Attributes to use in the shader
  62882. */
  62883. attributeNames?: Array<string>;
  62884. /**
  62885. * Uniforms to use in the shader
  62886. */
  62887. uniformNames?: Array<string>;
  62888. /**
  62889. * Texture sampler names to use in the shader
  62890. */
  62891. samplerNames?: Array<string>;
  62892. /**
  62893. * Defines to use in the shader
  62894. */
  62895. defines?: Array<string>;
  62896. /**
  62897. * Callback when effect is compiled
  62898. */
  62899. onCompiled?: Nullable<(effect: Effect) => void>;
  62900. /**
  62901. * The friendly name of the effect displayed in Spector.
  62902. */
  62903. name?: string;
  62904. }
  62905. /**
  62906. * Wraps an effect to be used for rendering
  62907. */
  62908. export class EffectWrapper {
  62909. /**
  62910. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62911. */
  62912. onApplyObservable: Observable<{}>;
  62913. /**
  62914. * The underlying effect
  62915. */
  62916. effect: Effect;
  62917. /**
  62918. * Creates an effect to be renderer
  62919. * @param creationOptions options to create the effect
  62920. */
  62921. constructor(creationOptions: EffectWrapperCreationOptions);
  62922. /**
  62923. * Disposes of the effect wrapper
  62924. */
  62925. dispose(): void;
  62926. }
  62927. }
  62928. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  62929. /** @hidden */
  62930. export var hdrFilteringVertexShader: {
  62931. name: string;
  62932. shader: string;
  62933. };
  62934. }
  62935. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  62936. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62937. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  62938. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  62939. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  62940. /** @hidden */
  62941. export var hdrFilteringPixelShader: {
  62942. name: string;
  62943. shader: string;
  62944. };
  62945. }
  62946. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  62947. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62948. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62949. import { Nullable } from "babylonjs/types";
  62950. import "babylonjs/Shaders/hdrFiltering.vertex";
  62951. import "babylonjs/Shaders/hdrFiltering.fragment";
  62952. /**
  62953. * Options for texture filtering
  62954. */
  62955. interface IHDRFilteringOptions {
  62956. /**
  62957. * Scales pixel intensity for the input HDR map.
  62958. */
  62959. hdrScale?: number;
  62960. /**
  62961. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  62962. */
  62963. quality?: number;
  62964. }
  62965. /**
  62966. * Filters HDR maps to get correct renderings of PBR reflections
  62967. */
  62968. export class HDRFiltering {
  62969. private _engine;
  62970. private _effectRenderer;
  62971. private _effectWrapper;
  62972. private _lodGenerationOffset;
  62973. private _lodGenerationScale;
  62974. /**
  62975. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  62976. * you care about baking speed.
  62977. */
  62978. quality: number;
  62979. /**
  62980. * Scales pixel intensity for the input HDR map.
  62981. */
  62982. hdrScale: number;
  62983. /**
  62984. * Instantiates HDR filter for reflection maps
  62985. *
  62986. * @param engine Thin engine
  62987. * @param options Options
  62988. */
  62989. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  62990. private _createRenderTarget;
  62991. private _prefilterInternal;
  62992. private _createEffect;
  62993. /**
  62994. * Get a value indicating if the filter is ready to be used
  62995. * @param texture Texture to filter
  62996. * @returns true if the filter is ready
  62997. */
  62998. isReady(texture: BaseTexture): boolean;
  62999. /**
  63000. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63001. * Prefiltering will be invoked at the end of next rendering pass.
  63002. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63003. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63004. * @param texture Texture to filter
  63005. * @param onFinished Callback when filtering is done
  63006. * @return Promise called when prefiltering is done
  63007. */
  63008. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63009. }
  63010. }
  63011. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63012. import { Nullable } from "babylonjs/types";
  63013. import { Scene } from "babylonjs/scene";
  63014. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63015. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63016. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63017. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63018. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63019. /**
  63020. * This represents a texture coming from an HDR input.
  63021. *
  63022. * The only supported format is currently panorama picture stored in RGBE format.
  63023. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63024. */
  63025. export class HDRCubeTexture extends BaseTexture {
  63026. private static _facesMapping;
  63027. private _generateHarmonics;
  63028. private _noMipmap;
  63029. private _prefilterOnLoad;
  63030. private _textureMatrix;
  63031. private _size;
  63032. private _onLoad;
  63033. private _onError;
  63034. /**
  63035. * The texture URL.
  63036. */
  63037. url: string;
  63038. /**
  63039. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  63040. */
  63041. coordinatesMode: number;
  63042. protected _isBlocking: boolean;
  63043. /**
  63044. * Sets wether or not the texture is blocking during loading.
  63045. */
  63046. set isBlocking(value: boolean);
  63047. /**
  63048. * Gets wether or not the texture is blocking during loading.
  63049. */
  63050. get isBlocking(): boolean;
  63051. protected _rotationY: number;
  63052. /**
  63053. * Sets texture matrix rotation angle around Y axis in radians.
  63054. */
  63055. set rotationY(value: number);
  63056. /**
  63057. * Gets texture matrix rotation angle around Y axis radians.
  63058. */
  63059. get rotationY(): number;
  63060. /**
  63061. * Gets or sets the center of the bounding box associated with the cube texture
  63062. * It must define where the camera used to render the texture was set
  63063. */
  63064. boundingBoxPosition: Vector3;
  63065. private _boundingBoxSize;
  63066. /**
  63067. * Gets or sets the size of the bounding box associated with the cube texture
  63068. * When defined, the cubemap will switch to local mode
  63069. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63070. * @example https://www.babylonjs-playground.com/#RNASML
  63071. */
  63072. set boundingBoxSize(value: Vector3);
  63073. get boundingBoxSize(): Vector3;
  63074. /**
  63075. * Instantiates an HDRTexture from the following parameters.
  63076. *
  63077. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63078. * @param sceneOrEngine The scene or engine the texture will be used in
  63079. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63080. * @param noMipmap Forces to not generate the mipmap if true
  63081. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63082. * @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)
  63083. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63084. */
  63085. 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>);
  63086. /**
  63087. * Get the current class name of the texture useful for serialization or dynamic coding.
  63088. * @returns "HDRCubeTexture"
  63089. */
  63090. getClassName(): string;
  63091. /**
  63092. * Occurs when the file is raw .hdr file.
  63093. */
  63094. private loadTexture;
  63095. clone(): HDRCubeTexture;
  63096. delayLoad(): void;
  63097. /**
  63098. * Get the texture reflection matrix used to rotate/transform the reflection.
  63099. * @returns the reflection matrix
  63100. */
  63101. getReflectionTextureMatrix(): Matrix;
  63102. /**
  63103. * Set the texture reflection matrix used to rotate/transform the reflection.
  63104. * @param value Define the reflection matrix to set
  63105. */
  63106. setReflectionTextureMatrix(value: Matrix): void;
  63107. /**
  63108. * Parses a JSON representation of an HDR Texture in order to create the texture
  63109. * @param parsedTexture Define the JSON representation
  63110. * @param scene Define the scene the texture should be created in
  63111. * @param rootUrl Define the root url in case we need to load relative dependencies
  63112. * @returns the newly created texture after parsing
  63113. */
  63114. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63115. serialize(): any;
  63116. }
  63117. }
  63118. declare module "babylonjs/Physics/physicsEngine" {
  63119. import { Nullable } from "babylonjs/types";
  63120. import { Vector3 } from "babylonjs/Maths/math.vector";
  63121. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63122. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63123. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63124. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63125. /**
  63126. * Class used to control physics engine
  63127. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63128. */
  63129. export class PhysicsEngine implements IPhysicsEngine {
  63130. private _physicsPlugin;
  63131. /**
  63132. * Global value used to control the smallest number supported by the simulation
  63133. */
  63134. static Epsilon: number;
  63135. private _impostors;
  63136. private _joints;
  63137. private _subTimeStep;
  63138. /**
  63139. * Gets the gravity vector used by the simulation
  63140. */
  63141. gravity: Vector3;
  63142. /**
  63143. * Factory used to create the default physics plugin.
  63144. * @returns The default physics plugin
  63145. */
  63146. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63147. /**
  63148. * Creates a new Physics Engine
  63149. * @param gravity defines the gravity vector used by the simulation
  63150. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63151. */
  63152. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63153. /**
  63154. * Sets the gravity vector used by the simulation
  63155. * @param gravity defines the gravity vector to use
  63156. */
  63157. setGravity(gravity: Vector3): void;
  63158. /**
  63159. * Set the time step of the physics engine.
  63160. * Default is 1/60.
  63161. * To slow it down, enter 1/600 for example.
  63162. * To speed it up, 1/30
  63163. * @param newTimeStep defines the new timestep to apply to this world.
  63164. */
  63165. setTimeStep(newTimeStep?: number): void;
  63166. /**
  63167. * Get the time step of the physics engine.
  63168. * @returns the current time step
  63169. */
  63170. getTimeStep(): number;
  63171. /**
  63172. * Set the sub time step of the physics engine.
  63173. * Default is 0 meaning there is no sub steps
  63174. * To increase physics resolution precision, set a small value (like 1 ms)
  63175. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63176. */
  63177. setSubTimeStep(subTimeStep?: number): void;
  63178. /**
  63179. * Get the sub time step of the physics engine.
  63180. * @returns the current sub time step
  63181. */
  63182. getSubTimeStep(): number;
  63183. /**
  63184. * Release all resources
  63185. */
  63186. dispose(): void;
  63187. /**
  63188. * Gets the name of the current physics plugin
  63189. * @returns the name of the plugin
  63190. */
  63191. getPhysicsPluginName(): string;
  63192. /**
  63193. * Adding a new impostor for the impostor tracking.
  63194. * This will be done by the impostor itself.
  63195. * @param impostor the impostor to add
  63196. */
  63197. addImpostor(impostor: PhysicsImpostor): void;
  63198. /**
  63199. * Remove an impostor from the engine.
  63200. * This impostor and its mesh will not longer be updated by the physics engine.
  63201. * @param impostor the impostor to remove
  63202. */
  63203. removeImpostor(impostor: PhysicsImpostor): void;
  63204. /**
  63205. * Add a joint to the physics engine
  63206. * @param mainImpostor defines the main impostor to which the joint is added.
  63207. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63208. * @param joint defines the joint that will connect both impostors.
  63209. */
  63210. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63211. /**
  63212. * Removes a joint from the simulation
  63213. * @param mainImpostor defines the impostor used with the joint
  63214. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63215. * @param joint defines the joint to remove
  63216. */
  63217. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63218. /**
  63219. * Called by the scene. No need to call it.
  63220. * @param delta defines the timespam between frames
  63221. */
  63222. _step(delta: number): void;
  63223. /**
  63224. * Gets the current plugin used to run the simulation
  63225. * @returns current plugin
  63226. */
  63227. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63228. /**
  63229. * Gets the list of physic impostors
  63230. * @returns an array of PhysicsImpostor
  63231. */
  63232. getImpostors(): Array<PhysicsImpostor>;
  63233. /**
  63234. * Gets the impostor for a physics enabled object
  63235. * @param object defines the object impersonated by the impostor
  63236. * @returns the PhysicsImpostor or null if not found
  63237. */
  63238. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63239. /**
  63240. * Gets the impostor for a physics body object
  63241. * @param body defines physics body used by the impostor
  63242. * @returns the PhysicsImpostor or null if not found
  63243. */
  63244. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63245. /**
  63246. * Does a raycast in the physics world
  63247. * @param from when should the ray start?
  63248. * @param to when should the ray end?
  63249. * @returns PhysicsRaycastResult
  63250. */
  63251. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63252. }
  63253. }
  63254. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63255. import { Nullable } from "babylonjs/types";
  63256. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63258. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63259. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63260. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63261. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63262. /** @hidden */
  63263. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63264. private _useDeltaForWorldStep;
  63265. world: any;
  63266. name: string;
  63267. private _physicsMaterials;
  63268. private _fixedTimeStep;
  63269. private _cannonRaycastResult;
  63270. private _raycastResult;
  63271. private _physicsBodysToRemoveAfterStep;
  63272. private _firstFrame;
  63273. BJSCANNON: any;
  63274. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63275. setGravity(gravity: Vector3): void;
  63276. setTimeStep(timeStep: number): void;
  63277. getTimeStep(): number;
  63278. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63279. private _removeMarkedPhysicsBodiesFromWorld;
  63280. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63281. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63282. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63283. private _processChildMeshes;
  63284. removePhysicsBody(impostor: PhysicsImpostor): void;
  63285. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63286. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63287. private _addMaterial;
  63288. private _checkWithEpsilon;
  63289. private _createShape;
  63290. private _createHeightmap;
  63291. private _minus90X;
  63292. private _plus90X;
  63293. private _tmpPosition;
  63294. private _tmpDeltaPosition;
  63295. private _tmpUnityRotation;
  63296. private _updatePhysicsBodyTransformation;
  63297. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63298. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63299. isSupported(): boolean;
  63300. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63301. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63302. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63303. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63304. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63305. getBodyMass(impostor: PhysicsImpostor): number;
  63306. getBodyFriction(impostor: PhysicsImpostor): number;
  63307. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63308. getBodyRestitution(impostor: PhysicsImpostor): number;
  63309. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63310. sleepBody(impostor: PhysicsImpostor): void;
  63311. wakeUpBody(impostor: PhysicsImpostor): void;
  63312. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63313. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63314. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63315. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63316. getRadius(impostor: PhysicsImpostor): number;
  63317. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63318. dispose(): void;
  63319. private _extendNamespace;
  63320. /**
  63321. * Does a raycast in the physics world
  63322. * @param from when should the ray start?
  63323. * @param to when should the ray end?
  63324. * @returns PhysicsRaycastResult
  63325. */
  63326. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63327. }
  63328. }
  63329. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63330. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63331. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63332. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63334. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63335. import { Nullable } from "babylonjs/types";
  63336. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63337. /** @hidden */
  63338. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63339. private _useDeltaForWorldStep;
  63340. world: any;
  63341. name: string;
  63342. BJSOIMO: any;
  63343. private _raycastResult;
  63344. private _fixedTimeStep;
  63345. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63346. setGravity(gravity: Vector3): void;
  63347. setTimeStep(timeStep: number): void;
  63348. getTimeStep(): number;
  63349. private _tmpImpostorsArray;
  63350. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63351. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63352. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63353. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63354. private _tmpPositionVector;
  63355. removePhysicsBody(impostor: PhysicsImpostor): void;
  63356. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63357. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63358. isSupported(): boolean;
  63359. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63360. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63361. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63362. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63363. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63364. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63365. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63366. getBodyMass(impostor: PhysicsImpostor): number;
  63367. getBodyFriction(impostor: PhysicsImpostor): number;
  63368. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63369. getBodyRestitution(impostor: PhysicsImpostor): number;
  63370. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63371. sleepBody(impostor: PhysicsImpostor): void;
  63372. wakeUpBody(impostor: PhysicsImpostor): void;
  63373. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63374. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63375. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63376. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63377. getRadius(impostor: PhysicsImpostor): number;
  63378. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63379. dispose(): void;
  63380. /**
  63381. * Does a raycast in the physics world
  63382. * @param from when should the ray start?
  63383. * @param to when should the ray end?
  63384. * @returns PhysicsRaycastResult
  63385. */
  63386. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63387. }
  63388. }
  63389. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63390. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63391. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63392. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63393. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63394. import { Nullable } from "babylonjs/types";
  63395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63396. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63397. /**
  63398. * AmmoJS Physics plugin
  63399. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63400. * @see https://github.com/kripken/ammo.js/
  63401. */
  63402. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63403. private _useDeltaForWorldStep;
  63404. /**
  63405. * Reference to the Ammo library
  63406. */
  63407. bjsAMMO: any;
  63408. /**
  63409. * Created ammoJS world which physics bodies are added to
  63410. */
  63411. world: any;
  63412. /**
  63413. * Name of the plugin
  63414. */
  63415. name: string;
  63416. private _timeStep;
  63417. private _fixedTimeStep;
  63418. private _maxSteps;
  63419. private _tmpQuaternion;
  63420. private _tmpAmmoTransform;
  63421. private _tmpAmmoQuaternion;
  63422. private _tmpAmmoConcreteContactResultCallback;
  63423. private _collisionConfiguration;
  63424. private _dispatcher;
  63425. private _overlappingPairCache;
  63426. private _solver;
  63427. private _softBodySolver;
  63428. private _tmpAmmoVectorA;
  63429. private _tmpAmmoVectorB;
  63430. private _tmpAmmoVectorC;
  63431. private _tmpAmmoVectorD;
  63432. private _tmpContactCallbackResult;
  63433. private _tmpAmmoVectorRCA;
  63434. private _tmpAmmoVectorRCB;
  63435. private _raycastResult;
  63436. private static readonly DISABLE_COLLISION_FLAG;
  63437. private static readonly KINEMATIC_FLAG;
  63438. private static readonly DISABLE_DEACTIVATION_FLAG;
  63439. /**
  63440. * Initializes the ammoJS plugin
  63441. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63442. * @param ammoInjection can be used to inject your own ammo reference
  63443. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63444. */
  63445. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63446. /**
  63447. * Sets the gravity of the physics world (m/(s^2))
  63448. * @param gravity Gravity to set
  63449. */
  63450. setGravity(gravity: Vector3): void;
  63451. /**
  63452. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63453. * @param timeStep timestep to use in seconds
  63454. */
  63455. setTimeStep(timeStep: number): void;
  63456. /**
  63457. * 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)
  63458. * @param fixedTimeStep fixedTimeStep to use in seconds
  63459. */
  63460. setFixedTimeStep(fixedTimeStep: number): void;
  63461. /**
  63462. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63463. * @param maxSteps the maximum number of steps by the physics engine per frame
  63464. */
  63465. setMaxSteps(maxSteps: number): void;
  63466. /**
  63467. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63468. * @returns the current timestep in seconds
  63469. */
  63470. getTimeStep(): number;
  63471. /**
  63472. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63473. */
  63474. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63475. private _isImpostorInContact;
  63476. private _isImpostorPairInContact;
  63477. private _stepSimulation;
  63478. /**
  63479. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63480. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63481. * After the step the babylon meshes are set to the position of the physics imposters
  63482. * @param delta amount of time to step forward
  63483. * @param impostors array of imposters to update before/after the step
  63484. */
  63485. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63486. /**
  63487. * Update babylon mesh to match physics world object
  63488. * @param impostor imposter to match
  63489. */
  63490. private _afterSoftStep;
  63491. /**
  63492. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63493. * @param impostor imposter to match
  63494. */
  63495. private _ropeStep;
  63496. /**
  63497. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63498. * @param impostor imposter to match
  63499. */
  63500. private _softbodyOrClothStep;
  63501. private _tmpMatrix;
  63502. /**
  63503. * Applies an impulse on the imposter
  63504. * @param impostor imposter to apply impulse to
  63505. * @param force amount of force to be applied to the imposter
  63506. * @param contactPoint the location to apply the impulse on the imposter
  63507. */
  63508. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63509. /**
  63510. * Applies a force on the imposter
  63511. * @param impostor imposter to apply force
  63512. * @param force amount of force to be applied to the imposter
  63513. * @param contactPoint the location to apply the force on the imposter
  63514. */
  63515. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63516. /**
  63517. * Creates a physics body using the plugin
  63518. * @param impostor the imposter to create the physics body on
  63519. */
  63520. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63521. /**
  63522. * Removes the physics body from the imposter and disposes of the body's memory
  63523. * @param impostor imposter to remove the physics body from
  63524. */
  63525. removePhysicsBody(impostor: PhysicsImpostor): void;
  63526. /**
  63527. * Generates a joint
  63528. * @param impostorJoint the imposter joint to create the joint with
  63529. */
  63530. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63531. /**
  63532. * Removes a joint
  63533. * @param impostorJoint the imposter joint to remove the joint from
  63534. */
  63535. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63536. private _addMeshVerts;
  63537. /**
  63538. * Initialise the soft body vertices to match its object's (mesh) vertices
  63539. * Softbody vertices (nodes) are in world space and to match this
  63540. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63541. * @param impostor to create the softbody for
  63542. */
  63543. private _softVertexData;
  63544. /**
  63545. * Create an impostor's soft body
  63546. * @param impostor to create the softbody for
  63547. */
  63548. private _createSoftbody;
  63549. /**
  63550. * Create cloth for an impostor
  63551. * @param impostor to create the softbody for
  63552. */
  63553. private _createCloth;
  63554. /**
  63555. * Create rope for an impostor
  63556. * @param impostor to create the softbody for
  63557. */
  63558. private _createRope;
  63559. /**
  63560. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63561. * @param impostor to create the custom physics shape for
  63562. */
  63563. private _createCustom;
  63564. private _addHullVerts;
  63565. private _createShape;
  63566. /**
  63567. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63568. * @param impostor imposter containing the physics body and babylon object
  63569. */
  63570. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63571. /**
  63572. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63573. * @param impostor imposter containing the physics body and babylon object
  63574. * @param newPosition new position
  63575. * @param newRotation new rotation
  63576. */
  63577. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63578. /**
  63579. * If this plugin is supported
  63580. * @returns true if its supported
  63581. */
  63582. isSupported(): boolean;
  63583. /**
  63584. * Sets the linear velocity of the physics body
  63585. * @param impostor imposter to set the velocity on
  63586. * @param velocity velocity to set
  63587. */
  63588. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63589. /**
  63590. * Sets the angular velocity of the physics body
  63591. * @param impostor imposter to set the velocity on
  63592. * @param velocity velocity to set
  63593. */
  63594. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63595. /**
  63596. * gets the linear velocity
  63597. * @param impostor imposter to get linear velocity from
  63598. * @returns linear velocity
  63599. */
  63600. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63601. /**
  63602. * gets the angular velocity
  63603. * @param impostor imposter to get angular velocity from
  63604. * @returns angular velocity
  63605. */
  63606. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63607. /**
  63608. * Sets the mass of physics body
  63609. * @param impostor imposter to set the mass on
  63610. * @param mass mass to set
  63611. */
  63612. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63613. /**
  63614. * Gets the mass of the physics body
  63615. * @param impostor imposter to get the mass from
  63616. * @returns mass
  63617. */
  63618. getBodyMass(impostor: PhysicsImpostor): number;
  63619. /**
  63620. * Gets friction of the impostor
  63621. * @param impostor impostor to get friction from
  63622. * @returns friction value
  63623. */
  63624. getBodyFriction(impostor: PhysicsImpostor): number;
  63625. /**
  63626. * Sets friction of the impostor
  63627. * @param impostor impostor to set friction on
  63628. * @param friction friction value
  63629. */
  63630. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63631. /**
  63632. * Gets restitution of the impostor
  63633. * @param impostor impostor to get restitution from
  63634. * @returns restitution value
  63635. */
  63636. getBodyRestitution(impostor: PhysicsImpostor): number;
  63637. /**
  63638. * Sets resitution of the impostor
  63639. * @param impostor impostor to set resitution on
  63640. * @param restitution resitution value
  63641. */
  63642. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63643. /**
  63644. * Gets pressure inside the impostor
  63645. * @param impostor impostor to get pressure from
  63646. * @returns pressure value
  63647. */
  63648. getBodyPressure(impostor: PhysicsImpostor): number;
  63649. /**
  63650. * Sets pressure inside a soft body impostor
  63651. * Cloth and rope must remain 0 pressure
  63652. * @param impostor impostor to set pressure on
  63653. * @param pressure pressure value
  63654. */
  63655. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  63656. /**
  63657. * Gets stiffness of the impostor
  63658. * @param impostor impostor to get stiffness from
  63659. * @returns pressure value
  63660. */
  63661. getBodyStiffness(impostor: PhysicsImpostor): number;
  63662. /**
  63663. * Sets stiffness of the impostor
  63664. * @param impostor impostor to set stiffness on
  63665. * @param stiffness stiffness value from 0 to 1
  63666. */
  63667. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  63668. /**
  63669. * Gets velocityIterations of the impostor
  63670. * @param impostor impostor to get velocity iterations from
  63671. * @returns velocityIterations value
  63672. */
  63673. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  63674. /**
  63675. * Sets velocityIterations of the impostor
  63676. * @param impostor impostor to set velocity iterations on
  63677. * @param velocityIterations velocityIterations value
  63678. */
  63679. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  63680. /**
  63681. * Gets positionIterations of the impostor
  63682. * @param impostor impostor to get position iterations from
  63683. * @returns positionIterations value
  63684. */
  63685. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  63686. /**
  63687. * Sets positionIterations of the impostor
  63688. * @param impostor impostor to set position on
  63689. * @param positionIterations positionIterations value
  63690. */
  63691. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  63692. /**
  63693. * Append an anchor to a cloth object
  63694. * @param impostor is the cloth impostor to add anchor to
  63695. * @param otherImpostor is the rigid impostor to anchor to
  63696. * @param width ratio across width from 0 to 1
  63697. * @param height ratio up height from 0 to 1
  63698. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  63699. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63700. */
  63701. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63702. /**
  63703. * Append an hook to a rope object
  63704. * @param impostor is the rope impostor to add hook to
  63705. * @param otherImpostor is the rigid impostor to hook to
  63706. * @param length ratio along the rope from 0 to 1
  63707. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  63708. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63709. */
  63710. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63711. /**
  63712. * Sleeps the physics body and stops it from being active
  63713. * @param impostor impostor to sleep
  63714. */
  63715. sleepBody(impostor: PhysicsImpostor): void;
  63716. /**
  63717. * Activates the physics body
  63718. * @param impostor impostor to activate
  63719. */
  63720. wakeUpBody(impostor: PhysicsImpostor): void;
  63721. /**
  63722. * Updates the distance parameters of the joint
  63723. * @param joint joint to update
  63724. * @param maxDistance maximum distance of the joint
  63725. * @param minDistance minimum distance of the joint
  63726. */
  63727. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63728. /**
  63729. * Sets a motor on the joint
  63730. * @param joint joint to set motor on
  63731. * @param speed speed of the motor
  63732. * @param maxForce maximum force of the motor
  63733. * @param motorIndex index of the motor
  63734. */
  63735. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63736. /**
  63737. * Sets the motors limit
  63738. * @param joint joint to set limit on
  63739. * @param upperLimit upper limit
  63740. * @param lowerLimit lower limit
  63741. */
  63742. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63743. /**
  63744. * Syncs the position and rotation of a mesh with the impostor
  63745. * @param mesh mesh to sync
  63746. * @param impostor impostor to update the mesh with
  63747. */
  63748. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63749. /**
  63750. * Gets the radius of the impostor
  63751. * @param impostor impostor to get radius from
  63752. * @returns the radius
  63753. */
  63754. getRadius(impostor: PhysicsImpostor): number;
  63755. /**
  63756. * Gets the box size of the impostor
  63757. * @param impostor impostor to get box size from
  63758. * @param result the resulting box size
  63759. */
  63760. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63761. /**
  63762. * Disposes of the impostor
  63763. */
  63764. dispose(): void;
  63765. /**
  63766. * Does a raycast in the physics world
  63767. * @param from when should the ray start?
  63768. * @param to when should the ray end?
  63769. * @returns PhysicsRaycastResult
  63770. */
  63771. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63772. }
  63773. }
  63774. declare module "babylonjs/Probes/reflectionProbe" {
  63775. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63776. import { Vector3 } from "babylonjs/Maths/math.vector";
  63777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63778. import { Nullable } from "babylonjs/types";
  63779. import { Scene } from "babylonjs/scene";
  63780. module "babylonjs/abstractScene" {
  63781. interface AbstractScene {
  63782. /**
  63783. * The list of reflection probes added to the scene
  63784. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63785. */
  63786. reflectionProbes: Array<ReflectionProbe>;
  63787. /**
  63788. * Removes the given reflection probe from this scene.
  63789. * @param toRemove The reflection probe to remove
  63790. * @returns The index of the removed reflection probe
  63791. */
  63792. removeReflectionProbe(toRemove: ReflectionProbe): number;
  63793. /**
  63794. * Adds the given reflection probe to this scene.
  63795. * @param newReflectionProbe The reflection probe to add
  63796. */
  63797. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  63798. }
  63799. }
  63800. /**
  63801. * Class used to generate realtime reflection / refraction cube textures
  63802. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63803. */
  63804. export class ReflectionProbe {
  63805. /** defines the name of the probe */
  63806. name: string;
  63807. private _scene;
  63808. private _renderTargetTexture;
  63809. private _projectionMatrix;
  63810. private _viewMatrix;
  63811. private _target;
  63812. private _add;
  63813. private _attachedMesh;
  63814. private _invertYAxis;
  63815. /** Gets or sets probe position (center of the cube map) */
  63816. position: Vector3;
  63817. /**
  63818. * Creates a new reflection probe
  63819. * @param name defines the name of the probe
  63820. * @param size defines the texture resolution (for each face)
  63821. * @param scene defines the hosting scene
  63822. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  63823. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  63824. */
  63825. constructor(
  63826. /** defines the name of the probe */
  63827. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  63828. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  63829. get samples(): number;
  63830. set samples(value: number);
  63831. /** Gets or sets the refresh rate to use (on every frame by default) */
  63832. get refreshRate(): number;
  63833. set refreshRate(value: number);
  63834. /**
  63835. * Gets the hosting scene
  63836. * @returns a Scene
  63837. */
  63838. getScene(): Scene;
  63839. /** Gets the internal CubeTexture used to render to */
  63840. get cubeTexture(): RenderTargetTexture;
  63841. /** Gets the list of meshes to render */
  63842. get renderList(): Nullable<AbstractMesh[]>;
  63843. /**
  63844. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  63845. * @param mesh defines the mesh to attach to
  63846. */
  63847. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  63848. /**
  63849. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  63850. * @param renderingGroupId The rendering group id corresponding to its index
  63851. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  63852. */
  63853. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  63854. /**
  63855. * Clean all associated resources
  63856. */
  63857. dispose(): void;
  63858. /**
  63859. * Converts the reflection probe information to a readable string for debug purpose.
  63860. * @param fullDetails Supports for multiple levels of logging within scene loading
  63861. * @returns the human readable reflection probe info
  63862. */
  63863. toString(fullDetails?: boolean): string;
  63864. /**
  63865. * Get the class name of the relfection probe.
  63866. * @returns "ReflectionProbe"
  63867. */
  63868. getClassName(): string;
  63869. /**
  63870. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  63871. * @returns The JSON representation of the texture
  63872. */
  63873. serialize(): any;
  63874. /**
  63875. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  63876. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  63877. * @param scene Define the scene the parsed reflection probe should be instantiated in
  63878. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  63879. * @returns The parsed reflection probe if successful
  63880. */
  63881. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  63882. }
  63883. }
  63884. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  63885. /** @hidden */
  63886. export var _BabylonLoaderRegistered: boolean;
  63887. /**
  63888. * Helps setting up some configuration for the babylon file loader.
  63889. */
  63890. export class BabylonFileLoaderConfiguration {
  63891. /**
  63892. * The loader does not allow injecting custom physix engine into the plugins.
  63893. * Unfortunately in ES6, we need to manually inject them into the plugin.
  63894. * So you could set this variable to your engine import to make it work.
  63895. */
  63896. static LoaderInjectedPhysicsEngine: any;
  63897. }
  63898. }
  63899. declare module "babylonjs/Loading/Plugins/index" {
  63900. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  63901. }
  63902. declare module "babylonjs/Loading/index" {
  63903. export * from "babylonjs/Loading/loadingScreen";
  63904. export * from "babylonjs/Loading/Plugins/index";
  63905. export * from "babylonjs/Loading/sceneLoader";
  63906. export * from "babylonjs/Loading/sceneLoaderFlags";
  63907. }
  63908. declare module "babylonjs/Materials/Background/index" {
  63909. export * from "babylonjs/Materials/Background/backgroundMaterial";
  63910. }
  63911. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  63912. import { Scene } from "babylonjs/scene";
  63913. import { Color3 } from "babylonjs/Maths/math.color";
  63914. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63915. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63916. /**
  63917. * The Physically based simple base material of BJS.
  63918. *
  63919. * This enables better naming and convention enforcements on top of the pbrMaterial.
  63920. * It is used as the base class for both the specGloss and metalRough conventions.
  63921. */
  63922. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  63923. /**
  63924. * Number of Simultaneous lights allowed on the material.
  63925. */
  63926. maxSimultaneousLights: number;
  63927. /**
  63928. * If sets to true, disables all the lights affecting the material.
  63929. */
  63930. disableLighting: boolean;
  63931. /**
  63932. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  63933. */
  63934. environmentTexture: BaseTexture;
  63935. /**
  63936. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  63937. */
  63938. invertNormalMapX: boolean;
  63939. /**
  63940. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  63941. */
  63942. invertNormalMapY: boolean;
  63943. /**
  63944. * Normal map used in the model.
  63945. */
  63946. normalTexture: BaseTexture;
  63947. /**
  63948. * Emissivie color used to self-illuminate the model.
  63949. */
  63950. emissiveColor: Color3;
  63951. /**
  63952. * Emissivie texture used to self-illuminate the model.
  63953. */
  63954. emissiveTexture: BaseTexture;
  63955. /**
  63956. * Occlusion Channel Strenght.
  63957. */
  63958. occlusionStrength: number;
  63959. /**
  63960. * Occlusion Texture of the material (adding extra occlusion effects).
  63961. */
  63962. occlusionTexture: BaseTexture;
  63963. /**
  63964. * Defines the alpha limits in alpha test mode.
  63965. */
  63966. alphaCutOff: number;
  63967. /**
  63968. * Gets the current double sided mode.
  63969. */
  63970. get doubleSided(): boolean;
  63971. /**
  63972. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63973. */
  63974. set doubleSided(value: boolean);
  63975. /**
  63976. * Stores the pre-calculated light information of a mesh in a texture.
  63977. */
  63978. lightmapTexture: BaseTexture;
  63979. /**
  63980. * If true, the light map contains occlusion information instead of lighting info.
  63981. */
  63982. useLightmapAsShadowmap: boolean;
  63983. /**
  63984. * Instantiates a new PBRMaterial instance.
  63985. *
  63986. * @param name The material name
  63987. * @param scene The scene the material will be use in.
  63988. */
  63989. constructor(name: string, scene: Scene);
  63990. getClassName(): string;
  63991. }
  63992. }
  63993. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  63994. import { Scene } from "babylonjs/scene";
  63995. import { Color3 } from "babylonjs/Maths/math.color";
  63996. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63997. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63998. /**
  63999. * The PBR material of BJS following the metal roughness convention.
  64000. *
  64001. * This fits to the PBR convention in the GLTF definition:
  64002. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64003. */
  64004. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64005. /**
  64006. * The base color has two different interpretations depending on the value of metalness.
  64007. * When the material is a metal, the base color is the specific measured reflectance value
  64008. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64009. * of the material.
  64010. */
  64011. baseColor: Color3;
  64012. /**
  64013. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64014. * well as opacity information in the alpha channel.
  64015. */
  64016. baseTexture: BaseTexture;
  64017. /**
  64018. * Specifies the metallic scalar value of the material.
  64019. * Can also be used to scale the metalness values of the metallic texture.
  64020. */
  64021. metallic: number;
  64022. /**
  64023. * Specifies the roughness scalar value of the material.
  64024. * Can also be used to scale the roughness values of the metallic texture.
  64025. */
  64026. roughness: number;
  64027. /**
  64028. * Texture containing both the metallic value in the B channel and the
  64029. * roughness value in the G channel to keep better precision.
  64030. */
  64031. metallicRoughnessTexture: BaseTexture;
  64032. /**
  64033. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64034. *
  64035. * @param name The material name
  64036. * @param scene The scene the material will be use in.
  64037. */
  64038. constructor(name: string, scene: Scene);
  64039. /**
  64040. * Return the currrent class name of the material.
  64041. */
  64042. getClassName(): string;
  64043. /**
  64044. * Makes a duplicate of the current material.
  64045. * @param name - name to use for the new material.
  64046. */
  64047. clone(name: string): PBRMetallicRoughnessMaterial;
  64048. /**
  64049. * Serialize the material to a parsable JSON object.
  64050. */
  64051. serialize(): any;
  64052. /**
  64053. * Parses a JSON object correponding to the serialize function.
  64054. */
  64055. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64056. }
  64057. }
  64058. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64059. import { Scene } from "babylonjs/scene";
  64060. import { Color3 } from "babylonjs/Maths/math.color";
  64061. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64062. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64063. /**
  64064. * The PBR material of BJS following the specular glossiness convention.
  64065. *
  64066. * This fits to the PBR convention in the GLTF definition:
  64067. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64068. */
  64069. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64070. /**
  64071. * Specifies the diffuse color of the material.
  64072. */
  64073. diffuseColor: Color3;
  64074. /**
  64075. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64076. * channel.
  64077. */
  64078. diffuseTexture: BaseTexture;
  64079. /**
  64080. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64081. */
  64082. specularColor: Color3;
  64083. /**
  64084. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64085. */
  64086. glossiness: number;
  64087. /**
  64088. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64089. */
  64090. specularGlossinessTexture: BaseTexture;
  64091. /**
  64092. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64093. *
  64094. * @param name The material name
  64095. * @param scene The scene the material will be use in.
  64096. */
  64097. constructor(name: string, scene: Scene);
  64098. /**
  64099. * Return the currrent class name of the material.
  64100. */
  64101. getClassName(): string;
  64102. /**
  64103. * Makes a duplicate of the current material.
  64104. * @param name - name to use for the new material.
  64105. */
  64106. clone(name: string): PBRSpecularGlossinessMaterial;
  64107. /**
  64108. * Serialize the material to a parsable JSON object.
  64109. */
  64110. serialize(): any;
  64111. /**
  64112. * Parses a JSON object correponding to the serialize function.
  64113. */
  64114. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64115. }
  64116. }
  64117. declare module "babylonjs/Materials/PBR/index" {
  64118. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64119. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64120. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64121. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64122. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64123. }
  64124. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64125. import { Nullable } from "babylonjs/types";
  64126. import { Scene } from "babylonjs/scene";
  64127. import { Matrix } from "babylonjs/Maths/math.vector";
  64128. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64129. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64130. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64131. /**
  64132. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64133. * It can help converting any input color in a desired output one. This can then be used to create effects
  64134. * from sepia, black and white to sixties or futuristic rendering...
  64135. *
  64136. * The only supported format is currently 3dl.
  64137. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64138. */
  64139. export class ColorGradingTexture extends BaseTexture {
  64140. /**
  64141. * The texture URL.
  64142. */
  64143. url: string;
  64144. /**
  64145. * Empty line regex stored for GC.
  64146. */
  64147. private static _noneEmptyLineRegex;
  64148. private _textureMatrix;
  64149. private _onLoad;
  64150. /**
  64151. * Instantiates a ColorGradingTexture from the following parameters.
  64152. *
  64153. * @param url The location of the color gradind data (currently only supporting 3dl)
  64154. * @param sceneOrEngine The scene or engine the texture will be used in
  64155. * @param onLoad defines a callback triggered when the texture has been loaded
  64156. */
  64157. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64158. /**
  64159. * Fires the onload event from the constructor if requested.
  64160. */
  64161. private _triggerOnLoad;
  64162. /**
  64163. * Returns the texture matrix used in most of the material.
  64164. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64165. */
  64166. getTextureMatrix(): Matrix;
  64167. /**
  64168. * Occurs when the file being loaded is a .3dl LUT file.
  64169. */
  64170. private load3dlTexture;
  64171. /**
  64172. * Starts the loading process of the texture.
  64173. */
  64174. private loadTexture;
  64175. /**
  64176. * Clones the color gradind texture.
  64177. */
  64178. clone(): ColorGradingTexture;
  64179. /**
  64180. * Called during delayed load for textures.
  64181. */
  64182. delayLoad(): void;
  64183. /**
  64184. * Parses a color grading texture serialized by Babylon.
  64185. * @param parsedTexture The texture information being parsedTexture
  64186. * @param scene The scene to load the texture in
  64187. * @param rootUrl The root url of the data assets to load
  64188. * @return A color gradind texture
  64189. */
  64190. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64191. /**
  64192. * Serializes the LUT texture to json format.
  64193. */
  64194. serialize(): any;
  64195. }
  64196. }
  64197. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64199. import { Scene } from "babylonjs/scene";
  64200. import { Nullable } from "babylonjs/types";
  64201. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64202. /**
  64203. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64204. */
  64205. export class EquiRectangularCubeTexture extends BaseTexture {
  64206. /** The six faces of the cube. */
  64207. private static _FacesMapping;
  64208. private _noMipmap;
  64209. private _onLoad;
  64210. private _onError;
  64211. /** The size of the cubemap. */
  64212. private _size;
  64213. /** The buffer of the image. */
  64214. private _buffer;
  64215. /** The width of the input image. */
  64216. private _width;
  64217. /** The height of the input image. */
  64218. private _height;
  64219. /** The URL to the image. */
  64220. url: string;
  64221. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  64222. coordinatesMode: number;
  64223. /**
  64224. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64225. * @param url The location of the image
  64226. * @param scene The scene the texture will be used in
  64227. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64228. * @param noMipmap Forces to not generate the mipmap if true
  64229. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64230. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64231. * @param onLoad — defines a callback called when texture is loaded
  64232. * @param onError — defines a callback called if there is an error
  64233. */
  64234. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64235. /**
  64236. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64237. */
  64238. private loadImage;
  64239. /**
  64240. * Convert the image buffer into a cubemap and create a CubeTexture.
  64241. */
  64242. private loadTexture;
  64243. /**
  64244. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64245. * @param buffer The ArrayBuffer that should be converted.
  64246. * @returns The buffer as Float32Array.
  64247. */
  64248. private getFloat32ArrayFromArrayBuffer;
  64249. /**
  64250. * Get the current class name of the texture useful for serialization or dynamic coding.
  64251. * @returns "EquiRectangularCubeTexture"
  64252. */
  64253. getClassName(): string;
  64254. /**
  64255. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64256. * @returns A clone of the current EquiRectangularCubeTexture.
  64257. */
  64258. clone(): EquiRectangularCubeTexture;
  64259. }
  64260. }
  64261. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64262. import { Nullable } from "babylonjs/types";
  64263. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64264. import { Matrix } from "babylonjs/Maths/math.vector";
  64265. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64266. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64267. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64268. import { Scene } from "babylonjs/scene";
  64269. /**
  64270. * Defines the options related to the creation of an HtmlElementTexture
  64271. */
  64272. export interface IHtmlElementTextureOptions {
  64273. /**
  64274. * Defines wether mip maps should be created or not.
  64275. */
  64276. generateMipMaps?: boolean;
  64277. /**
  64278. * Defines the sampling mode of the texture.
  64279. */
  64280. samplingMode?: number;
  64281. /**
  64282. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64283. */
  64284. engine: Nullable<ThinEngine>;
  64285. /**
  64286. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64287. */
  64288. scene: Nullable<Scene>;
  64289. }
  64290. /**
  64291. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64292. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64293. * is automatically managed.
  64294. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64295. * in your application.
  64296. *
  64297. * As the update is not automatic, you need to call them manually.
  64298. */
  64299. export class HtmlElementTexture extends BaseTexture {
  64300. /**
  64301. * The texture URL.
  64302. */
  64303. element: HTMLVideoElement | HTMLCanvasElement;
  64304. private static readonly DefaultOptions;
  64305. private _textureMatrix;
  64306. private _isVideo;
  64307. private _generateMipMaps;
  64308. private _samplingMode;
  64309. /**
  64310. * Instantiates a HtmlElementTexture from the following parameters.
  64311. *
  64312. * @param name Defines the name of the texture
  64313. * @param element Defines the video or canvas the texture is filled with
  64314. * @param options Defines the other none mandatory texture creation options
  64315. */
  64316. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64317. private _createInternalTexture;
  64318. /**
  64319. * Returns the texture matrix used in most of the material.
  64320. */
  64321. getTextureMatrix(): Matrix;
  64322. /**
  64323. * Updates the content of the texture.
  64324. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64325. */
  64326. update(invertY?: Nullable<boolean>): void;
  64327. }
  64328. }
  64329. declare module "babylonjs/Misc/tga" {
  64330. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64331. /**
  64332. * Based on jsTGALoader - Javascript loader for TGA file
  64333. * By Vincent Thibault
  64334. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64335. */
  64336. export class TGATools {
  64337. private static _TYPE_INDEXED;
  64338. private static _TYPE_RGB;
  64339. private static _TYPE_GREY;
  64340. private static _TYPE_RLE_INDEXED;
  64341. private static _TYPE_RLE_RGB;
  64342. private static _TYPE_RLE_GREY;
  64343. private static _ORIGIN_MASK;
  64344. private static _ORIGIN_SHIFT;
  64345. private static _ORIGIN_BL;
  64346. private static _ORIGIN_BR;
  64347. private static _ORIGIN_UL;
  64348. private static _ORIGIN_UR;
  64349. /**
  64350. * Gets the header of a TGA file
  64351. * @param data defines the TGA data
  64352. * @returns the header
  64353. */
  64354. static GetTGAHeader(data: Uint8Array): any;
  64355. /**
  64356. * Uploads TGA content to a Babylon Texture
  64357. * @hidden
  64358. */
  64359. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64360. /** @hidden */
  64361. 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;
  64362. /** @hidden */
  64363. 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;
  64364. /** @hidden */
  64365. 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;
  64366. /** @hidden */
  64367. 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;
  64368. /** @hidden */
  64369. 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;
  64370. /** @hidden */
  64371. 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;
  64372. }
  64373. }
  64374. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64375. import { Nullable } from "babylonjs/types";
  64376. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64377. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64378. /**
  64379. * Implementation of the TGA Texture Loader.
  64380. * @hidden
  64381. */
  64382. export class _TGATextureLoader implements IInternalTextureLoader {
  64383. /**
  64384. * Defines wether the loader supports cascade loading the different faces.
  64385. */
  64386. readonly supportCascades: boolean;
  64387. /**
  64388. * This returns if the loader support the current file information.
  64389. * @param extension defines the file extension of the file being loaded
  64390. * @returns true if the loader can load the specified file
  64391. */
  64392. canLoad(extension: string): boolean;
  64393. /**
  64394. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64395. * @param data contains the texture data
  64396. * @param texture defines the BabylonJS internal texture
  64397. * @param createPolynomials will be true if polynomials have been requested
  64398. * @param onLoad defines the callback to trigger once the texture is ready
  64399. * @param onError defines the callback to trigger in case of error
  64400. */
  64401. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64402. /**
  64403. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64404. * @param data contains the texture data
  64405. * @param texture defines the BabylonJS internal texture
  64406. * @param callback defines the method to call once ready to upload
  64407. */
  64408. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64409. }
  64410. }
  64411. declare module "babylonjs/Misc/basis" {
  64412. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64413. /**
  64414. * Info about the .basis files
  64415. */
  64416. class BasisFileInfo {
  64417. /**
  64418. * If the file has alpha
  64419. */
  64420. hasAlpha: boolean;
  64421. /**
  64422. * Info about each image of the basis file
  64423. */
  64424. images: Array<{
  64425. levels: Array<{
  64426. width: number;
  64427. height: number;
  64428. transcodedPixels: ArrayBufferView;
  64429. }>;
  64430. }>;
  64431. }
  64432. /**
  64433. * Result of transcoding a basis file
  64434. */
  64435. class TranscodeResult {
  64436. /**
  64437. * Info about the .basis file
  64438. */
  64439. fileInfo: BasisFileInfo;
  64440. /**
  64441. * Format to use when loading the file
  64442. */
  64443. format: number;
  64444. }
  64445. /**
  64446. * Configuration options for the Basis transcoder
  64447. */
  64448. export class BasisTranscodeConfiguration {
  64449. /**
  64450. * Supported compression formats used to determine the supported output format of the transcoder
  64451. */
  64452. supportedCompressionFormats?: {
  64453. /**
  64454. * etc1 compression format
  64455. */
  64456. etc1?: boolean;
  64457. /**
  64458. * s3tc compression format
  64459. */
  64460. s3tc?: boolean;
  64461. /**
  64462. * pvrtc compression format
  64463. */
  64464. pvrtc?: boolean;
  64465. /**
  64466. * etc2 compression format
  64467. */
  64468. etc2?: boolean;
  64469. };
  64470. /**
  64471. * If mipmap levels should be loaded for transcoded images (Default: true)
  64472. */
  64473. loadMipmapLevels?: boolean;
  64474. /**
  64475. * Index of a single image to load (Default: all images)
  64476. */
  64477. loadSingleImage?: number;
  64478. }
  64479. /**
  64480. * Used to load .Basis files
  64481. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64482. */
  64483. export class BasisTools {
  64484. private static _IgnoreSupportedFormats;
  64485. /**
  64486. * URL to use when loading the basis transcoder
  64487. */
  64488. static JSModuleURL: string;
  64489. /**
  64490. * URL to use when loading the wasm module for the transcoder
  64491. */
  64492. static WasmModuleURL: string;
  64493. /**
  64494. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64495. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64496. * @returns internal format corresponding to the Basis format
  64497. */
  64498. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64499. private static _WorkerPromise;
  64500. private static _Worker;
  64501. private static _actionId;
  64502. private static _CreateWorkerAsync;
  64503. /**
  64504. * Transcodes a loaded image file to compressed pixel data
  64505. * @param data image data to transcode
  64506. * @param config configuration options for the transcoding
  64507. * @returns a promise resulting in the transcoded image
  64508. */
  64509. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64510. /**
  64511. * Loads a texture from the transcode result
  64512. * @param texture texture load to
  64513. * @param transcodeResult the result of transcoding the basis file to load from
  64514. */
  64515. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64516. }
  64517. }
  64518. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64519. import { Nullable } from "babylonjs/types";
  64520. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64521. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64522. /**
  64523. * Loader for .basis file format
  64524. */
  64525. export class _BasisTextureLoader implements IInternalTextureLoader {
  64526. /**
  64527. * Defines whether the loader supports cascade loading the different faces.
  64528. */
  64529. readonly supportCascades: boolean;
  64530. /**
  64531. * This returns if the loader support the current file information.
  64532. * @param extension defines the file extension of the file being loaded
  64533. * @returns true if the loader can load the specified file
  64534. */
  64535. canLoad(extension: string): boolean;
  64536. /**
  64537. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64538. * @param data contains the texture data
  64539. * @param texture defines the BabylonJS internal texture
  64540. * @param createPolynomials will be true if polynomials have been requested
  64541. * @param onLoad defines the callback to trigger once the texture is ready
  64542. * @param onError defines the callback to trigger in case of error
  64543. */
  64544. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64545. /**
  64546. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64547. * @param data contains the texture data
  64548. * @param texture defines the BabylonJS internal texture
  64549. * @param callback defines the method to call once ready to upload
  64550. */
  64551. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64552. }
  64553. }
  64554. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64555. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64556. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64557. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64558. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64559. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64560. }
  64561. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64562. import { Vector2 } from "babylonjs/Maths/math.vector";
  64563. /**
  64564. * Defines the basic options interface of a TexturePacker Frame
  64565. */
  64566. export interface ITexturePackerFrame {
  64567. /**
  64568. * The frame ID
  64569. */
  64570. id: number;
  64571. /**
  64572. * The frames Scale
  64573. */
  64574. scale: Vector2;
  64575. /**
  64576. * The Frames offset
  64577. */
  64578. offset: Vector2;
  64579. }
  64580. /**
  64581. * This is a support class for frame Data on texture packer sets.
  64582. */
  64583. export class TexturePackerFrame implements ITexturePackerFrame {
  64584. /**
  64585. * The frame ID
  64586. */
  64587. id: number;
  64588. /**
  64589. * The frames Scale
  64590. */
  64591. scale: Vector2;
  64592. /**
  64593. * The Frames offset
  64594. */
  64595. offset: Vector2;
  64596. /**
  64597. * Initializes a texture package frame.
  64598. * @param id The numerical frame identifier
  64599. * @param scale Scalar Vector2 for UV frame
  64600. * @param offset Vector2 for the frame position in UV units.
  64601. * @returns TexturePackerFrame
  64602. */
  64603. constructor(id: number, scale: Vector2, offset: Vector2);
  64604. }
  64605. }
  64606. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64608. import { Scene } from "babylonjs/scene";
  64609. import { Nullable } from "babylonjs/types";
  64610. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64611. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64612. /**
  64613. * Defines the basic options interface of a TexturePacker
  64614. */
  64615. export interface ITexturePackerOptions {
  64616. /**
  64617. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64618. */
  64619. map?: string[];
  64620. /**
  64621. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64622. */
  64623. uvsIn?: string;
  64624. /**
  64625. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64626. */
  64627. uvsOut?: string;
  64628. /**
  64629. * number representing the layout style. Defaults to LAYOUT_STRIP
  64630. */
  64631. layout?: number;
  64632. /**
  64633. * number of columns if using custom column count layout(2). This defaults to 4.
  64634. */
  64635. colnum?: number;
  64636. /**
  64637. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64638. */
  64639. updateInputMeshes?: boolean;
  64640. /**
  64641. * boolean flag to dispose all the source textures. Defaults to true.
  64642. */
  64643. disposeSources?: boolean;
  64644. /**
  64645. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64646. */
  64647. fillBlanks?: boolean;
  64648. /**
  64649. * string value representing the context fill style color. Defaults to 'black'.
  64650. */
  64651. customFillColor?: string;
  64652. /**
  64653. * Width and Height Value of each Frame in the TexturePacker Sets
  64654. */
  64655. frameSize?: number;
  64656. /**
  64657. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  64658. */
  64659. paddingRatio?: number;
  64660. /**
  64661. * Number that declares the fill method for the padding gutter.
  64662. */
  64663. paddingMode?: number;
  64664. /**
  64665. * If in SUBUV_COLOR padding mode what color to use.
  64666. */
  64667. paddingColor?: Color3 | Color4;
  64668. }
  64669. /**
  64670. * Defines the basic interface of a TexturePacker JSON File
  64671. */
  64672. export interface ITexturePackerJSON {
  64673. /**
  64674. * The frame ID
  64675. */
  64676. name: string;
  64677. /**
  64678. * The base64 channel data
  64679. */
  64680. sets: any;
  64681. /**
  64682. * The options of the Packer
  64683. */
  64684. options: ITexturePackerOptions;
  64685. /**
  64686. * The frame data of the Packer
  64687. */
  64688. frames: Array<number>;
  64689. }
  64690. /**
  64691. * This is a support class that generates a series of packed texture sets.
  64692. * @see https://doc.babylonjs.com/babylon101/materials
  64693. */
  64694. export class TexturePacker {
  64695. /** Packer Layout Constant 0 */
  64696. static readonly LAYOUT_STRIP: number;
  64697. /** Packer Layout Constant 1 */
  64698. static readonly LAYOUT_POWER2: number;
  64699. /** Packer Layout Constant 2 */
  64700. static readonly LAYOUT_COLNUM: number;
  64701. /** Packer Layout Constant 0 */
  64702. static readonly SUBUV_WRAP: number;
  64703. /** Packer Layout Constant 1 */
  64704. static readonly SUBUV_EXTEND: number;
  64705. /** Packer Layout Constant 2 */
  64706. static readonly SUBUV_COLOR: number;
  64707. /** The Name of the Texture Package */
  64708. name: string;
  64709. /** The scene scope of the TexturePacker */
  64710. scene: Scene;
  64711. /** The Meshes to target */
  64712. meshes: AbstractMesh[];
  64713. /** Arguments passed with the Constructor */
  64714. options: ITexturePackerOptions;
  64715. /** The promise that is started upon initialization */
  64716. promise: Nullable<Promise<TexturePacker | string>>;
  64717. /** The Container object for the channel sets that are generated */
  64718. sets: object;
  64719. /** The Container array for the frames that are generated */
  64720. frames: TexturePackerFrame[];
  64721. /** The expected number of textures the system is parsing. */
  64722. private _expecting;
  64723. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  64724. private _paddingValue;
  64725. /**
  64726. * Initializes a texture package series from an array of meshes or a single mesh.
  64727. * @param name The name of the package
  64728. * @param meshes The target meshes to compose the package from
  64729. * @param options The arguments that texture packer should follow while building.
  64730. * @param scene The scene which the textures are scoped to.
  64731. * @returns TexturePacker
  64732. */
  64733. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  64734. /**
  64735. * Starts the package process
  64736. * @param resolve The promises resolution function
  64737. * @returns TexturePacker
  64738. */
  64739. private _createFrames;
  64740. /**
  64741. * Calculates the Size of the Channel Sets
  64742. * @returns Vector2
  64743. */
  64744. private _calculateSize;
  64745. /**
  64746. * Calculates the UV data for the frames.
  64747. * @param baseSize the base frameSize
  64748. * @param padding the base frame padding
  64749. * @param dtSize size of the Dynamic Texture for that channel
  64750. * @param dtUnits is 1/dtSize
  64751. * @param update flag to update the input meshes
  64752. */
  64753. private _calculateMeshUVFrames;
  64754. /**
  64755. * Calculates the frames Offset.
  64756. * @param index of the frame
  64757. * @returns Vector2
  64758. */
  64759. private _getFrameOffset;
  64760. /**
  64761. * Updates a Mesh to the frame data
  64762. * @param mesh that is the target
  64763. * @param frameID or the frame index
  64764. */
  64765. private _updateMeshUV;
  64766. /**
  64767. * Updates a Meshes materials to use the texture packer channels
  64768. * @param m is the mesh to target
  64769. * @param force all channels on the packer to be set.
  64770. */
  64771. private _updateTextureReferences;
  64772. /**
  64773. * Public method to set a Mesh to a frame
  64774. * @param m that is the target
  64775. * @param frameID or the frame index
  64776. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  64777. */
  64778. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  64779. /**
  64780. * Starts the async promise to compile the texture packer.
  64781. * @returns Promise<void>
  64782. */
  64783. processAsync(): Promise<void>;
  64784. /**
  64785. * Disposes all textures associated with this packer
  64786. */
  64787. dispose(): void;
  64788. /**
  64789. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  64790. * @param imageType is the image type to use.
  64791. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  64792. */
  64793. download(imageType?: string, quality?: number): void;
  64794. /**
  64795. * Public method to load a texturePacker JSON file.
  64796. * @param data of the JSON file in string format.
  64797. */
  64798. updateFromJSON(data: string): void;
  64799. }
  64800. }
  64801. declare module "babylonjs/Materials/Textures/Packer/index" {
  64802. export * from "babylonjs/Materials/Textures/Packer/packer";
  64803. export * from "babylonjs/Materials/Textures/Packer/frame";
  64804. }
  64805. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  64806. import { Scene } from "babylonjs/scene";
  64807. import { Texture } from "babylonjs/Materials/Textures/texture";
  64808. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64809. /**
  64810. * 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.
  64811. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64812. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64813. */
  64814. export class CustomProceduralTexture extends ProceduralTexture {
  64815. private _animate;
  64816. private _time;
  64817. private _config;
  64818. private _texturePath;
  64819. /**
  64820. * Instantiates a new Custom Procedural Texture.
  64821. * 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.
  64822. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64823. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64824. * @param name Define the name of the texture
  64825. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  64826. * @param size Define the size of the texture to create
  64827. * @param scene Define the scene the texture belongs to
  64828. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  64829. * @param generateMipMaps Define if the texture should creates mip maps or not
  64830. */
  64831. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64832. private _loadJson;
  64833. /**
  64834. * Is the texture ready to be used ? (rendered at least once)
  64835. * @returns true if ready, otherwise, false.
  64836. */
  64837. isReady(): boolean;
  64838. /**
  64839. * Render the texture to its associated render target.
  64840. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  64841. */
  64842. render(useCameraPostProcess?: boolean): void;
  64843. /**
  64844. * Update the list of dependant textures samplers in the shader.
  64845. */
  64846. updateTextures(): void;
  64847. /**
  64848. * Update the uniform values of the procedural texture in the shader.
  64849. */
  64850. updateShaderUniforms(): void;
  64851. /**
  64852. * Define if the texture animates or not.
  64853. */
  64854. get animate(): boolean;
  64855. set animate(value: boolean);
  64856. }
  64857. }
  64858. declare module "babylonjs/Shaders/noise.fragment" {
  64859. /** @hidden */
  64860. export var noisePixelShader: {
  64861. name: string;
  64862. shader: string;
  64863. };
  64864. }
  64865. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  64866. import { Nullable } from "babylonjs/types";
  64867. import { Scene } from "babylonjs/scene";
  64868. import { Texture } from "babylonjs/Materials/Textures/texture";
  64869. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64870. import "babylonjs/Shaders/noise.fragment";
  64871. /**
  64872. * Class used to generate noise procedural textures
  64873. */
  64874. export class NoiseProceduralTexture extends ProceduralTexture {
  64875. private _time;
  64876. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  64877. brightness: number;
  64878. /** Defines the number of octaves to process */
  64879. octaves: number;
  64880. /** Defines the level of persistence (0.8 by default) */
  64881. persistence: number;
  64882. /** Gets or sets animation speed factor (default is 1) */
  64883. animationSpeedFactor: number;
  64884. /**
  64885. * Creates a new NoiseProceduralTexture
  64886. * @param name defines the name fo the texture
  64887. * @param size defines the size of the texture (default is 256)
  64888. * @param scene defines the hosting scene
  64889. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  64890. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  64891. */
  64892. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64893. private _updateShaderUniforms;
  64894. protected _getDefines(): string;
  64895. /** Generate the current state of the procedural texture */
  64896. render(useCameraPostProcess?: boolean): void;
  64897. /**
  64898. * Serializes this noise procedural texture
  64899. * @returns a serialized noise procedural texture object
  64900. */
  64901. serialize(): any;
  64902. /**
  64903. * Clone the texture.
  64904. * @returns the cloned texture
  64905. */
  64906. clone(): NoiseProceduralTexture;
  64907. /**
  64908. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  64909. * @param parsedTexture defines parsed texture data
  64910. * @param scene defines the current scene
  64911. * @param rootUrl defines the root URL containing noise procedural texture information
  64912. * @returns a parsed NoiseProceduralTexture
  64913. */
  64914. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  64915. }
  64916. }
  64917. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  64918. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  64919. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  64920. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64921. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  64922. }
  64923. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  64924. import { Nullable } from "babylonjs/types";
  64925. import { Scene } from "babylonjs/scene";
  64926. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  64927. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64928. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64929. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64930. /**
  64931. * Raw cube texture where the raw buffers are passed in
  64932. */
  64933. export class RawCubeTexture extends CubeTexture {
  64934. /**
  64935. * Creates a cube texture where the raw buffers are passed in.
  64936. * @param scene defines the scene the texture is attached to
  64937. * @param data defines the array of data to use to create each face
  64938. * @param size defines the size of the textures
  64939. * @param format defines the format of the data
  64940. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  64941. * @param generateMipMaps defines if the engine should generate the mip levels
  64942. * @param invertY defines if data must be stored with Y axis inverted
  64943. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  64944. * @param compression defines the compression used (null by default)
  64945. */
  64946. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  64947. /**
  64948. * Updates the raw cube texture.
  64949. * @param data defines the data to store
  64950. * @param format defines the data format
  64951. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64952. * @param invertY defines if data must be stored with Y axis inverted
  64953. * @param compression defines the compression used (null by default)
  64954. * @param level defines which level of the texture to update
  64955. */
  64956. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  64957. /**
  64958. * Updates a raw cube texture with RGBD encoded data.
  64959. * @param data defines the array of data [mipmap][face] to use to create each face
  64960. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  64961. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64962. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64963. * @returns a promsie that resolves when the operation is complete
  64964. */
  64965. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  64966. /**
  64967. * Clones the raw cube texture.
  64968. * @return a new cube texture
  64969. */
  64970. clone(): CubeTexture;
  64971. /** @hidden */
  64972. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  64973. }
  64974. }
  64975. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  64976. import { Scene } from "babylonjs/scene";
  64977. import { Texture } from "babylonjs/Materials/Textures/texture";
  64978. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64979. /**
  64980. * Class used to store 2D array textures containing user data
  64981. */
  64982. export class RawTexture2DArray extends Texture {
  64983. /** Gets or sets the texture format to use */
  64984. format: number;
  64985. /**
  64986. * Create a new RawTexture2DArray
  64987. * @param data defines the data of the texture
  64988. * @param width defines the width of the texture
  64989. * @param height defines the height of the texture
  64990. * @param depth defines the number of layers of the texture
  64991. * @param format defines the texture format to use
  64992. * @param scene defines the hosting scene
  64993. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64994. * @param invertY defines if texture must be stored with Y axis inverted
  64995. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64996. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64997. */
  64998. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64999. /** Gets or sets the texture format to use */
  65000. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65001. /**
  65002. * Update the texture with new data
  65003. * @param data defines the data to store in the texture
  65004. */
  65005. update(data: ArrayBufferView): void;
  65006. }
  65007. }
  65008. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65009. import { Scene } from "babylonjs/scene";
  65010. import { Texture } from "babylonjs/Materials/Textures/texture";
  65011. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65012. /**
  65013. * Class used to store 3D textures containing user data
  65014. */
  65015. export class RawTexture3D extends Texture {
  65016. /** Gets or sets the texture format to use */
  65017. format: number;
  65018. /**
  65019. * Create a new RawTexture3D
  65020. * @param data defines the data of the texture
  65021. * @param width defines the width of the texture
  65022. * @param height defines the height of the texture
  65023. * @param depth defines the depth of the texture
  65024. * @param format defines the texture format to use
  65025. * @param scene defines the hosting scene
  65026. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65027. * @param invertY defines if texture must be stored with Y axis inverted
  65028. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65029. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65030. */
  65031. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65032. /** Gets or sets the texture format to use */
  65033. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65034. /**
  65035. * Update the texture with new data
  65036. * @param data defines the data to store in the texture
  65037. */
  65038. update(data: ArrayBufferView): void;
  65039. }
  65040. }
  65041. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65042. import { Scene } from "babylonjs/scene";
  65043. import { Plane } from "babylonjs/Maths/math.plane";
  65044. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65045. /**
  65046. * Creates a refraction texture used by refraction channel of the standard material.
  65047. * It is like a mirror but to see through a material.
  65048. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65049. */
  65050. export class RefractionTexture extends RenderTargetTexture {
  65051. /**
  65052. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65053. * 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.
  65054. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65055. */
  65056. refractionPlane: Plane;
  65057. /**
  65058. * Define how deep under the surface we should see.
  65059. */
  65060. depth: number;
  65061. /**
  65062. * Creates a refraction texture used by refraction channel of the standard material.
  65063. * It is like a mirror but to see through a material.
  65064. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65065. * @param name Define the texture name
  65066. * @param size Define the size of the underlying texture
  65067. * @param scene Define the scene the refraction belongs to
  65068. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65069. */
  65070. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65071. /**
  65072. * Clone the refraction texture.
  65073. * @returns the cloned texture
  65074. */
  65075. clone(): RefractionTexture;
  65076. /**
  65077. * Serialize the texture to a JSON representation you could use in Parse later on
  65078. * @returns the serialized JSON representation
  65079. */
  65080. serialize(): any;
  65081. }
  65082. }
  65083. declare module "babylonjs/Materials/Textures/index" {
  65084. export * from "babylonjs/Materials/Textures/baseTexture";
  65085. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65086. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65087. export * from "babylonjs/Materials/Textures/cubeTexture";
  65088. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65089. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65090. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65091. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65092. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65093. export * from "babylonjs/Materials/Textures/internalTexture";
  65094. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65095. export * from "babylonjs/Materials/Textures/Loaders/index";
  65096. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65097. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65098. export * from "babylonjs/Materials/Textures/Packer/index";
  65099. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65100. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65101. export * from "babylonjs/Materials/Textures/rawTexture";
  65102. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65103. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65104. export * from "babylonjs/Materials/Textures/refractionTexture";
  65105. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65106. export * from "babylonjs/Materials/Textures/texture";
  65107. export * from "babylonjs/Materials/Textures/videoTexture";
  65108. }
  65109. declare module "babylonjs/Materials/Node/Enums/index" {
  65110. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65111. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65112. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65113. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65114. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65115. }
  65116. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65117. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65118. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65120. import { Mesh } from "babylonjs/Meshes/mesh";
  65121. import { Effect } from "babylonjs/Materials/effect";
  65122. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65123. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65124. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65125. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65126. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65127. /**
  65128. * Block used to add support for vertex skinning (bones)
  65129. */
  65130. export class BonesBlock extends NodeMaterialBlock {
  65131. /**
  65132. * Creates a new BonesBlock
  65133. * @param name defines the block name
  65134. */
  65135. constructor(name: string);
  65136. /**
  65137. * Initialize the block and prepare the context for build
  65138. * @param state defines the state that will be used for the build
  65139. */
  65140. initialize(state: NodeMaterialBuildState): void;
  65141. /**
  65142. * Gets the current class name
  65143. * @returns the class name
  65144. */
  65145. getClassName(): string;
  65146. /**
  65147. * Gets the matrix indices input component
  65148. */
  65149. get matricesIndices(): NodeMaterialConnectionPoint;
  65150. /**
  65151. * Gets the matrix weights input component
  65152. */
  65153. get matricesWeights(): NodeMaterialConnectionPoint;
  65154. /**
  65155. * Gets the extra matrix indices input component
  65156. */
  65157. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65158. /**
  65159. * Gets the extra matrix weights input component
  65160. */
  65161. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65162. /**
  65163. * Gets the world input component
  65164. */
  65165. get world(): NodeMaterialConnectionPoint;
  65166. /**
  65167. * Gets the output component
  65168. */
  65169. get output(): NodeMaterialConnectionPoint;
  65170. autoConfigure(material: NodeMaterial): void;
  65171. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65172. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65173. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65174. protected _buildBlock(state: NodeMaterialBuildState): this;
  65175. }
  65176. }
  65177. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65179. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65180. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65182. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65183. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65184. /**
  65185. * Block used to add support for instances
  65186. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65187. */
  65188. export class InstancesBlock extends NodeMaterialBlock {
  65189. /**
  65190. * Creates a new InstancesBlock
  65191. * @param name defines the block name
  65192. */
  65193. constructor(name: string);
  65194. /**
  65195. * Gets the current class name
  65196. * @returns the class name
  65197. */
  65198. getClassName(): string;
  65199. /**
  65200. * Gets the first world row input component
  65201. */
  65202. get world0(): NodeMaterialConnectionPoint;
  65203. /**
  65204. * Gets the second world row input component
  65205. */
  65206. get world1(): NodeMaterialConnectionPoint;
  65207. /**
  65208. * Gets the third world row input component
  65209. */
  65210. get world2(): NodeMaterialConnectionPoint;
  65211. /**
  65212. * Gets the forth world row input component
  65213. */
  65214. get world3(): NodeMaterialConnectionPoint;
  65215. /**
  65216. * Gets the world input component
  65217. */
  65218. get world(): NodeMaterialConnectionPoint;
  65219. /**
  65220. * Gets the output component
  65221. */
  65222. get output(): NodeMaterialConnectionPoint;
  65223. /**
  65224. * Gets the isntanceID component
  65225. */
  65226. get instanceID(): NodeMaterialConnectionPoint;
  65227. autoConfigure(material: NodeMaterial): void;
  65228. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65229. protected _buildBlock(state: NodeMaterialBuildState): this;
  65230. }
  65231. }
  65232. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65233. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65234. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65235. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65237. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65238. import { Effect } from "babylonjs/Materials/effect";
  65239. import { Mesh } from "babylonjs/Meshes/mesh";
  65240. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65241. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65242. /**
  65243. * Block used to add morph targets support to vertex shader
  65244. */
  65245. export class MorphTargetsBlock extends NodeMaterialBlock {
  65246. private _repeatableContentAnchor;
  65247. /**
  65248. * Create a new MorphTargetsBlock
  65249. * @param name defines the block name
  65250. */
  65251. constructor(name: string);
  65252. /**
  65253. * Gets the current class name
  65254. * @returns the class name
  65255. */
  65256. getClassName(): string;
  65257. /**
  65258. * Gets the position input component
  65259. */
  65260. get position(): NodeMaterialConnectionPoint;
  65261. /**
  65262. * Gets the normal input component
  65263. */
  65264. get normal(): NodeMaterialConnectionPoint;
  65265. /**
  65266. * Gets the tangent input component
  65267. */
  65268. get tangent(): NodeMaterialConnectionPoint;
  65269. /**
  65270. * Gets the tangent input component
  65271. */
  65272. get uv(): NodeMaterialConnectionPoint;
  65273. /**
  65274. * Gets the position output component
  65275. */
  65276. get positionOutput(): NodeMaterialConnectionPoint;
  65277. /**
  65278. * Gets the normal output component
  65279. */
  65280. get normalOutput(): NodeMaterialConnectionPoint;
  65281. /**
  65282. * Gets the tangent output component
  65283. */
  65284. get tangentOutput(): NodeMaterialConnectionPoint;
  65285. /**
  65286. * Gets the tangent output component
  65287. */
  65288. get uvOutput(): NodeMaterialConnectionPoint;
  65289. initialize(state: NodeMaterialBuildState): void;
  65290. autoConfigure(material: NodeMaterial): void;
  65291. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65292. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65293. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65294. protected _buildBlock(state: NodeMaterialBuildState): this;
  65295. }
  65296. }
  65297. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65298. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65299. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65300. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65301. import { Nullable } from "babylonjs/types";
  65302. import { Scene } from "babylonjs/scene";
  65303. import { Effect } from "babylonjs/Materials/effect";
  65304. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65305. import { Mesh } from "babylonjs/Meshes/mesh";
  65306. import { Light } from "babylonjs/Lights/light";
  65307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65308. /**
  65309. * Block used to get data information from a light
  65310. */
  65311. export class LightInformationBlock extends NodeMaterialBlock {
  65312. private _lightDataUniformName;
  65313. private _lightColorUniformName;
  65314. private _lightTypeDefineName;
  65315. /**
  65316. * Gets or sets the light associated with this block
  65317. */
  65318. light: Nullable<Light>;
  65319. /**
  65320. * Creates a new LightInformationBlock
  65321. * @param name defines the block name
  65322. */
  65323. constructor(name: string);
  65324. /**
  65325. * Gets the current class name
  65326. * @returns the class name
  65327. */
  65328. getClassName(): string;
  65329. /**
  65330. * Gets the world position input component
  65331. */
  65332. get worldPosition(): NodeMaterialConnectionPoint;
  65333. /**
  65334. * Gets the direction output component
  65335. */
  65336. get direction(): NodeMaterialConnectionPoint;
  65337. /**
  65338. * Gets the direction output component
  65339. */
  65340. get color(): NodeMaterialConnectionPoint;
  65341. /**
  65342. * Gets the direction output component
  65343. */
  65344. get intensity(): NodeMaterialConnectionPoint;
  65345. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65346. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65347. protected _buildBlock(state: NodeMaterialBuildState): this;
  65348. serialize(): any;
  65349. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65350. }
  65351. }
  65352. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65353. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65354. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65355. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65356. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65357. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65358. }
  65359. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65360. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65361. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65362. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65364. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65365. import { Effect } from "babylonjs/Materials/effect";
  65366. import { Mesh } from "babylonjs/Meshes/mesh";
  65367. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65368. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65369. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65370. /**
  65371. * Block used to add image processing support to fragment shader
  65372. */
  65373. export class ImageProcessingBlock extends NodeMaterialBlock {
  65374. /**
  65375. * Create a new ImageProcessingBlock
  65376. * @param name defines the block name
  65377. */
  65378. constructor(name: string);
  65379. /**
  65380. * Gets the current class name
  65381. * @returns the class name
  65382. */
  65383. getClassName(): string;
  65384. /**
  65385. * Gets the color input component
  65386. */
  65387. get color(): NodeMaterialConnectionPoint;
  65388. /**
  65389. * Gets the output component
  65390. */
  65391. get output(): NodeMaterialConnectionPoint;
  65392. /**
  65393. * Initialize the block and prepare the context for build
  65394. * @param state defines the state that will be used for the build
  65395. */
  65396. initialize(state: NodeMaterialBuildState): void;
  65397. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65398. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65399. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65400. protected _buildBlock(state: NodeMaterialBuildState): this;
  65401. }
  65402. }
  65403. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65404. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65405. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65406. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65407. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65409. import { Effect } from "babylonjs/Materials/effect";
  65410. import { Mesh } from "babylonjs/Meshes/mesh";
  65411. import { Scene } from "babylonjs/scene";
  65412. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65413. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65414. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65415. /**
  65416. * Block used to pertub normals based on a normal map
  65417. */
  65418. export class PerturbNormalBlock extends NodeMaterialBlock {
  65419. private _tangentSpaceParameterName;
  65420. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65421. invertX: boolean;
  65422. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65423. invertY: boolean;
  65424. /**
  65425. * Create a new PerturbNormalBlock
  65426. * @param name defines the block name
  65427. */
  65428. constructor(name: string);
  65429. /**
  65430. * Gets the current class name
  65431. * @returns the class name
  65432. */
  65433. getClassName(): string;
  65434. /**
  65435. * Gets the world position input component
  65436. */
  65437. get worldPosition(): NodeMaterialConnectionPoint;
  65438. /**
  65439. * Gets the world normal input component
  65440. */
  65441. get worldNormal(): NodeMaterialConnectionPoint;
  65442. /**
  65443. * Gets the world tangent input component
  65444. */
  65445. get worldTangent(): NodeMaterialConnectionPoint;
  65446. /**
  65447. * Gets the uv input component
  65448. */
  65449. get uv(): NodeMaterialConnectionPoint;
  65450. /**
  65451. * Gets the normal map color input component
  65452. */
  65453. get normalMapColor(): NodeMaterialConnectionPoint;
  65454. /**
  65455. * Gets the strength input component
  65456. */
  65457. get strength(): NodeMaterialConnectionPoint;
  65458. /**
  65459. * Gets the output component
  65460. */
  65461. get output(): NodeMaterialConnectionPoint;
  65462. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65463. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65464. autoConfigure(material: NodeMaterial): void;
  65465. protected _buildBlock(state: NodeMaterialBuildState): this;
  65466. protected _dumpPropertiesCode(): string;
  65467. serialize(): any;
  65468. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65469. }
  65470. }
  65471. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65472. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65473. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65474. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65475. /**
  65476. * Block used to discard a pixel if a value is smaller than a cutoff
  65477. */
  65478. export class DiscardBlock extends NodeMaterialBlock {
  65479. /**
  65480. * Create a new DiscardBlock
  65481. * @param name defines the block name
  65482. */
  65483. constructor(name: string);
  65484. /**
  65485. * Gets the current class name
  65486. * @returns the class name
  65487. */
  65488. getClassName(): string;
  65489. /**
  65490. * Gets the color input component
  65491. */
  65492. get value(): NodeMaterialConnectionPoint;
  65493. /**
  65494. * Gets the cutoff input component
  65495. */
  65496. get cutoff(): NodeMaterialConnectionPoint;
  65497. protected _buildBlock(state: NodeMaterialBuildState): this;
  65498. }
  65499. }
  65500. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65501. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65502. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65503. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65504. /**
  65505. * Block used to test if the fragment shader is front facing
  65506. */
  65507. export class FrontFacingBlock extends NodeMaterialBlock {
  65508. /**
  65509. * Creates a new FrontFacingBlock
  65510. * @param name defines the block name
  65511. */
  65512. constructor(name: string);
  65513. /**
  65514. * Gets the current class name
  65515. * @returns the class name
  65516. */
  65517. getClassName(): string;
  65518. /**
  65519. * Gets the output component
  65520. */
  65521. get output(): NodeMaterialConnectionPoint;
  65522. protected _buildBlock(state: NodeMaterialBuildState): this;
  65523. }
  65524. }
  65525. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65526. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65527. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65528. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65529. /**
  65530. * Block used to get the derivative value on x and y of a given input
  65531. */
  65532. export class DerivativeBlock extends NodeMaterialBlock {
  65533. /**
  65534. * Create a new DerivativeBlock
  65535. * @param name defines the block name
  65536. */
  65537. constructor(name: string);
  65538. /**
  65539. * Gets the current class name
  65540. * @returns the class name
  65541. */
  65542. getClassName(): string;
  65543. /**
  65544. * Gets the input component
  65545. */
  65546. get input(): NodeMaterialConnectionPoint;
  65547. /**
  65548. * Gets the derivative output on x
  65549. */
  65550. get dx(): NodeMaterialConnectionPoint;
  65551. /**
  65552. * Gets the derivative output on y
  65553. */
  65554. get dy(): NodeMaterialConnectionPoint;
  65555. protected _buildBlock(state: NodeMaterialBuildState): this;
  65556. }
  65557. }
  65558. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65559. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65560. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65561. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65562. /**
  65563. * Block used to make gl_FragCoord available
  65564. */
  65565. export class FragCoordBlock extends NodeMaterialBlock {
  65566. /**
  65567. * Creates a new FragCoordBlock
  65568. * @param name defines the block name
  65569. */
  65570. constructor(name: string);
  65571. /**
  65572. * Gets the current class name
  65573. * @returns the class name
  65574. */
  65575. getClassName(): string;
  65576. /**
  65577. * Gets the xy component
  65578. */
  65579. get xy(): NodeMaterialConnectionPoint;
  65580. /**
  65581. * Gets the xyz component
  65582. */
  65583. get xyz(): NodeMaterialConnectionPoint;
  65584. /**
  65585. * Gets the xyzw component
  65586. */
  65587. get xyzw(): NodeMaterialConnectionPoint;
  65588. /**
  65589. * Gets the x component
  65590. */
  65591. get x(): NodeMaterialConnectionPoint;
  65592. /**
  65593. * Gets the y component
  65594. */
  65595. get y(): NodeMaterialConnectionPoint;
  65596. /**
  65597. * Gets the z component
  65598. */
  65599. get z(): NodeMaterialConnectionPoint;
  65600. /**
  65601. * Gets the w component
  65602. */
  65603. get output(): NodeMaterialConnectionPoint;
  65604. protected writeOutputs(state: NodeMaterialBuildState): string;
  65605. protected _buildBlock(state: NodeMaterialBuildState): this;
  65606. }
  65607. }
  65608. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65609. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65610. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65611. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65612. import { Effect } from "babylonjs/Materials/effect";
  65613. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65614. import { Mesh } from "babylonjs/Meshes/mesh";
  65615. /**
  65616. * Block used to get the screen sizes
  65617. */
  65618. export class ScreenSizeBlock extends NodeMaterialBlock {
  65619. private _varName;
  65620. private _scene;
  65621. /**
  65622. * Creates a new ScreenSizeBlock
  65623. * @param name defines the block name
  65624. */
  65625. constructor(name: string);
  65626. /**
  65627. * Gets the current class name
  65628. * @returns the class name
  65629. */
  65630. getClassName(): string;
  65631. /**
  65632. * Gets the xy component
  65633. */
  65634. get xy(): NodeMaterialConnectionPoint;
  65635. /**
  65636. * Gets the x component
  65637. */
  65638. get x(): NodeMaterialConnectionPoint;
  65639. /**
  65640. * Gets the y component
  65641. */
  65642. get y(): NodeMaterialConnectionPoint;
  65643. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65644. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65645. protected _buildBlock(state: NodeMaterialBuildState): this;
  65646. }
  65647. }
  65648. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  65649. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  65650. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  65651. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  65652. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  65653. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  65654. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  65655. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  65656. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  65657. }
  65658. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  65659. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65660. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65661. import { Mesh } from "babylonjs/Meshes/mesh";
  65662. import { Effect } from "babylonjs/Materials/effect";
  65663. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65665. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65666. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  65667. /**
  65668. * Block used to add support for scene fog
  65669. */
  65670. export class FogBlock extends NodeMaterialBlock {
  65671. private _fogDistanceName;
  65672. private _fogParameters;
  65673. /**
  65674. * Create a new FogBlock
  65675. * @param name defines the block name
  65676. */
  65677. constructor(name: string);
  65678. /**
  65679. * Gets the current class name
  65680. * @returns the class name
  65681. */
  65682. getClassName(): string;
  65683. /**
  65684. * Gets the world position input component
  65685. */
  65686. get worldPosition(): NodeMaterialConnectionPoint;
  65687. /**
  65688. * Gets the view input component
  65689. */
  65690. get view(): NodeMaterialConnectionPoint;
  65691. /**
  65692. * Gets the color input component
  65693. */
  65694. get input(): NodeMaterialConnectionPoint;
  65695. /**
  65696. * Gets the fog color input component
  65697. */
  65698. get fogColor(): NodeMaterialConnectionPoint;
  65699. /**
  65700. * Gets the output component
  65701. */
  65702. get output(): NodeMaterialConnectionPoint;
  65703. autoConfigure(material: NodeMaterial): void;
  65704. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65705. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65706. protected _buildBlock(state: NodeMaterialBuildState): this;
  65707. }
  65708. }
  65709. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  65710. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65711. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65712. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65714. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65715. import { Effect } from "babylonjs/Materials/effect";
  65716. import { Mesh } from "babylonjs/Meshes/mesh";
  65717. import { Light } from "babylonjs/Lights/light";
  65718. import { Nullable } from "babylonjs/types";
  65719. import { Scene } from "babylonjs/scene";
  65720. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  65721. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  65722. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  65723. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65724. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  65725. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  65726. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  65727. /**
  65728. * Block used to add light in the fragment shader
  65729. */
  65730. export class LightBlock extends NodeMaterialBlock {
  65731. private _lightId;
  65732. /**
  65733. * Gets or sets the light associated with this block
  65734. */
  65735. light: Nullable<Light>;
  65736. /**
  65737. * Create a new LightBlock
  65738. * @param name defines the block name
  65739. */
  65740. constructor(name: string);
  65741. /**
  65742. * Gets the current class name
  65743. * @returns the class name
  65744. */
  65745. getClassName(): string;
  65746. /**
  65747. * Gets the world position input component
  65748. */
  65749. get worldPosition(): NodeMaterialConnectionPoint;
  65750. /**
  65751. * Gets the world normal input component
  65752. */
  65753. get worldNormal(): NodeMaterialConnectionPoint;
  65754. /**
  65755. * Gets the camera (or eye) position component
  65756. */
  65757. get cameraPosition(): NodeMaterialConnectionPoint;
  65758. /**
  65759. * Gets the glossiness component
  65760. */
  65761. get glossiness(): NodeMaterialConnectionPoint;
  65762. /**
  65763. * Gets the glossinness power component
  65764. */
  65765. get glossPower(): NodeMaterialConnectionPoint;
  65766. /**
  65767. * Gets the diffuse color component
  65768. */
  65769. get diffuseColor(): NodeMaterialConnectionPoint;
  65770. /**
  65771. * Gets the specular color component
  65772. */
  65773. get specularColor(): NodeMaterialConnectionPoint;
  65774. /**
  65775. * Gets the diffuse output component
  65776. */
  65777. get diffuseOutput(): NodeMaterialConnectionPoint;
  65778. /**
  65779. * Gets the specular output component
  65780. */
  65781. get specularOutput(): NodeMaterialConnectionPoint;
  65782. /**
  65783. * Gets the shadow output component
  65784. */
  65785. get shadow(): NodeMaterialConnectionPoint;
  65786. autoConfigure(material: NodeMaterial): void;
  65787. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65788. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65789. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65790. private _injectVertexCode;
  65791. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65792. serialize(): any;
  65793. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65794. }
  65795. }
  65796. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  65797. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65798. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65799. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65800. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65801. /**
  65802. * Block used to read a reflection texture from a sampler
  65803. */
  65804. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  65805. /**
  65806. * Create a new ReflectionTextureBlock
  65807. * @param name defines the block name
  65808. */
  65809. constructor(name: string);
  65810. /**
  65811. * Gets the current class name
  65812. * @returns the class name
  65813. */
  65814. getClassName(): string;
  65815. /**
  65816. * Gets the world position input component
  65817. */
  65818. get position(): NodeMaterialConnectionPoint;
  65819. /**
  65820. * Gets the world position input component
  65821. */
  65822. get worldPosition(): NodeMaterialConnectionPoint;
  65823. /**
  65824. * Gets the world normal input component
  65825. */
  65826. get worldNormal(): NodeMaterialConnectionPoint;
  65827. /**
  65828. * Gets the world input component
  65829. */
  65830. get world(): NodeMaterialConnectionPoint;
  65831. /**
  65832. * Gets the camera (or eye) position component
  65833. */
  65834. get cameraPosition(): NodeMaterialConnectionPoint;
  65835. /**
  65836. * Gets the view input component
  65837. */
  65838. get view(): NodeMaterialConnectionPoint;
  65839. /**
  65840. * Gets the rgb output component
  65841. */
  65842. get rgb(): NodeMaterialConnectionPoint;
  65843. /**
  65844. * Gets the rgba output component
  65845. */
  65846. get rgba(): NodeMaterialConnectionPoint;
  65847. /**
  65848. * Gets the r output component
  65849. */
  65850. get r(): NodeMaterialConnectionPoint;
  65851. /**
  65852. * Gets the g output component
  65853. */
  65854. get g(): NodeMaterialConnectionPoint;
  65855. /**
  65856. * Gets the b output component
  65857. */
  65858. get b(): NodeMaterialConnectionPoint;
  65859. /**
  65860. * Gets the a output component
  65861. */
  65862. get a(): NodeMaterialConnectionPoint;
  65863. autoConfigure(material: NodeMaterial): void;
  65864. protected _buildBlock(state: NodeMaterialBuildState): this;
  65865. }
  65866. }
  65867. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  65868. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  65869. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  65870. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  65871. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  65872. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  65873. }
  65874. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  65875. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  65876. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  65877. }
  65878. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  65879. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65880. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65881. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65882. /**
  65883. * Block used to add 2 vectors
  65884. */
  65885. export class AddBlock extends NodeMaterialBlock {
  65886. /**
  65887. * Creates a new AddBlock
  65888. * @param name defines the block name
  65889. */
  65890. constructor(name: string);
  65891. /**
  65892. * Gets the current class name
  65893. * @returns the class name
  65894. */
  65895. getClassName(): string;
  65896. /**
  65897. * Gets the left operand input component
  65898. */
  65899. get left(): NodeMaterialConnectionPoint;
  65900. /**
  65901. * Gets the right operand input component
  65902. */
  65903. get right(): NodeMaterialConnectionPoint;
  65904. /**
  65905. * Gets the output component
  65906. */
  65907. get output(): NodeMaterialConnectionPoint;
  65908. protected _buildBlock(state: NodeMaterialBuildState): this;
  65909. }
  65910. }
  65911. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  65912. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65913. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65914. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65915. /**
  65916. * Block used to scale a vector by a float
  65917. */
  65918. export class ScaleBlock extends NodeMaterialBlock {
  65919. /**
  65920. * Creates a new ScaleBlock
  65921. * @param name defines the block name
  65922. */
  65923. constructor(name: string);
  65924. /**
  65925. * Gets the current class name
  65926. * @returns the class name
  65927. */
  65928. getClassName(): string;
  65929. /**
  65930. * Gets the input component
  65931. */
  65932. get input(): NodeMaterialConnectionPoint;
  65933. /**
  65934. * Gets the factor input component
  65935. */
  65936. get factor(): NodeMaterialConnectionPoint;
  65937. /**
  65938. * Gets the output component
  65939. */
  65940. get output(): NodeMaterialConnectionPoint;
  65941. protected _buildBlock(state: NodeMaterialBuildState): this;
  65942. }
  65943. }
  65944. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  65945. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65946. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65947. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65948. import { Scene } from "babylonjs/scene";
  65949. /**
  65950. * Block used to clamp a float
  65951. */
  65952. export class ClampBlock extends NodeMaterialBlock {
  65953. /** Gets or sets the minimum range */
  65954. minimum: number;
  65955. /** Gets or sets the maximum range */
  65956. maximum: number;
  65957. /**
  65958. * Creates a new ClampBlock
  65959. * @param name defines the block name
  65960. */
  65961. constructor(name: string);
  65962. /**
  65963. * Gets the current class name
  65964. * @returns the class name
  65965. */
  65966. getClassName(): string;
  65967. /**
  65968. * Gets the value input component
  65969. */
  65970. get value(): NodeMaterialConnectionPoint;
  65971. /**
  65972. * Gets the output component
  65973. */
  65974. get output(): NodeMaterialConnectionPoint;
  65975. protected _buildBlock(state: NodeMaterialBuildState): this;
  65976. protected _dumpPropertiesCode(): string;
  65977. serialize(): any;
  65978. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65979. }
  65980. }
  65981. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  65982. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65983. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65984. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65985. /**
  65986. * Block used to apply a cross product between 2 vectors
  65987. */
  65988. export class CrossBlock extends NodeMaterialBlock {
  65989. /**
  65990. * Creates a new CrossBlock
  65991. * @param name defines the block name
  65992. */
  65993. constructor(name: string);
  65994. /**
  65995. * Gets the current class name
  65996. * @returns the class name
  65997. */
  65998. getClassName(): string;
  65999. /**
  66000. * Gets the left operand input component
  66001. */
  66002. get left(): NodeMaterialConnectionPoint;
  66003. /**
  66004. * Gets the right operand input component
  66005. */
  66006. get right(): NodeMaterialConnectionPoint;
  66007. /**
  66008. * Gets the output component
  66009. */
  66010. get output(): NodeMaterialConnectionPoint;
  66011. protected _buildBlock(state: NodeMaterialBuildState): this;
  66012. }
  66013. }
  66014. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66015. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66016. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66017. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66018. /**
  66019. * Block used to apply a dot product between 2 vectors
  66020. */
  66021. export class DotBlock extends NodeMaterialBlock {
  66022. /**
  66023. * Creates a new DotBlock
  66024. * @param name defines the block name
  66025. */
  66026. constructor(name: string);
  66027. /**
  66028. * Gets the current class name
  66029. * @returns the class name
  66030. */
  66031. getClassName(): string;
  66032. /**
  66033. * Gets the left operand input component
  66034. */
  66035. get left(): NodeMaterialConnectionPoint;
  66036. /**
  66037. * Gets the right operand input component
  66038. */
  66039. get right(): NodeMaterialConnectionPoint;
  66040. /**
  66041. * Gets the output component
  66042. */
  66043. get output(): NodeMaterialConnectionPoint;
  66044. protected _buildBlock(state: NodeMaterialBuildState): this;
  66045. }
  66046. }
  66047. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66048. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66049. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66050. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66051. /**
  66052. * Block used to normalize a vector
  66053. */
  66054. export class NormalizeBlock extends NodeMaterialBlock {
  66055. /**
  66056. * Creates a new NormalizeBlock
  66057. * @param name defines the block name
  66058. */
  66059. constructor(name: string);
  66060. /**
  66061. * Gets the current class name
  66062. * @returns the class name
  66063. */
  66064. getClassName(): string;
  66065. /**
  66066. * Gets the input component
  66067. */
  66068. get input(): NodeMaterialConnectionPoint;
  66069. /**
  66070. * Gets the output component
  66071. */
  66072. get output(): NodeMaterialConnectionPoint;
  66073. protected _buildBlock(state: NodeMaterialBuildState): this;
  66074. }
  66075. }
  66076. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  66077. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66078. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66079. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66080. import { Scene } from "babylonjs/scene";
  66081. /**
  66082. * Operations supported by the Trigonometry block
  66083. */
  66084. export enum TrigonometryBlockOperations {
  66085. /** Cos */
  66086. Cos = 0,
  66087. /** Sin */
  66088. Sin = 1,
  66089. /** Abs */
  66090. Abs = 2,
  66091. /** Exp */
  66092. Exp = 3,
  66093. /** Exp2 */
  66094. Exp2 = 4,
  66095. /** Round */
  66096. Round = 5,
  66097. /** Floor */
  66098. Floor = 6,
  66099. /** Ceiling */
  66100. Ceiling = 7,
  66101. /** Square root */
  66102. Sqrt = 8,
  66103. /** Log */
  66104. Log = 9,
  66105. /** Tangent */
  66106. Tan = 10,
  66107. /** Arc tangent */
  66108. ArcTan = 11,
  66109. /** Arc cosinus */
  66110. ArcCos = 12,
  66111. /** Arc sinus */
  66112. ArcSin = 13,
  66113. /** Fraction */
  66114. Fract = 14,
  66115. /** Sign */
  66116. Sign = 15,
  66117. /** To radians (from degrees) */
  66118. Radians = 16,
  66119. /** To degrees (from radians) */
  66120. Degrees = 17
  66121. }
  66122. /**
  66123. * Block used to apply trigonometry operation to floats
  66124. */
  66125. export class TrigonometryBlock extends NodeMaterialBlock {
  66126. /**
  66127. * Gets or sets the operation applied by the block
  66128. */
  66129. operation: TrigonometryBlockOperations;
  66130. /**
  66131. * Creates a new TrigonometryBlock
  66132. * @param name defines the block name
  66133. */
  66134. constructor(name: string);
  66135. /**
  66136. * Gets the current class name
  66137. * @returns the class name
  66138. */
  66139. getClassName(): string;
  66140. /**
  66141. * Gets the input component
  66142. */
  66143. get input(): NodeMaterialConnectionPoint;
  66144. /**
  66145. * Gets the output component
  66146. */
  66147. get output(): NodeMaterialConnectionPoint;
  66148. protected _buildBlock(state: NodeMaterialBuildState): this;
  66149. serialize(): any;
  66150. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66151. protected _dumpPropertiesCode(): string;
  66152. }
  66153. }
  66154. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66155. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66156. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66157. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66158. /**
  66159. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66160. */
  66161. export class ColorMergerBlock extends NodeMaterialBlock {
  66162. /**
  66163. * Create a new ColorMergerBlock
  66164. * @param name defines the block name
  66165. */
  66166. constructor(name: string);
  66167. /**
  66168. * Gets the current class name
  66169. * @returns the class name
  66170. */
  66171. getClassName(): string;
  66172. /**
  66173. * Gets the rgb component (input)
  66174. */
  66175. get rgbIn(): NodeMaterialConnectionPoint;
  66176. /**
  66177. * Gets the r component (input)
  66178. */
  66179. get r(): NodeMaterialConnectionPoint;
  66180. /**
  66181. * Gets the g component (input)
  66182. */
  66183. get g(): NodeMaterialConnectionPoint;
  66184. /**
  66185. * Gets the b component (input)
  66186. */
  66187. get b(): NodeMaterialConnectionPoint;
  66188. /**
  66189. * Gets the a component (input)
  66190. */
  66191. get a(): NodeMaterialConnectionPoint;
  66192. /**
  66193. * Gets the rgba component (output)
  66194. */
  66195. get rgba(): NodeMaterialConnectionPoint;
  66196. /**
  66197. * Gets the rgb component (output)
  66198. */
  66199. get rgbOut(): NodeMaterialConnectionPoint;
  66200. /**
  66201. * Gets the rgb component (output)
  66202. * @deprecated Please use rgbOut instead.
  66203. */
  66204. get rgb(): NodeMaterialConnectionPoint;
  66205. protected _buildBlock(state: NodeMaterialBuildState): this;
  66206. }
  66207. }
  66208. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66209. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66210. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66211. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66212. /**
  66213. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66214. */
  66215. export class VectorSplitterBlock extends NodeMaterialBlock {
  66216. /**
  66217. * Create a new VectorSplitterBlock
  66218. * @param name defines the block name
  66219. */
  66220. constructor(name: string);
  66221. /**
  66222. * Gets the current class name
  66223. * @returns the class name
  66224. */
  66225. getClassName(): string;
  66226. /**
  66227. * Gets the xyzw component (input)
  66228. */
  66229. get xyzw(): NodeMaterialConnectionPoint;
  66230. /**
  66231. * Gets the xyz component (input)
  66232. */
  66233. get xyzIn(): NodeMaterialConnectionPoint;
  66234. /**
  66235. * Gets the xy component (input)
  66236. */
  66237. get xyIn(): NodeMaterialConnectionPoint;
  66238. /**
  66239. * Gets the xyz component (output)
  66240. */
  66241. get xyzOut(): NodeMaterialConnectionPoint;
  66242. /**
  66243. * Gets the xy component (output)
  66244. */
  66245. get xyOut(): NodeMaterialConnectionPoint;
  66246. /**
  66247. * Gets the x component (output)
  66248. */
  66249. get x(): NodeMaterialConnectionPoint;
  66250. /**
  66251. * Gets the y component (output)
  66252. */
  66253. get y(): NodeMaterialConnectionPoint;
  66254. /**
  66255. * Gets the z component (output)
  66256. */
  66257. get z(): NodeMaterialConnectionPoint;
  66258. /**
  66259. * Gets the w component (output)
  66260. */
  66261. get w(): NodeMaterialConnectionPoint;
  66262. protected _inputRename(name: string): string;
  66263. protected _outputRename(name: string): string;
  66264. protected _buildBlock(state: NodeMaterialBuildState): this;
  66265. }
  66266. }
  66267. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66268. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66269. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66270. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66271. /**
  66272. * Block used to lerp between 2 values
  66273. */
  66274. export class LerpBlock extends NodeMaterialBlock {
  66275. /**
  66276. * Creates a new LerpBlock
  66277. * @param name defines the block name
  66278. */
  66279. constructor(name: string);
  66280. /**
  66281. * Gets the current class name
  66282. * @returns the class name
  66283. */
  66284. getClassName(): string;
  66285. /**
  66286. * Gets the left operand input component
  66287. */
  66288. get left(): NodeMaterialConnectionPoint;
  66289. /**
  66290. * Gets the right operand input component
  66291. */
  66292. get right(): NodeMaterialConnectionPoint;
  66293. /**
  66294. * Gets the gradient operand input component
  66295. */
  66296. get gradient(): NodeMaterialConnectionPoint;
  66297. /**
  66298. * Gets the output component
  66299. */
  66300. get output(): NodeMaterialConnectionPoint;
  66301. protected _buildBlock(state: NodeMaterialBuildState): this;
  66302. }
  66303. }
  66304. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66305. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66306. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66307. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66308. /**
  66309. * Block used to divide 2 vectors
  66310. */
  66311. export class DivideBlock extends NodeMaterialBlock {
  66312. /**
  66313. * Creates a new DivideBlock
  66314. * @param name defines the block name
  66315. */
  66316. constructor(name: string);
  66317. /**
  66318. * Gets the current class name
  66319. * @returns the class name
  66320. */
  66321. getClassName(): string;
  66322. /**
  66323. * Gets the left operand input component
  66324. */
  66325. get left(): NodeMaterialConnectionPoint;
  66326. /**
  66327. * Gets the right operand input component
  66328. */
  66329. get right(): NodeMaterialConnectionPoint;
  66330. /**
  66331. * Gets the output component
  66332. */
  66333. get output(): NodeMaterialConnectionPoint;
  66334. protected _buildBlock(state: NodeMaterialBuildState): this;
  66335. }
  66336. }
  66337. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66338. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66339. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66340. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66341. /**
  66342. * Block used to subtract 2 vectors
  66343. */
  66344. export class SubtractBlock extends NodeMaterialBlock {
  66345. /**
  66346. * Creates a new SubtractBlock
  66347. * @param name defines the block name
  66348. */
  66349. constructor(name: string);
  66350. /**
  66351. * Gets the current class name
  66352. * @returns the class name
  66353. */
  66354. getClassName(): string;
  66355. /**
  66356. * Gets the left operand input component
  66357. */
  66358. get left(): NodeMaterialConnectionPoint;
  66359. /**
  66360. * Gets the right operand input component
  66361. */
  66362. get right(): NodeMaterialConnectionPoint;
  66363. /**
  66364. * Gets the output component
  66365. */
  66366. get output(): NodeMaterialConnectionPoint;
  66367. protected _buildBlock(state: NodeMaterialBuildState): this;
  66368. }
  66369. }
  66370. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66371. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66372. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66373. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66374. /**
  66375. * Block used to step a value
  66376. */
  66377. export class StepBlock extends NodeMaterialBlock {
  66378. /**
  66379. * Creates a new StepBlock
  66380. * @param name defines the block name
  66381. */
  66382. constructor(name: string);
  66383. /**
  66384. * Gets the current class name
  66385. * @returns the class name
  66386. */
  66387. getClassName(): string;
  66388. /**
  66389. * Gets the value operand input component
  66390. */
  66391. get value(): NodeMaterialConnectionPoint;
  66392. /**
  66393. * Gets the edge operand input component
  66394. */
  66395. get edge(): NodeMaterialConnectionPoint;
  66396. /**
  66397. * Gets the output component
  66398. */
  66399. get output(): NodeMaterialConnectionPoint;
  66400. protected _buildBlock(state: NodeMaterialBuildState): this;
  66401. }
  66402. }
  66403. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66404. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66405. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66406. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66407. /**
  66408. * Block used to get the opposite (1 - x) of a value
  66409. */
  66410. export class OneMinusBlock extends NodeMaterialBlock {
  66411. /**
  66412. * Creates a new OneMinusBlock
  66413. * @param name defines the block name
  66414. */
  66415. constructor(name: string);
  66416. /**
  66417. * Gets the current class name
  66418. * @returns the class name
  66419. */
  66420. getClassName(): string;
  66421. /**
  66422. * Gets the input component
  66423. */
  66424. get input(): NodeMaterialConnectionPoint;
  66425. /**
  66426. * Gets the output component
  66427. */
  66428. get output(): NodeMaterialConnectionPoint;
  66429. protected _buildBlock(state: NodeMaterialBuildState): this;
  66430. }
  66431. }
  66432. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66433. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66434. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66435. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66436. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66437. /**
  66438. * Block used to get the view direction
  66439. */
  66440. export class ViewDirectionBlock extends NodeMaterialBlock {
  66441. /**
  66442. * Creates a new ViewDirectionBlock
  66443. * @param name defines the block name
  66444. */
  66445. constructor(name: string);
  66446. /**
  66447. * Gets the current class name
  66448. * @returns the class name
  66449. */
  66450. getClassName(): string;
  66451. /**
  66452. * Gets the world position component
  66453. */
  66454. get worldPosition(): NodeMaterialConnectionPoint;
  66455. /**
  66456. * Gets the camera position component
  66457. */
  66458. get cameraPosition(): NodeMaterialConnectionPoint;
  66459. /**
  66460. * Gets the output component
  66461. */
  66462. get output(): NodeMaterialConnectionPoint;
  66463. autoConfigure(material: NodeMaterial): void;
  66464. protected _buildBlock(state: NodeMaterialBuildState): this;
  66465. }
  66466. }
  66467. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66468. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66469. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66470. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66471. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66472. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66473. /**
  66474. * Block used to compute fresnel value
  66475. */
  66476. export class FresnelBlock extends NodeMaterialBlock {
  66477. /**
  66478. * Create a new FresnelBlock
  66479. * @param name defines the block name
  66480. */
  66481. constructor(name: string);
  66482. /**
  66483. * Gets the current class name
  66484. * @returns the class name
  66485. */
  66486. getClassName(): string;
  66487. /**
  66488. * Gets the world normal input component
  66489. */
  66490. get worldNormal(): NodeMaterialConnectionPoint;
  66491. /**
  66492. * Gets the view direction input component
  66493. */
  66494. get viewDirection(): NodeMaterialConnectionPoint;
  66495. /**
  66496. * Gets the bias input component
  66497. */
  66498. get bias(): NodeMaterialConnectionPoint;
  66499. /**
  66500. * Gets the camera (or eye) position component
  66501. */
  66502. get power(): NodeMaterialConnectionPoint;
  66503. /**
  66504. * Gets the fresnel output component
  66505. */
  66506. get fresnel(): NodeMaterialConnectionPoint;
  66507. autoConfigure(material: NodeMaterial): void;
  66508. protected _buildBlock(state: NodeMaterialBuildState): this;
  66509. }
  66510. }
  66511. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66512. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66513. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66514. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66515. /**
  66516. * Block used to get the max of 2 values
  66517. */
  66518. export class MaxBlock extends NodeMaterialBlock {
  66519. /**
  66520. * Creates a new MaxBlock
  66521. * @param name defines the block name
  66522. */
  66523. constructor(name: string);
  66524. /**
  66525. * Gets the current class name
  66526. * @returns the class name
  66527. */
  66528. getClassName(): string;
  66529. /**
  66530. * Gets the left operand input component
  66531. */
  66532. get left(): NodeMaterialConnectionPoint;
  66533. /**
  66534. * Gets the right operand input component
  66535. */
  66536. get right(): NodeMaterialConnectionPoint;
  66537. /**
  66538. * Gets the output component
  66539. */
  66540. get output(): NodeMaterialConnectionPoint;
  66541. protected _buildBlock(state: NodeMaterialBuildState): this;
  66542. }
  66543. }
  66544. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66545. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66546. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66547. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66548. /**
  66549. * Block used to get the min of 2 values
  66550. */
  66551. export class MinBlock extends NodeMaterialBlock {
  66552. /**
  66553. * Creates a new MinBlock
  66554. * @param name defines the block name
  66555. */
  66556. constructor(name: string);
  66557. /**
  66558. * Gets the current class name
  66559. * @returns the class name
  66560. */
  66561. getClassName(): string;
  66562. /**
  66563. * Gets the left operand input component
  66564. */
  66565. get left(): NodeMaterialConnectionPoint;
  66566. /**
  66567. * Gets the right operand input component
  66568. */
  66569. get right(): NodeMaterialConnectionPoint;
  66570. /**
  66571. * Gets the output component
  66572. */
  66573. get output(): NodeMaterialConnectionPoint;
  66574. protected _buildBlock(state: NodeMaterialBuildState): this;
  66575. }
  66576. }
  66577. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66578. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66579. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66580. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66581. /**
  66582. * Block used to get the distance between 2 values
  66583. */
  66584. export class DistanceBlock extends NodeMaterialBlock {
  66585. /**
  66586. * Creates a new DistanceBlock
  66587. * @param name defines the block name
  66588. */
  66589. constructor(name: string);
  66590. /**
  66591. * Gets the current class name
  66592. * @returns the class name
  66593. */
  66594. getClassName(): string;
  66595. /**
  66596. * Gets the left operand input component
  66597. */
  66598. get left(): NodeMaterialConnectionPoint;
  66599. /**
  66600. * Gets the right operand input component
  66601. */
  66602. get right(): NodeMaterialConnectionPoint;
  66603. /**
  66604. * Gets the output component
  66605. */
  66606. get output(): NodeMaterialConnectionPoint;
  66607. protected _buildBlock(state: NodeMaterialBuildState): this;
  66608. }
  66609. }
  66610. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66611. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66612. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66613. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66614. /**
  66615. * Block used to get the length of a vector
  66616. */
  66617. export class LengthBlock extends NodeMaterialBlock {
  66618. /**
  66619. * Creates a new LengthBlock
  66620. * @param name defines the block name
  66621. */
  66622. constructor(name: string);
  66623. /**
  66624. * Gets the current class name
  66625. * @returns the class name
  66626. */
  66627. getClassName(): string;
  66628. /**
  66629. * Gets the value input component
  66630. */
  66631. get value(): NodeMaterialConnectionPoint;
  66632. /**
  66633. * Gets the output component
  66634. */
  66635. get output(): NodeMaterialConnectionPoint;
  66636. protected _buildBlock(state: NodeMaterialBuildState): this;
  66637. }
  66638. }
  66639. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66640. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66641. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66642. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66643. /**
  66644. * Block used to get negative version of a value (i.e. x * -1)
  66645. */
  66646. export class NegateBlock extends NodeMaterialBlock {
  66647. /**
  66648. * Creates a new NegateBlock
  66649. * @param name defines the block name
  66650. */
  66651. constructor(name: string);
  66652. /**
  66653. * Gets the current class name
  66654. * @returns the class name
  66655. */
  66656. getClassName(): string;
  66657. /**
  66658. * Gets the value input component
  66659. */
  66660. get value(): NodeMaterialConnectionPoint;
  66661. /**
  66662. * Gets the output component
  66663. */
  66664. get output(): NodeMaterialConnectionPoint;
  66665. protected _buildBlock(state: NodeMaterialBuildState): this;
  66666. }
  66667. }
  66668. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66669. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66670. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66671. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66672. /**
  66673. * Block used to get the value of the first parameter raised to the power of the second
  66674. */
  66675. export class PowBlock extends NodeMaterialBlock {
  66676. /**
  66677. * Creates a new PowBlock
  66678. * @param name defines the block name
  66679. */
  66680. constructor(name: string);
  66681. /**
  66682. * Gets the current class name
  66683. * @returns the class name
  66684. */
  66685. getClassName(): string;
  66686. /**
  66687. * Gets the value operand input component
  66688. */
  66689. get value(): NodeMaterialConnectionPoint;
  66690. /**
  66691. * Gets the power operand input component
  66692. */
  66693. get power(): NodeMaterialConnectionPoint;
  66694. /**
  66695. * Gets the output component
  66696. */
  66697. get output(): NodeMaterialConnectionPoint;
  66698. protected _buildBlock(state: NodeMaterialBuildState): this;
  66699. }
  66700. }
  66701. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66702. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66703. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66704. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66705. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66706. /**
  66707. * Block used to get a random number
  66708. */
  66709. export class RandomNumberBlock extends NodeMaterialBlock {
  66710. /**
  66711. * Creates a new RandomNumberBlock
  66712. * @param name defines the block name
  66713. */
  66714. constructor(name: string);
  66715. /**
  66716. * Gets the current class name
  66717. * @returns the class name
  66718. */
  66719. getClassName(): string;
  66720. /**
  66721. * Gets the seed input component
  66722. */
  66723. get seed(): NodeMaterialConnectionPoint;
  66724. /**
  66725. * Gets the output component
  66726. */
  66727. get output(): NodeMaterialConnectionPoint;
  66728. protected _buildBlock(state: NodeMaterialBuildState): this;
  66729. }
  66730. }
  66731. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  66732. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66733. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66734. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66735. /**
  66736. * Block used to compute arc tangent of 2 values
  66737. */
  66738. export class ArcTan2Block extends NodeMaterialBlock {
  66739. /**
  66740. * Creates a new ArcTan2Block
  66741. * @param name defines the block name
  66742. */
  66743. constructor(name: string);
  66744. /**
  66745. * Gets the current class name
  66746. * @returns the class name
  66747. */
  66748. getClassName(): string;
  66749. /**
  66750. * Gets the x operand input component
  66751. */
  66752. get x(): NodeMaterialConnectionPoint;
  66753. /**
  66754. * Gets the y operand input component
  66755. */
  66756. get y(): NodeMaterialConnectionPoint;
  66757. /**
  66758. * Gets the output component
  66759. */
  66760. get output(): NodeMaterialConnectionPoint;
  66761. protected _buildBlock(state: NodeMaterialBuildState): this;
  66762. }
  66763. }
  66764. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  66765. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66766. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66767. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66768. /**
  66769. * Block used to smooth step a value
  66770. */
  66771. export class SmoothStepBlock extends NodeMaterialBlock {
  66772. /**
  66773. * Creates a new SmoothStepBlock
  66774. * @param name defines the block name
  66775. */
  66776. constructor(name: string);
  66777. /**
  66778. * Gets the current class name
  66779. * @returns the class name
  66780. */
  66781. getClassName(): string;
  66782. /**
  66783. * Gets the value operand input component
  66784. */
  66785. get value(): NodeMaterialConnectionPoint;
  66786. /**
  66787. * Gets the first edge operand input component
  66788. */
  66789. get edge0(): NodeMaterialConnectionPoint;
  66790. /**
  66791. * Gets the second edge operand input component
  66792. */
  66793. get edge1(): NodeMaterialConnectionPoint;
  66794. /**
  66795. * Gets the output component
  66796. */
  66797. get output(): NodeMaterialConnectionPoint;
  66798. protected _buildBlock(state: NodeMaterialBuildState): this;
  66799. }
  66800. }
  66801. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  66802. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66803. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66804. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66805. /**
  66806. * Block used to get the reciprocal (1 / x) of a value
  66807. */
  66808. export class ReciprocalBlock extends NodeMaterialBlock {
  66809. /**
  66810. * Creates a new ReciprocalBlock
  66811. * @param name defines the block name
  66812. */
  66813. constructor(name: string);
  66814. /**
  66815. * Gets the current class name
  66816. * @returns the class name
  66817. */
  66818. getClassName(): string;
  66819. /**
  66820. * Gets the input component
  66821. */
  66822. get input(): NodeMaterialConnectionPoint;
  66823. /**
  66824. * Gets the output component
  66825. */
  66826. get output(): NodeMaterialConnectionPoint;
  66827. protected _buildBlock(state: NodeMaterialBuildState): this;
  66828. }
  66829. }
  66830. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  66831. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66832. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66833. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66834. /**
  66835. * Block used to replace a color by another one
  66836. */
  66837. export class ReplaceColorBlock extends NodeMaterialBlock {
  66838. /**
  66839. * Creates a new ReplaceColorBlock
  66840. * @param name defines the block name
  66841. */
  66842. constructor(name: string);
  66843. /**
  66844. * Gets the current class name
  66845. * @returns the class name
  66846. */
  66847. getClassName(): string;
  66848. /**
  66849. * Gets the value input component
  66850. */
  66851. get value(): NodeMaterialConnectionPoint;
  66852. /**
  66853. * Gets the reference input component
  66854. */
  66855. get reference(): NodeMaterialConnectionPoint;
  66856. /**
  66857. * Gets the distance input component
  66858. */
  66859. get distance(): NodeMaterialConnectionPoint;
  66860. /**
  66861. * Gets the replacement input component
  66862. */
  66863. get replacement(): NodeMaterialConnectionPoint;
  66864. /**
  66865. * Gets the output component
  66866. */
  66867. get output(): NodeMaterialConnectionPoint;
  66868. protected _buildBlock(state: NodeMaterialBuildState): this;
  66869. }
  66870. }
  66871. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  66872. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66873. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66874. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66875. /**
  66876. * Block used to posterize a value
  66877. * @see https://en.wikipedia.org/wiki/Posterization
  66878. */
  66879. export class PosterizeBlock extends NodeMaterialBlock {
  66880. /**
  66881. * Creates a new PosterizeBlock
  66882. * @param name defines the block name
  66883. */
  66884. constructor(name: string);
  66885. /**
  66886. * Gets the current class name
  66887. * @returns the class name
  66888. */
  66889. getClassName(): string;
  66890. /**
  66891. * Gets the value input component
  66892. */
  66893. get value(): NodeMaterialConnectionPoint;
  66894. /**
  66895. * Gets the steps input component
  66896. */
  66897. get steps(): NodeMaterialConnectionPoint;
  66898. /**
  66899. * Gets the output component
  66900. */
  66901. get output(): NodeMaterialConnectionPoint;
  66902. protected _buildBlock(state: NodeMaterialBuildState): this;
  66903. }
  66904. }
  66905. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  66906. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66907. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66908. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66909. import { Scene } from "babylonjs/scene";
  66910. /**
  66911. * Operations supported by the Wave block
  66912. */
  66913. export enum WaveBlockKind {
  66914. /** SawTooth */
  66915. SawTooth = 0,
  66916. /** Square */
  66917. Square = 1,
  66918. /** Triangle */
  66919. Triangle = 2
  66920. }
  66921. /**
  66922. * Block used to apply wave operation to floats
  66923. */
  66924. export class WaveBlock extends NodeMaterialBlock {
  66925. /**
  66926. * Gets or sets the kibnd of wave to be applied by the block
  66927. */
  66928. kind: WaveBlockKind;
  66929. /**
  66930. * Creates a new WaveBlock
  66931. * @param name defines the block name
  66932. */
  66933. constructor(name: string);
  66934. /**
  66935. * Gets the current class name
  66936. * @returns the class name
  66937. */
  66938. getClassName(): string;
  66939. /**
  66940. * Gets the input component
  66941. */
  66942. get input(): NodeMaterialConnectionPoint;
  66943. /**
  66944. * Gets the output component
  66945. */
  66946. get output(): NodeMaterialConnectionPoint;
  66947. protected _buildBlock(state: NodeMaterialBuildState): this;
  66948. serialize(): any;
  66949. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66950. }
  66951. }
  66952. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  66953. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66954. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66955. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66956. import { Color3 } from "babylonjs/Maths/math.color";
  66957. import { Scene } from "babylonjs/scene";
  66958. /**
  66959. * Class used to store a color step for the GradientBlock
  66960. */
  66961. export class GradientBlockColorStep {
  66962. /**
  66963. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66964. */
  66965. step: number;
  66966. /**
  66967. * Gets or sets the color associated with this step
  66968. */
  66969. color: Color3;
  66970. /**
  66971. * Creates a new GradientBlockColorStep
  66972. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  66973. * @param color defines the color associated with this step
  66974. */
  66975. constructor(
  66976. /**
  66977. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66978. */
  66979. step: number,
  66980. /**
  66981. * Gets or sets the color associated with this step
  66982. */
  66983. color: Color3);
  66984. }
  66985. /**
  66986. * Block used to return a color from a gradient based on an input value between 0 and 1
  66987. */
  66988. export class GradientBlock extends NodeMaterialBlock {
  66989. /**
  66990. * Gets or sets the list of color steps
  66991. */
  66992. colorSteps: GradientBlockColorStep[];
  66993. /**
  66994. * Creates a new GradientBlock
  66995. * @param name defines the block name
  66996. */
  66997. constructor(name: string);
  66998. /**
  66999. * Gets the current class name
  67000. * @returns the class name
  67001. */
  67002. getClassName(): string;
  67003. /**
  67004. * Gets the gradient input component
  67005. */
  67006. get gradient(): NodeMaterialConnectionPoint;
  67007. /**
  67008. * Gets the output component
  67009. */
  67010. get output(): NodeMaterialConnectionPoint;
  67011. private _writeColorConstant;
  67012. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67013. serialize(): any;
  67014. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67015. protected _dumpPropertiesCode(): string;
  67016. }
  67017. }
  67018. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67019. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67020. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67021. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67022. /**
  67023. * Block used to normalize lerp between 2 values
  67024. */
  67025. export class NLerpBlock extends NodeMaterialBlock {
  67026. /**
  67027. * Creates a new NLerpBlock
  67028. * @param name defines the block name
  67029. */
  67030. constructor(name: string);
  67031. /**
  67032. * Gets the current class name
  67033. * @returns the class name
  67034. */
  67035. getClassName(): string;
  67036. /**
  67037. * Gets the left operand input component
  67038. */
  67039. get left(): NodeMaterialConnectionPoint;
  67040. /**
  67041. * Gets the right operand input component
  67042. */
  67043. get right(): NodeMaterialConnectionPoint;
  67044. /**
  67045. * Gets the gradient operand input component
  67046. */
  67047. get gradient(): NodeMaterialConnectionPoint;
  67048. /**
  67049. * Gets the output component
  67050. */
  67051. get output(): NodeMaterialConnectionPoint;
  67052. protected _buildBlock(state: NodeMaterialBuildState): this;
  67053. }
  67054. }
  67055. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67056. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67057. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67058. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67059. import { Scene } from "babylonjs/scene";
  67060. /**
  67061. * block used to Generate a Worley Noise 3D Noise Pattern
  67062. */
  67063. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67064. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67065. manhattanDistance: boolean;
  67066. /**
  67067. * Creates a new WorleyNoise3DBlock
  67068. * @param name defines the block name
  67069. */
  67070. constructor(name: string);
  67071. /**
  67072. * Gets the current class name
  67073. * @returns the class name
  67074. */
  67075. getClassName(): string;
  67076. /**
  67077. * Gets the seed input component
  67078. */
  67079. get seed(): NodeMaterialConnectionPoint;
  67080. /**
  67081. * Gets the jitter input component
  67082. */
  67083. get jitter(): NodeMaterialConnectionPoint;
  67084. /**
  67085. * Gets the output component
  67086. */
  67087. get output(): NodeMaterialConnectionPoint;
  67088. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67089. /**
  67090. * Exposes the properties to the UI?
  67091. */
  67092. protected _dumpPropertiesCode(): string;
  67093. /**
  67094. * Exposes the properties to the Seralize?
  67095. */
  67096. serialize(): any;
  67097. /**
  67098. * Exposes the properties to the deseralize?
  67099. */
  67100. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67101. }
  67102. }
  67103. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67104. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67105. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67106. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67107. /**
  67108. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67109. */
  67110. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67111. /**
  67112. * Creates a new SimplexPerlin3DBlock
  67113. * @param name defines the block name
  67114. */
  67115. constructor(name: string);
  67116. /**
  67117. * Gets the current class name
  67118. * @returns the class name
  67119. */
  67120. getClassName(): string;
  67121. /**
  67122. * Gets the seed operand input component
  67123. */
  67124. get seed(): NodeMaterialConnectionPoint;
  67125. /**
  67126. * Gets the output component
  67127. */
  67128. get output(): NodeMaterialConnectionPoint;
  67129. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67130. }
  67131. }
  67132. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67133. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67134. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67135. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67136. /**
  67137. * Block used to blend normals
  67138. */
  67139. export class NormalBlendBlock extends NodeMaterialBlock {
  67140. /**
  67141. * Creates a new NormalBlendBlock
  67142. * @param name defines the block name
  67143. */
  67144. constructor(name: string);
  67145. /**
  67146. * Gets the current class name
  67147. * @returns the class name
  67148. */
  67149. getClassName(): string;
  67150. /**
  67151. * Gets the first input component
  67152. */
  67153. get normalMap0(): NodeMaterialConnectionPoint;
  67154. /**
  67155. * Gets the second input component
  67156. */
  67157. get normalMap1(): NodeMaterialConnectionPoint;
  67158. /**
  67159. * Gets the output component
  67160. */
  67161. get output(): NodeMaterialConnectionPoint;
  67162. protected _buildBlock(state: NodeMaterialBuildState): this;
  67163. }
  67164. }
  67165. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67166. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67167. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67168. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67169. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67170. /**
  67171. * Block used to rotate a 2d vector by a given angle
  67172. */
  67173. export class Rotate2dBlock extends NodeMaterialBlock {
  67174. /**
  67175. * Creates a new Rotate2dBlock
  67176. * @param name defines the block name
  67177. */
  67178. constructor(name: string);
  67179. /**
  67180. * Gets the current class name
  67181. * @returns the class name
  67182. */
  67183. getClassName(): string;
  67184. /**
  67185. * Gets the input vector
  67186. */
  67187. get input(): NodeMaterialConnectionPoint;
  67188. /**
  67189. * Gets the input angle
  67190. */
  67191. get angle(): NodeMaterialConnectionPoint;
  67192. /**
  67193. * Gets the output component
  67194. */
  67195. get output(): NodeMaterialConnectionPoint;
  67196. autoConfigure(material: NodeMaterial): void;
  67197. protected _buildBlock(state: NodeMaterialBuildState): this;
  67198. }
  67199. }
  67200. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67201. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67202. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67203. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67204. /**
  67205. * Block used to get the reflected vector from a direction and a normal
  67206. */
  67207. export class ReflectBlock extends NodeMaterialBlock {
  67208. /**
  67209. * Creates a new ReflectBlock
  67210. * @param name defines the block name
  67211. */
  67212. constructor(name: string);
  67213. /**
  67214. * Gets the current class name
  67215. * @returns the class name
  67216. */
  67217. getClassName(): string;
  67218. /**
  67219. * Gets the incident component
  67220. */
  67221. get incident(): NodeMaterialConnectionPoint;
  67222. /**
  67223. * Gets the normal component
  67224. */
  67225. get normal(): NodeMaterialConnectionPoint;
  67226. /**
  67227. * Gets the output component
  67228. */
  67229. get output(): NodeMaterialConnectionPoint;
  67230. protected _buildBlock(state: NodeMaterialBuildState): this;
  67231. }
  67232. }
  67233. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67234. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67235. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67236. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67237. /**
  67238. * Block used to get the refracted vector from a direction and a normal
  67239. */
  67240. export class RefractBlock extends NodeMaterialBlock {
  67241. /**
  67242. * Creates a new RefractBlock
  67243. * @param name defines the block name
  67244. */
  67245. constructor(name: string);
  67246. /**
  67247. * Gets the current class name
  67248. * @returns the class name
  67249. */
  67250. getClassName(): string;
  67251. /**
  67252. * Gets the incident component
  67253. */
  67254. get incident(): NodeMaterialConnectionPoint;
  67255. /**
  67256. * Gets the normal component
  67257. */
  67258. get normal(): NodeMaterialConnectionPoint;
  67259. /**
  67260. * Gets the index of refraction component
  67261. */
  67262. get ior(): NodeMaterialConnectionPoint;
  67263. /**
  67264. * Gets the output component
  67265. */
  67266. get output(): NodeMaterialConnectionPoint;
  67267. protected _buildBlock(state: NodeMaterialBuildState): this;
  67268. }
  67269. }
  67270. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67271. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67272. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67273. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67274. /**
  67275. * Block used to desaturate a color
  67276. */
  67277. export class DesaturateBlock extends NodeMaterialBlock {
  67278. /**
  67279. * Creates a new DesaturateBlock
  67280. * @param name defines the block name
  67281. */
  67282. constructor(name: string);
  67283. /**
  67284. * Gets the current class name
  67285. * @returns the class name
  67286. */
  67287. getClassName(): string;
  67288. /**
  67289. * Gets the color operand input component
  67290. */
  67291. get color(): NodeMaterialConnectionPoint;
  67292. /**
  67293. * Gets the level operand input component
  67294. */
  67295. get level(): NodeMaterialConnectionPoint;
  67296. /**
  67297. * Gets the output component
  67298. */
  67299. get output(): NodeMaterialConnectionPoint;
  67300. protected _buildBlock(state: NodeMaterialBuildState): this;
  67301. }
  67302. }
  67303. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67304. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67305. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67306. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67307. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67308. import { Nullable } from "babylonjs/types";
  67309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67310. import { Scene } from "babylonjs/scene";
  67311. /**
  67312. * Block used to implement the ambient occlusion module of the PBR material
  67313. */
  67314. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67315. /**
  67316. * Create a new AmbientOcclusionBlock
  67317. * @param name defines the block name
  67318. */
  67319. constructor(name: string);
  67320. /**
  67321. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67322. */
  67323. useAmbientInGrayScale: boolean;
  67324. /**
  67325. * Initialize the block and prepare the context for build
  67326. * @param state defines the state that will be used for the build
  67327. */
  67328. initialize(state: NodeMaterialBuildState): void;
  67329. /**
  67330. * Gets the current class name
  67331. * @returns the class name
  67332. */
  67333. getClassName(): string;
  67334. /**
  67335. * Gets the texture input component
  67336. */
  67337. get texture(): NodeMaterialConnectionPoint;
  67338. /**
  67339. * Gets the texture intensity component
  67340. */
  67341. get intensity(): NodeMaterialConnectionPoint;
  67342. /**
  67343. * Gets the direct light intensity input component
  67344. */
  67345. get directLightIntensity(): NodeMaterialConnectionPoint;
  67346. /**
  67347. * Gets the ambient occlusion object output component
  67348. */
  67349. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67350. /**
  67351. * Gets the main code of the block (fragment side)
  67352. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67353. * @returns the shader code
  67354. */
  67355. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67356. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67357. protected _buildBlock(state: NodeMaterialBuildState): this;
  67358. protected _dumpPropertiesCode(): string;
  67359. serialize(): any;
  67360. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67361. }
  67362. }
  67363. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67364. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67365. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67366. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67367. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67369. import { Nullable } from "babylonjs/types";
  67370. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67371. import { Mesh } from "babylonjs/Meshes/mesh";
  67372. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67373. import { Effect } from "babylonjs/Materials/effect";
  67374. import { Scene } from "babylonjs/scene";
  67375. /**
  67376. * Block used to implement the reflection module of the PBR material
  67377. */
  67378. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67379. /** @hidden */
  67380. _defineLODReflectionAlpha: string;
  67381. /** @hidden */
  67382. _defineLinearSpecularReflection: string;
  67383. private _vEnvironmentIrradianceName;
  67384. /** @hidden */
  67385. _vReflectionMicrosurfaceInfosName: string;
  67386. /** @hidden */
  67387. _vReflectionInfosName: string;
  67388. /** @hidden */
  67389. _vReflectionFilteringInfoName: string;
  67390. private _scene;
  67391. /**
  67392. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67393. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67394. * It's less burden on the user side in the editor part.
  67395. */
  67396. /** @hidden */
  67397. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67398. /** @hidden */
  67399. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67400. /** @hidden */
  67401. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67402. /**
  67403. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67404. * diffuse part of the IBL.
  67405. */
  67406. useSphericalHarmonics: boolean;
  67407. /**
  67408. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67409. */
  67410. forceIrradianceInFragment: boolean;
  67411. /**
  67412. * Create a new ReflectionBlock
  67413. * @param name defines the block name
  67414. */
  67415. constructor(name: string);
  67416. /**
  67417. * Gets the current class name
  67418. * @returns the class name
  67419. */
  67420. getClassName(): string;
  67421. /**
  67422. * Gets the position input component
  67423. */
  67424. get position(): NodeMaterialConnectionPoint;
  67425. /**
  67426. * Gets the world position input component
  67427. */
  67428. get worldPosition(): NodeMaterialConnectionPoint;
  67429. /**
  67430. * Gets the world normal input component
  67431. */
  67432. get worldNormal(): NodeMaterialConnectionPoint;
  67433. /**
  67434. * Gets the world input component
  67435. */
  67436. get world(): NodeMaterialConnectionPoint;
  67437. /**
  67438. * Gets the camera (or eye) position component
  67439. */
  67440. get cameraPosition(): NodeMaterialConnectionPoint;
  67441. /**
  67442. * Gets the view input component
  67443. */
  67444. get view(): NodeMaterialConnectionPoint;
  67445. /**
  67446. * Gets the color input component
  67447. */
  67448. get color(): NodeMaterialConnectionPoint;
  67449. /**
  67450. * Gets the reflection object output component
  67451. */
  67452. get reflection(): NodeMaterialConnectionPoint;
  67453. /**
  67454. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67455. */
  67456. get hasTexture(): boolean;
  67457. /**
  67458. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67459. */
  67460. get reflectionColor(): string;
  67461. protected _getTexture(): Nullable<BaseTexture>;
  67462. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67463. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67464. /**
  67465. * Gets the code to inject in the vertex shader
  67466. * @param state current state of the node material building
  67467. * @returns the shader code
  67468. */
  67469. handleVertexSide(state: NodeMaterialBuildState): string;
  67470. /**
  67471. * Gets the main code of the block (fragment side)
  67472. * @param state current state of the node material building
  67473. * @param normalVarName name of the existing variable corresponding to the normal
  67474. * @returns the shader code
  67475. */
  67476. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67477. protected _buildBlock(state: NodeMaterialBuildState): this;
  67478. protected _dumpPropertiesCode(): string;
  67479. serialize(): any;
  67480. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67481. }
  67482. }
  67483. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67484. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67485. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67486. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67487. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67489. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67490. import { Scene } from "babylonjs/scene";
  67491. import { Nullable } from "babylonjs/types";
  67492. /**
  67493. * Block used to implement the sheen module of the PBR material
  67494. */
  67495. export class SheenBlock extends NodeMaterialBlock {
  67496. /**
  67497. * Create a new SheenBlock
  67498. * @param name defines the block name
  67499. */
  67500. constructor(name: string);
  67501. /**
  67502. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67503. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67504. * making it easier to setup and tweak the effect
  67505. */
  67506. albedoScaling: boolean;
  67507. /**
  67508. * Defines if the sheen is linked to the sheen color.
  67509. */
  67510. linkSheenWithAlbedo: boolean;
  67511. /**
  67512. * Initialize the block and prepare the context for build
  67513. * @param state defines the state that will be used for the build
  67514. */
  67515. initialize(state: NodeMaterialBuildState): void;
  67516. /**
  67517. * Gets the current class name
  67518. * @returns the class name
  67519. */
  67520. getClassName(): string;
  67521. /**
  67522. * Gets the intensity input component
  67523. */
  67524. get intensity(): NodeMaterialConnectionPoint;
  67525. /**
  67526. * Gets the color input component
  67527. */
  67528. get color(): NodeMaterialConnectionPoint;
  67529. /**
  67530. * Gets the roughness input component
  67531. */
  67532. get roughness(): NodeMaterialConnectionPoint;
  67533. /**
  67534. * Gets the sheen object output component
  67535. */
  67536. get sheen(): NodeMaterialConnectionPoint;
  67537. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67538. /**
  67539. * Gets the main code of the block (fragment side)
  67540. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67541. * @returns the shader code
  67542. */
  67543. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67544. protected _buildBlock(state: NodeMaterialBuildState): this;
  67545. protected _dumpPropertiesCode(): string;
  67546. serialize(): any;
  67547. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67548. }
  67549. }
  67550. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67551. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67552. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67553. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67555. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67556. import { Scene } from "babylonjs/scene";
  67557. import { Nullable } from "babylonjs/types";
  67558. import { Mesh } from "babylonjs/Meshes/mesh";
  67559. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67560. import { Effect } from "babylonjs/Materials/effect";
  67561. /**
  67562. * Block used to implement the reflectivity module of the PBR material
  67563. */
  67564. export class ReflectivityBlock extends NodeMaterialBlock {
  67565. private _metallicReflectanceColor;
  67566. private _metallicF0Factor;
  67567. /** @hidden */
  67568. _vMetallicReflectanceFactorsName: string;
  67569. /**
  67570. * The property below is set by the main PBR block prior to calling methods of this class.
  67571. */
  67572. /** @hidden */
  67573. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67574. /**
  67575. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67576. */
  67577. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67578. /**
  67579. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67580. */
  67581. useMetallnessFromMetallicTextureBlue: boolean;
  67582. /**
  67583. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67584. */
  67585. useRoughnessFromMetallicTextureAlpha: boolean;
  67586. /**
  67587. * Specifies if the metallic texture contains the roughness information in its green channel.
  67588. */
  67589. useRoughnessFromMetallicTextureGreen: boolean;
  67590. /**
  67591. * Create a new ReflectivityBlock
  67592. * @param name defines the block name
  67593. */
  67594. constructor(name: string);
  67595. /**
  67596. * Initialize the block and prepare the context for build
  67597. * @param state defines the state that will be used for the build
  67598. */
  67599. initialize(state: NodeMaterialBuildState): void;
  67600. /**
  67601. * Gets the current class name
  67602. * @returns the class name
  67603. */
  67604. getClassName(): string;
  67605. /**
  67606. * Gets the metallic input component
  67607. */
  67608. get metallic(): NodeMaterialConnectionPoint;
  67609. /**
  67610. * Gets the roughness input component
  67611. */
  67612. get roughness(): NodeMaterialConnectionPoint;
  67613. /**
  67614. * Gets the texture input component
  67615. */
  67616. get texture(): NodeMaterialConnectionPoint;
  67617. /**
  67618. * Gets the reflectivity object output component
  67619. */
  67620. get reflectivity(): NodeMaterialConnectionPoint;
  67621. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67622. /**
  67623. * Gets the main code of the block (fragment side)
  67624. * @param state current state of the node material building
  67625. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67626. * @returns the shader code
  67627. */
  67628. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67629. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67630. protected _buildBlock(state: NodeMaterialBuildState): this;
  67631. protected _dumpPropertiesCode(): string;
  67632. serialize(): any;
  67633. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67634. }
  67635. }
  67636. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67637. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67638. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67639. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67640. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67642. /**
  67643. * Block used to implement the anisotropy module of the PBR material
  67644. */
  67645. export class AnisotropyBlock extends NodeMaterialBlock {
  67646. /**
  67647. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67648. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67649. * It's less burden on the user side in the editor part.
  67650. */
  67651. /** @hidden */
  67652. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67653. /** @hidden */
  67654. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67655. /**
  67656. * Create a new AnisotropyBlock
  67657. * @param name defines the block name
  67658. */
  67659. constructor(name: string);
  67660. /**
  67661. * Initialize the block and prepare the context for build
  67662. * @param state defines the state that will be used for the build
  67663. */
  67664. initialize(state: NodeMaterialBuildState): void;
  67665. /**
  67666. * Gets the current class name
  67667. * @returns the class name
  67668. */
  67669. getClassName(): string;
  67670. /**
  67671. * Gets the intensity input component
  67672. */
  67673. get intensity(): NodeMaterialConnectionPoint;
  67674. /**
  67675. * Gets the direction input component
  67676. */
  67677. get direction(): NodeMaterialConnectionPoint;
  67678. /**
  67679. * Gets the texture input component
  67680. */
  67681. get texture(): NodeMaterialConnectionPoint;
  67682. /**
  67683. * Gets the uv input component
  67684. */
  67685. get uv(): NodeMaterialConnectionPoint;
  67686. /**
  67687. * Gets the worldTangent input component
  67688. */
  67689. get worldTangent(): NodeMaterialConnectionPoint;
  67690. /**
  67691. * Gets the anisotropy object output component
  67692. */
  67693. get anisotropy(): NodeMaterialConnectionPoint;
  67694. private _generateTBNSpace;
  67695. /**
  67696. * Gets the main code of the block (fragment side)
  67697. * @param state current state of the node material building
  67698. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67699. * @returns the shader code
  67700. */
  67701. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67702. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67703. protected _buildBlock(state: NodeMaterialBuildState): this;
  67704. }
  67705. }
  67706. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67707. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67708. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67709. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67710. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67712. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67713. import { Nullable } from "babylonjs/types";
  67714. import { Mesh } from "babylonjs/Meshes/mesh";
  67715. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67716. import { Effect } from "babylonjs/Materials/effect";
  67717. /**
  67718. * Block used to implement the clear coat module of the PBR material
  67719. */
  67720. export class ClearCoatBlock extends NodeMaterialBlock {
  67721. private _scene;
  67722. /**
  67723. * Create a new ClearCoatBlock
  67724. * @param name defines the block name
  67725. */
  67726. constructor(name: string);
  67727. /**
  67728. * Initialize the block and prepare the context for build
  67729. * @param state defines the state that will be used for the build
  67730. */
  67731. initialize(state: NodeMaterialBuildState): void;
  67732. /**
  67733. * Gets the current class name
  67734. * @returns the class name
  67735. */
  67736. getClassName(): string;
  67737. /**
  67738. * Gets the intensity input component
  67739. */
  67740. get intensity(): NodeMaterialConnectionPoint;
  67741. /**
  67742. * Gets the roughness input component
  67743. */
  67744. get roughness(): NodeMaterialConnectionPoint;
  67745. /**
  67746. * Gets the ior input component
  67747. */
  67748. get ior(): NodeMaterialConnectionPoint;
  67749. /**
  67750. * Gets the texture input component
  67751. */
  67752. get texture(): NodeMaterialConnectionPoint;
  67753. /**
  67754. * Gets the bump texture input component
  67755. */
  67756. get bumpTexture(): NodeMaterialConnectionPoint;
  67757. /**
  67758. * Gets the uv input component
  67759. */
  67760. get uv(): NodeMaterialConnectionPoint;
  67761. /**
  67762. * Gets the tint color input component
  67763. */
  67764. get tintColor(): NodeMaterialConnectionPoint;
  67765. /**
  67766. * Gets the tint "at distance" input component
  67767. */
  67768. get tintAtDistance(): NodeMaterialConnectionPoint;
  67769. /**
  67770. * Gets the tint thickness input component
  67771. */
  67772. get tintThickness(): NodeMaterialConnectionPoint;
  67773. /**
  67774. * Gets the world tangent input component
  67775. */
  67776. get worldTangent(): NodeMaterialConnectionPoint;
  67777. /**
  67778. * Gets the clear coat object output component
  67779. */
  67780. get clearcoat(): NodeMaterialConnectionPoint;
  67781. autoConfigure(material: NodeMaterial): void;
  67782. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67783. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67784. private _generateTBNSpace;
  67785. /**
  67786. * Gets the main code of the block (fragment side)
  67787. * @param state current state of the node material building
  67788. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  67789. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67790. * @param worldPosVarName name of the variable holding the world position
  67791. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67792. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  67793. * @param worldNormalVarName name of the variable holding the world normal
  67794. * @returns the shader code
  67795. */
  67796. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  67797. protected _buildBlock(state: NodeMaterialBuildState): this;
  67798. }
  67799. }
  67800. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  67801. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67802. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67804. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67806. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67807. import { Nullable } from "babylonjs/types";
  67808. /**
  67809. * Block used to implement the sub surface module of the PBR material
  67810. */
  67811. export class SubSurfaceBlock extends NodeMaterialBlock {
  67812. /**
  67813. * Create a new SubSurfaceBlock
  67814. * @param name defines the block name
  67815. */
  67816. constructor(name: string);
  67817. /**
  67818. * Stores the intensity of the different subsurface effects in the thickness texture.
  67819. * * the green channel is the translucency intensity.
  67820. * * the blue channel is the scattering intensity.
  67821. * * the alpha channel is the refraction intensity.
  67822. */
  67823. useMaskFromThicknessTexture: boolean;
  67824. /**
  67825. * Initialize the block and prepare the context for build
  67826. * @param state defines the state that will be used for the build
  67827. */
  67828. initialize(state: NodeMaterialBuildState): void;
  67829. /**
  67830. * Gets the current class name
  67831. * @returns the class name
  67832. */
  67833. getClassName(): string;
  67834. /**
  67835. * Gets the min thickness input component
  67836. */
  67837. get minThickness(): NodeMaterialConnectionPoint;
  67838. /**
  67839. * Gets the max thickness input component
  67840. */
  67841. get maxThickness(): NodeMaterialConnectionPoint;
  67842. /**
  67843. * Gets the thickness texture component
  67844. */
  67845. get thicknessTexture(): NodeMaterialConnectionPoint;
  67846. /**
  67847. * Gets the tint color input component
  67848. */
  67849. get tintColor(): NodeMaterialConnectionPoint;
  67850. /**
  67851. * Gets the translucency intensity input component
  67852. */
  67853. get translucencyIntensity(): NodeMaterialConnectionPoint;
  67854. /**
  67855. * Gets the translucency diffusion distance input component
  67856. */
  67857. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  67858. /**
  67859. * Gets the refraction object parameters
  67860. */
  67861. get refraction(): NodeMaterialConnectionPoint;
  67862. /**
  67863. * Gets the sub surface object output component
  67864. */
  67865. get subsurface(): NodeMaterialConnectionPoint;
  67866. autoConfigure(material: NodeMaterial): void;
  67867. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67868. /**
  67869. * Gets the main code of the block (fragment side)
  67870. * @param state current state of the node material building
  67871. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  67872. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67873. * @param worldPosVarName name of the variable holding the world position
  67874. * @returns the shader code
  67875. */
  67876. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  67877. protected _buildBlock(state: NodeMaterialBuildState): this;
  67878. }
  67879. }
  67880. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  67881. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67882. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67883. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67884. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67885. import { Light } from "babylonjs/Lights/light";
  67886. import { Nullable } from "babylonjs/types";
  67887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67888. import { Effect } from "babylonjs/Materials/effect";
  67889. import { Mesh } from "babylonjs/Meshes/mesh";
  67890. import { Scene } from "babylonjs/scene";
  67891. /**
  67892. * Block used to implement the PBR metallic/roughness model
  67893. */
  67894. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  67895. /**
  67896. * Gets or sets the light associated with this block
  67897. */
  67898. light: Nullable<Light>;
  67899. private _lightId;
  67900. private _scene;
  67901. private _environmentBRDFTexture;
  67902. private _environmentBrdfSamplerName;
  67903. private _vNormalWName;
  67904. private _invertNormalName;
  67905. /**
  67906. * Create a new ReflectionBlock
  67907. * @param name defines the block name
  67908. */
  67909. constructor(name: string);
  67910. /**
  67911. * Intensity of the direct lights e.g. the four lights available in your scene.
  67912. * This impacts both the direct diffuse and specular highlights.
  67913. */
  67914. directIntensity: number;
  67915. /**
  67916. * Intensity of the environment e.g. how much the environment will light the object
  67917. * either through harmonics for rough material or through the refelction for shiny ones.
  67918. */
  67919. environmentIntensity: number;
  67920. /**
  67921. * This is a special control allowing the reduction of the specular highlights coming from the
  67922. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  67923. */
  67924. specularIntensity: number;
  67925. /**
  67926. * Defines the falloff type used in this material.
  67927. * It by default is Physical.
  67928. */
  67929. lightFalloff: number;
  67930. /**
  67931. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  67932. */
  67933. useAlphaFromAlbedoTexture: boolean;
  67934. /**
  67935. * Specifies that alpha test should be used
  67936. */
  67937. useAlphaTest: boolean;
  67938. /**
  67939. * Defines the alpha limits in alpha test mode.
  67940. */
  67941. alphaTestCutoff: number;
  67942. /**
  67943. * Specifies that alpha blending should be used
  67944. */
  67945. useAlphaBlending: boolean;
  67946. /**
  67947. * Defines if the alpha value should be determined via the rgb values.
  67948. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  67949. */
  67950. opacityRGB: boolean;
  67951. /**
  67952. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  67953. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  67954. */
  67955. useRadianceOverAlpha: boolean;
  67956. /**
  67957. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  67958. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  67959. */
  67960. useSpecularOverAlpha: boolean;
  67961. /**
  67962. * Enables specular anti aliasing in the PBR shader.
  67963. * It will both interacts on the Geometry for analytical and IBL lighting.
  67964. * It also prefilter the roughness map based on the bump values.
  67965. */
  67966. enableSpecularAntiAliasing: boolean;
  67967. /**
  67968. * Enables realtime filtering on the texture.
  67969. */
  67970. realTimeFiltering: boolean;
  67971. /**
  67972. * Quality switch for realtime filtering
  67973. */
  67974. realTimeFilteringQuality: number;
  67975. /**
  67976. * Defines if the material uses energy conservation.
  67977. */
  67978. useEnergyConservation: boolean;
  67979. /**
  67980. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  67981. * too much the area relying on ambient texture to define their ambient occlusion.
  67982. */
  67983. useRadianceOcclusion: boolean;
  67984. /**
  67985. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  67986. * makes the reflect vector face the model (under horizon).
  67987. */
  67988. useHorizonOcclusion: boolean;
  67989. /**
  67990. * If set to true, no lighting calculations will be applied.
  67991. */
  67992. unlit: boolean;
  67993. /**
  67994. * Force normal to face away from face.
  67995. */
  67996. forceNormalForward: boolean;
  67997. /**
  67998. * Defines the material debug mode.
  67999. * It helps seeing only some components of the material while troubleshooting.
  68000. */
  68001. debugMode: number;
  68002. /**
  68003. * Specify from where on screen the debug mode should start.
  68004. * The value goes from -1 (full screen) to 1 (not visible)
  68005. * It helps with side by side comparison against the final render
  68006. * This defaults to 0
  68007. */
  68008. debugLimit: number;
  68009. /**
  68010. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68011. * You can use the factor to better multiply the final value.
  68012. */
  68013. debugFactor: number;
  68014. /**
  68015. * Initialize the block and prepare the context for build
  68016. * @param state defines the state that will be used for the build
  68017. */
  68018. initialize(state: NodeMaterialBuildState): void;
  68019. /**
  68020. * Gets the current class name
  68021. * @returns the class name
  68022. */
  68023. getClassName(): string;
  68024. /**
  68025. * Gets the world position input component
  68026. */
  68027. get worldPosition(): NodeMaterialConnectionPoint;
  68028. /**
  68029. * Gets the world normal input component
  68030. */
  68031. get worldNormal(): NodeMaterialConnectionPoint;
  68032. /**
  68033. * Gets the perturbed normal input component
  68034. */
  68035. get perturbedNormal(): NodeMaterialConnectionPoint;
  68036. /**
  68037. * Gets the camera position input component
  68038. */
  68039. get cameraPosition(): NodeMaterialConnectionPoint;
  68040. /**
  68041. * Gets the base color input component
  68042. */
  68043. get baseColor(): NodeMaterialConnectionPoint;
  68044. /**
  68045. * Gets the opacity texture input component
  68046. */
  68047. get opacityTexture(): NodeMaterialConnectionPoint;
  68048. /**
  68049. * Gets the ambient color input component
  68050. */
  68051. get ambientColor(): NodeMaterialConnectionPoint;
  68052. /**
  68053. * Gets the reflectivity object parameters
  68054. */
  68055. get reflectivity(): NodeMaterialConnectionPoint;
  68056. /**
  68057. * Gets the ambient occlusion object parameters
  68058. */
  68059. get ambientOcclusion(): NodeMaterialConnectionPoint;
  68060. /**
  68061. * Gets the reflection object parameters
  68062. */
  68063. get reflection(): NodeMaterialConnectionPoint;
  68064. /**
  68065. * Gets the sheen object parameters
  68066. */
  68067. get sheen(): NodeMaterialConnectionPoint;
  68068. /**
  68069. * Gets the clear coat object parameters
  68070. */
  68071. get clearcoat(): NodeMaterialConnectionPoint;
  68072. /**
  68073. * Gets the sub surface object parameters
  68074. */
  68075. get subsurface(): NodeMaterialConnectionPoint;
  68076. /**
  68077. * Gets the anisotropy object parameters
  68078. */
  68079. get anisotropy(): NodeMaterialConnectionPoint;
  68080. /**
  68081. * Gets the ambient output component
  68082. */
  68083. get ambient(): NodeMaterialConnectionPoint;
  68084. /**
  68085. * Gets the diffuse output component
  68086. */
  68087. get diffuse(): NodeMaterialConnectionPoint;
  68088. /**
  68089. * Gets the specular output component
  68090. */
  68091. get specular(): NodeMaterialConnectionPoint;
  68092. /**
  68093. * Gets the sheen output component
  68094. */
  68095. get sheenDir(): NodeMaterialConnectionPoint;
  68096. /**
  68097. * Gets the clear coat output component
  68098. */
  68099. get clearcoatDir(): NodeMaterialConnectionPoint;
  68100. /**
  68101. * Gets the indirect diffuse output component
  68102. */
  68103. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68104. /**
  68105. * Gets the indirect specular output component
  68106. */
  68107. get specularIndirect(): NodeMaterialConnectionPoint;
  68108. /**
  68109. * Gets the indirect sheen output component
  68110. */
  68111. get sheenIndirect(): NodeMaterialConnectionPoint;
  68112. /**
  68113. * Gets the indirect clear coat output component
  68114. */
  68115. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68116. /**
  68117. * Gets the refraction output component
  68118. */
  68119. get refraction(): NodeMaterialConnectionPoint;
  68120. /**
  68121. * Gets the global lighting output component
  68122. */
  68123. get lighting(): NodeMaterialConnectionPoint;
  68124. /**
  68125. * Gets the shadow output component
  68126. */
  68127. get shadow(): NodeMaterialConnectionPoint;
  68128. /**
  68129. * Gets the alpha output component
  68130. */
  68131. get alpha(): NodeMaterialConnectionPoint;
  68132. autoConfigure(material: NodeMaterial): void;
  68133. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68134. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68135. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68136. private _injectVertexCode;
  68137. /**
  68138. * Gets the code corresponding to the albedo/opacity module
  68139. * @returns the shader code
  68140. */
  68141. getAlbedoOpacityCode(): string;
  68142. protected _buildBlock(state: NodeMaterialBuildState): this;
  68143. protected _dumpPropertiesCode(): string;
  68144. serialize(): any;
  68145. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68146. }
  68147. }
  68148. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68149. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68150. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68151. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68152. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68153. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68154. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68155. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68156. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68157. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68158. }
  68159. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68160. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68161. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68162. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68163. }
  68164. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68165. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68166. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68167. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68168. /**
  68169. * Block used to compute value of one parameter modulo another
  68170. */
  68171. export class ModBlock extends NodeMaterialBlock {
  68172. /**
  68173. * Creates a new ModBlock
  68174. * @param name defines the block name
  68175. */
  68176. constructor(name: string);
  68177. /**
  68178. * Gets the current class name
  68179. * @returns the class name
  68180. */
  68181. getClassName(): string;
  68182. /**
  68183. * Gets the left operand input component
  68184. */
  68185. get left(): NodeMaterialConnectionPoint;
  68186. /**
  68187. * Gets the right operand input component
  68188. */
  68189. get right(): NodeMaterialConnectionPoint;
  68190. /**
  68191. * Gets the output component
  68192. */
  68193. get output(): NodeMaterialConnectionPoint;
  68194. protected _buildBlock(state: NodeMaterialBuildState): this;
  68195. }
  68196. }
  68197. declare module "babylonjs/Materials/Node/Blocks/index" {
  68198. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68199. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68200. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68201. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68202. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68203. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68204. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68205. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68206. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68207. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68208. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68209. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68210. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68211. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68212. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68213. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68214. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68215. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68216. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68217. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68218. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68219. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68220. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68221. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68222. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68223. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68224. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68225. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68226. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68227. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68228. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68229. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68230. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68231. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68232. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68233. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68234. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68235. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68236. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68237. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68238. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68239. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68240. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68241. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68242. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68243. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68244. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68245. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68246. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68247. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68248. }
  68249. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68250. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68251. }
  68252. declare module "babylonjs/Materials/Node/index" {
  68253. export * from "babylonjs/Materials/Node/Enums/index";
  68254. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68255. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68256. export * from "babylonjs/Materials/Node/nodeMaterial";
  68257. export * from "babylonjs/Materials/Node/Blocks/index";
  68258. export * from "babylonjs/Materials/Node/Optimizers/index";
  68259. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68260. }
  68261. declare module "babylonjs/Materials/index" {
  68262. export * from "babylonjs/Materials/Background/index";
  68263. export * from "babylonjs/Materials/colorCurves";
  68264. export * from "babylonjs/Materials/iEffectFallbacks";
  68265. export * from "babylonjs/Materials/effectFallbacks";
  68266. export * from "babylonjs/Materials/effect";
  68267. export * from "babylonjs/Materials/fresnelParameters";
  68268. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68269. export * from "babylonjs/Materials/material";
  68270. export * from "babylonjs/Materials/materialDefines";
  68271. export * from "babylonjs/Materials/thinMaterialHelper";
  68272. export * from "babylonjs/Materials/materialHelper";
  68273. export * from "babylonjs/Materials/multiMaterial";
  68274. export * from "babylonjs/Materials/PBR/index";
  68275. export * from "babylonjs/Materials/pushMaterial";
  68276. export * from "babylonjs/Materials/shaderMaterial";
  68277. export * from "babylonjs/Materials/standardMaterial";
  68278. export * from "babylonjs/Materials/Textures/index";
  68279. export * from "babylonjs/Materials/uniformBuffer";
  68280. export * from "babylonjs/Materials/materialFlags";
  68281. export * from "babylonjs/Materials/Node/index";
  68282. export * from "babylonjs/Materials/effectRenderer";
  68283. export * from "babylonjs/Materials/shadowDepthWrapper";
  68284. }
  68285. declare module "babylonjs/Maths/index" {
  68286. export * from "babylonjs/Maths/math.scalar";
  68287. export * from "babylonjs/Maths/math";
  68288. export * from "babylonjs/Maths/sphericalPolynomial";
  68289. }
  68290. declare module "babylonjs/Misc/workerPool" {
  68291. import { IDisposable } from "babylonjs/scene";
  68292. /**
  68293. * Helper class to push actions to a pool of workers.
  68294. */
  68295. export class WorkerPool implements IDisposable {
  68296. private _workerInfos;
  68297. private _pendingActions;
  68298. /**
  68299. * Constructor
  68300. * @param workers Array of workers to use for actions
  68301. */
  68302. constructor(workers: Array<Worker>);
  68303. /**
  68304. * Terminates all workers and clears any pending actions.
  68305. */
  68306. dispose(): void;
  68307. /**
  68308. * Pushes an action to the worker pool. If all the workers are active, the action will be
  68309. * pended until a worker has completed its action.
  68310. * @param action The action to perform. Call onComplete when the action is complete.
  68311. */
  68312. push(action: (worker: Worker, onComplete: () => void) => void): void;
  68313. private _execute;
  68314. }
  68315. }
  68316. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68317. import { IDisposable } from "babylonjs/scene";
  68318. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68319. /**
  68320. * Configuration for Draco compression
  68321. */
  68322. export interface IDracoCompressionConfiguration {
  68323. /**
  68324. * Configuration for the decoder.
  68325. */
  68326. decoder: {
  68327. /**
  68328. * The url to the WebAssembly module.
  68329. */
  68330. wasmUrl?: string;
  68331. /**
  68332. * The url to the WebAssembly binary.
  68333. */
  68334. wasmBinaryUrl?: string;
  68335. /**
  68336. * The url to the fallback JavaScript module.
  68337. */
  68338. fallbackUrl?: string;
  68339. };
  68340. }
  68341. /**
  68342. * Draco compression (https://google.github.io/draco/)
  68343. *
  68344. * This class wraps the Draco module.
  68345. *
  68346. * **Encoder**
  68347. *
  68348. * The encoder is not currently implemented.
  68349. *
  68350. * **Decoder**
  68351. *
  68352. * 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.
  68353. *
  68354. * To update the configuration, use the following code:
  68355. * ```javascript
  68356. * DracoCompression.Configuration = {
  68357. * decoder: {
  68358. * wasmUrl: "<url to the WebAssembly library>",
  68359. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68360. * fallbackUrl: "<url to the fallback JavaScript library>",
  68361. * }
  68362. * };
  68363. * ```
  68364. *
  68365. * 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.
  68366. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68367. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68368. *
  68369. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68370. * ```javascript
  68371. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68372. * ```
  68373. *
  68374. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68375. */
  68376. export class DracoCompression implements IDisposable {
  68377. private _workerPoolPromise?;
  68378. private _decoderModulePromise?;
  68379. /**
  68380. * The configuration. Defaults to the following urls:
  68381. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68382. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68383. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68384. */
  68385. static Configuration: IDracoCompressionConfiguration;
  68386. /**
  68387. * Returns true if the decoder configuration is available.
  68388. */
  68389. static get DecoderAvailable(): boolean;
  68390. /**
  68391. * Default number of workers to create when creating the draco compression object.
  68392. */
  68393. static DefaultNumWorkers: number;
  68394. private static GetDefaultNumWorkers;
  68395. private static _Default;
  68396. /**
  68397. * Default instance for the draco compression object.
  68398. */
  68399. static get Default(): DracoCompression;
  68400. /**
  68401. * Constructor
  68402. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68403. */
  68404. constructor(numWorkers?: number);
  68405. /**
  68406. * Stop all async operations and release resources.
  68407. */
  68408. dispose(): void;
  68409. /**
  68410. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68411. * @returns a promise that resolves when ready
  68412. */
  68413. whenReadyAsync(): Promise<void>;
  68414. /**
  68415. * Decode Draco compressed mesh data to vertex data.
  68416. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68417. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68418. * @returns A promise that resolves with the decoded vertex data
  68419. */
  68420. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68421. [kind: string]: number;
  68422. }): Promise<VertexData>;
  68423. }
  68424. }
  68425. declare module "babylonjs/Meshes/Compression/index" {
  68426. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68427. }
  68428. declare module "babylonjs/Meshes/csg" {
  68429. import { Nullable } from "babylonjs/types";
  68430. import { Scene } from "babylonjs/scene";
  68431. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68432. import { Mesh } from "babylonjs/Meshes/mesh";
  68433. import { Material } from "babylonjs/Materials/material";
  68434. /**
  68435. * Class for building Constructive Solid Geometry
  68436. */
  68437. export class CSG {
  68438. private polygons;
  68439. /**
  68440. * The world matrix
  68441. */
  68442. matrix: Matrix;
  68443. /**
  68444. * Stores the position
  68445. */
  68446. position: Vector3;
  68447. /**
  68448. * Stores the rotation
  68449. */
  68450. rotation: Vector3;
  68451. /**
  68452. * Stores the rotation quaternion
  68453. */
  68454. rotationQuaternion: Nullable<Quaternion>;
  68455. /**
  68456. * Stores the scaling vector
  68457. */
  68458. scaling: Vector3;
  68459. /**
  68460. * Convert the Mesh to CSG
  68461. * @param mesh The Mesh to convert to CSG
  68462. * @returns A new CSG from the Mesh
  68463. */
  68464. static FromMesh(mesh: Mesh): CSG;
  68465. /**
  68466. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68467. * @param polygons Polygons used to construct a CSG solid
  68468. */
  68469. private static FromPolygons;
  68470. /**
  68471. * Clones, or makes a deep copy, of the CSG
  68472. * @returns A new CSG
  68473. */
  68474. clone(): CSG;
  68475. /**
  68476. * Unions this CSG with another CSG
  68477. * @param csg The CSG to union against this CSG
  68478. * @returns The unioned CSG
  68479. */
  68480. union(csg: CSG): CSG;
  68481. /**
  68482. * Unions this CSG with another CSG in place
  68483. * @param csg The CSG to union against this CSG
  68484. */
  68485. unionInPlace(csg: CSG): void;
  68486. /**
  68487. * Subtracts this CSG with another CSG
  68488. * @param csg The CSG to subtract against this CSG
  68489. * @returns A new CSG
  68490. */
  68491. subtract(csg: CSG): CSG;
  68492. /**
  68493. * Subtracts this CSG with another CSG in place
  68494. * @param csg The CSG to subtact against this CSG
  68495. */
  68496. subtractInPlace(csg: CSG): void;
  68497. /**
  68498. * Intersect this CSG with another CSG
  68499. * @param csg The CSG to intersect against this CSG
  68500. * @returns A new CSG
  68501. */
  68502. intersect(csg: CSG): CSG;
  68503. /**
  68504. * Intersects this CSG with another CSG in place
  68505. * @param csg The CSG to intersect against this CSG
  68506. */
  68507. intersectInPlace(csg: CSG): void;
  68508. /**
  68509. * Return a new CSG solid with solid and empty space switched. This solid is
  68510. * not modified.
  68511. * @returns A new CSG solid with solid and empty space switched
  68512. */
  68513. inverse(): CSG;
  68514. /**
  68515. * Inverses the CSG in place
  68516. */
  68517. inverseInPlace(): void;
  68518. /**
  68519. * This is used to keep meshes transformations so they can be restored
  68520. * when we build back a Babylon Mesh
  68521. * NB : All CSG operations are performed in world coordinates
  68522. * @param csg The CSG to copy the transform attributes from
  68523. * @returns This CSG
  68524. */
  68525. copyTransformAttributes(csg: CSG): CSG;
  68526. /**
  68527. * Build Raw mesh from CSG
  68528. * Coordinates here are in world space
  68529. * @param name The name of the mesh geometry
  68530. * @param scene The Scene
  68531. * @param keepSubMeshes Specifies if the submeshes should be kept
  68532. * @returns A new Mesh
  68533. */
  68534. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68535. /**
  68536. * Build Mesh from CSG taking material and transforms into account
  68537. * @param name The name of the Mesh
  68538. * @param material The material of the Mesh
  68539. * @param scene The Scene
  68540. * @param keepSubMeshes Specifies if submeshes should be kept
  68541. * @returns The new Mesh
  68542. */
  68543. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68544. }
  68545. }
  68546. declare module "babylonjs/Meshes/trailMesh" {
  68547. import { Mesh } from "babylonjs/Meshes/mesh";
  68548. import { Scene } from "babylonjs/scene";
  68549. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68550. /**
  68551. * Class used to create a trail following a mesh
  68552. */
  68553. export class TrailMesh extends Mesh {
  68554. private _generator;
  68555. private _autoStart;
  68556. private _running;
  68557. private _diameter;
  68558. private _length;
  68559. private _sectionPolygonPointsCount;
  68560. private _sectionVectors;
  68561. private _sectionNormalVectors;
  68562. private _beforeRenderObserver;
  68563. /**
  68564. * @constructor
  68565. * @param name The value used by scene.getMeshByName() to do a lookup.
  68566. * @param generator The mesh or transform node to generate a trail.
  68567. * @param scene The scene to add this mesh to.
  68568. * @param diameter Diameter of trailing mesh. Default is 1.
  68569. * @param length Length of trailing mesh. Default is 60.
  68570. * @param autoStart Automatically start trailing mesh. Default true.
  68571. */
  68572. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68573. /**
  68574. * "TrailMesh"
  68575. * @returns "TrailMesh"
  68576. */
  68577. getClassName(): string;
  68578. private _createMesh;
  68579. /**
  68580. * Start trailing mesh.
  68581. */
  68582. start(): void;
  68583. /**
  68584. * Stop trailing mesh.
  68585. */
  68586. stop(): void;
  68587. /**
  68588. * Update trailing mesh geometry.
  68589. */
  68590. update(): void;
  68591. /**
  68592. * Returns a new TrailMesh object.
  68593. * @param name is a string, the name given to the new mesh
  68594. * @param newGenerator use new generator object for cloned trail mesh
  68595. * @returns a new mesh
  68596. */
  68597. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68598. /**
  68599. * Serializes this trail mesh
  68600. * @param serializationObject object to write serialization to
  68601. */
  68602. serialize(serializationObject: any): void;
  68603. /**
  68604. * Parses a serialized trail mesh
  68605. * @param parsedMesh the serialized mesh
  68606. * @param scene the scene to create the trail mesh in
  68607. * @returns the created trail mesh
  68608. */
  68609. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68610. }
  68611. }
  68612. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68613. import { Nullable } from "babylonjs/types";
  68614. import { Scene } from "babylonjs/scene";
  68615. import { Vector4 } from "babylonjs/Maths/math.vector";
  68616. import { Color4 } from "babylonjs/Maths/math.color";
  68617. import { Mesh } from "babylonjs/Meshes/mesh";
  68618. /**
  68619. * Class containing static functions to help procedurally build meshes
  68620. */
  68621. export class TiledBoxBuilder {
  68622. /**
  68623. * Creates a box mesh
  68624. * 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)
  68625. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68627. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68629. * @param name defines the name of the mesh
  68630. * @param options defines the options used to create the mesh
  68631. * @param scene defines the hosting scene
  68632. * @returns the box mesh
  68633. */
  68634. static CreateTiledBox(name: string, options: {
  68635. pattern?: number;
  68636. width?: number;
  68637. height?: number;
  68638. depth?: number;
  68639. tileSize?: number;
  68640. tileWidth?: number;
  68641. tileHeight?: number;
  68642. alignHorizontal?: number;
  68643. alignVertical?: number;
  68644. faceUV?: Vector4[];
  68645. faceColors?: Color4[];
  68646. sideOrientation?: number;
  68647. updatable?: boolean;
  68648. }, scene?: Nullable<Scene>): Mesh;
  68649. }
  68650. }
  68651. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68652. import { Vector4 } from "babylonjs/Maths/math.vector";
  68653. import { Mesh } from "babylonjs/Meshes/mesh";
  68654. /**
  68655. * Class containing static functions to help procedurally build meshes
  68656. */
  68657. export class TorusKnotBuilder {
  68658. /**
  68659. * Creates a torus knot mesh
  68660. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68661. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68662. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68663. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68667. * @param name defines the name of the mesh
  68668. * @param options defines the options used to create the mesh
  68669. * @param scene defines the hosting scene
  68670. * @returns the torus knot mesh
  68671. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68672. */
  68673. static CreateTorusKnot(name: string, options: {
  68674. radius?: number;
  68675. tube?: number;
  68676. radialSegments?: number;
  68677. tubularSegments?: number;
  68678. p?: number;
  68679. q?: number;
  68680. updatable?: boolean;
  68681. sideOrientation?: number;
  68682. frontUVs?: Vector4;
  68683. backUVs?: Vector4;
  68684. }, scene: any): Mesh;
  68685. }
  68686. }
  68687. declare module "babylonjs/Meshes/polygonMesh" {
  68688. import { Scene } from "babylonjs/scene";
  68689. import { Vector2 } from "babylonjs/Maths/math.vector";
  68690. import { Mesh } from "babylonjs/Meshes/mesh";
  68691. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68692. import { Path2 } from "babylonjs/Maths/math.path";
  68693. /**
  68694. * Polygon
  68695. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68696. */
  68697. export class Polygon {
  68698. /**
  68699. * Creates a rectangle
  68700. * @param xmin bottom X coord
  68701. * @param ymin bottom Y coord
  68702. * @param xmax top X coord
  68703. * @param ymax top Y coord
  68704. * @returns points that make the resulting rectation
  68705. */
  68706. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68707. /**
  68708. * Creates a circle
  68709. * @param radius radius of circle
  68710. * @param cx scale in x
  68711. * @param cy scale in y
  68712. * @param numberOfSides number of sides that make up the circle
  68713. * @returns points that make the resulting circle
  68714. */
  68715. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68716. /**
  68717. * Creates a polygon from input string
  68718. * @param input Input polygon data
  68719. * @returns the parsed points
  68720. */
  68721. static Parse(input: string): Vector2[];
  68722. /**
  68723. * Starts building a polygon from x and y coordinates
  68724. * @param x x coordinate
  68725. * @param y y coordinate
  68726. * @returns the started path2
  68727. */
  68728. static StartingAt(x: number, y: number): Path2;
  68729. }
  68730. /**
  68731. * Builds a polygon
  68732. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68733. */
  68734. export class PolygonMeshBuilder {
  68735. private _points;
  68736. private _outlinepoints;
  68737. private _holes;
  68738. private _name;
  68739. private _scene;
  68740. private _epoints;
  68741. private _eholes;
  68742. private _addToepoint;
  68743. /**
  68744. * Babylon reference to the earcut plugin.
  68745. */
  68746. bjsEarcut: any;
  68747. /**
  68748. * Creates a PolygonMeshBuilder
  68749. * @param name name of the builder
  68750. * @param contours Path of the polygon
  68751. * @param scene scene to add to when creating the mesh
  68752. * @param earcutInjection can be used to inject your own earcut reference
  68753. */
  68754. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  68755. /**
  68756. * Adds a whole within the polygon
  68757. * @param hole Array of points defining the hole
  68758. * @returns this
  68759. */
  68760. addHole(hole: Vector2[]): PolygonMeshBuilder;
  68761. /**
  68762. * Creates the polygon
  68763. * @param updatable If the mesh should be updatable
  68764. * @param depth The depth of the mesh created
  68765. * @returns the created mesh
  68766. */
  68767. build(updatable?: boolean, depth?: number): Mesh;
  68768. /**
  68769. * Creates the polygon
  68770. * @param depth The depth of the mesh created
  68771. * @returns the created VertexData
  68772. */
  68773. buildVertexData(depth?: number): VertexData;
  68774. /**
  68775. * Adds a side to the polygon
  68776. * @param positions points that make the polygon
  68777. * @param normals normals of the polygon
  68778. * @param uvs uvs of the polygon
  68779. * @param indices indices of the polygon
  68780. * @param bounds bounds of the polygon
  68781. * @param points points of the polygon
  68782. * @param depth depth of the polygon
  68783. * @param flip flip of the polygon
  68784. */
  68785. private addSide;
  68786. }
  68787. }
  68788. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  68789. import { Scene } from "babylonjs/scene";
  68790. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68791. import { Color4 } from "babylonjs/Maths/math.color";
  68792. import { Mesh } from "babylonjs/Meshes/mesh";
  68793. import { Nullable } from "babylonjs/types";
  68794. /**
  68795. * Class containing static functions to help procedurally build meshes
  68796. */
  68797. export class PolygonBuilder {
  68798. /**
  68799. * Creates a polygon mesh
  68800. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68801. * * 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
  68802. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68805. * * Remember you can only change the shape positions, not their number when updating a polygon
  68806. * @param name defines the name of the mesh
  68807. * @param options defines the options used to create the mesh
  68808. * @param scene defines the hosting scene
  68809. * @param earcutInjection can be used to inject your own earcut reference
  68810. * @returns the polygon mesh
  68811. */
  68812. static CreatePolygon(name: string, options: {
  68813. shape: Vector3[];
  68814. holes?: Vector3[][];
  68815. depth?: number;
  68816. faceUV?: Vector4[];
  68817. faceColors?: Color4[];
  68818. updatable?: boolean;
  68819. sideOrientation?: number;
  68820. frontUVs?: Vector4;
  68821. backUVs?: Vector4;
  68822. wrap?: boolean;
  68823. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68824. /**
  68825. * Creates an extruded polygon mesh, with depth in the Y direction.
  68826. * * 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)
  68827. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  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. * @param earcutInjection can be used to inject your own earcut reference
  68832. * @returns the polygon mesh
  68833. */
  68834. static ExtrudePolygon(name: string, options: {
  68835. shape: Vector3[];
  68836. holes?: Vector3[][];
  68837. depth?: number;
  68838. faceUV?: Vector4[];
  68839. faceColors?: Color4[];
  68840. updatable?: boolean;
  68841. sideOrientation?: number;
  68842. frontUVs?: Vector4;
  68843. backUVs?: Vector4;
  68844. wrap?: boolean;
  68845. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68846. }
  68847. }
  68848. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  68849. import { Scene } from "babylonjs/scene";
  68850. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68851. import { Mesh } from "babylonjs/Meshes/mesh";
  68852. import { Nullable } from "babylonjs/types";
  68853. /**
  68854. * Class containing static functions to help procedurally build meshes
  68855. */
  68856. export class LatheBuilder {
  68857. /**
  68858. * Creates lathe mesh.
  68859. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68860. * * 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
  68861. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68862. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68863. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68864. * * 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
  68865. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68866. * * 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
  68867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68868. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68869. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68871. * @param name defines the name of the mesh
  68872. * @param options defines the options used to create the mesh
  68873. * @param scene defines the hosting scene
  68874. * @returns the lathe mesh
  68875. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68876. */
  68877. static CreateLathe(name: string, options: {
  68878. shape: Vector3[];
  68879. radius?: number;
  68880. tessellation?: number;
  68881. clip?: number;
  68882. arc?: number;
  68883. closed?: boolean;
  68884. updatable?: boolean;
  68885. sideOrientation?: number;
  68886. frontUVs?: Vector4;
  68887. backUVs?: Vector4;
  68888. cap?: number;
  68889. invertUV?: boolean;
  68890. }, scene?: Nullable<Scene>): Mesh;
  68891. }
  68892. }
  68893. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  68894. import { Nullable } from "babylonjs/types";
  68895. import { Scene } from "babylonjs/scene";
  68896. import { Vector4 } from "babylonjs/Maths/math.vector";
  68897. import { Mesh } from "babylonjs/Meshes/mesh";
  68898. /**
  68899. * Class containing static functions to help procedurally build meshes
  68900. */
  68901. export class TiledPlaneBuilder {
  68902. /**
  68903. * Creates a tiled plane mesh
  68904. * * The parameter `pattern` will, depending on value, do nothing or
  68905. * * * flip (reflect about central vertical) alternate tiles across and up
  68906. * * * flip every tile on alternate rows
  68907. * * * rotate (180 degs) alternate tiles across and up
  68908. * * * rotate every tile on alternate rows
  68909. * * * flip and rotate alternate tiles across and up
  68910. * * * flip and rotate every tile on alternate rows
  68911. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  68912. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  68913. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68914. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68915. * * 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)
  68916. * * 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)
  68917. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68918. * @param name defines the name of the mesh
  68919. * @param options defines the options used to create the mesh
  68920. * @param scene defines the hosting scene
  68921. * @returns the box mesh
  68922. */
  68923. static CreateTiledPlane(name: string, options: {
  68924. pattern?: number;
  68925. tileSize?: number;
  68926. tileWidth?: number;
  68927. tileHeight?: number;
  68928. size?: number;
  68929. width?: number;
  68930. height?: number;
  68931. alignHorizontal?: number;
  68932. alignVertical?: number;
  68933. sideOrientation?: number;
  68934. frontUVs?: Vector4;
  68935. backUVs?: Vector4;
  68936. updatable?: boolean;
  68937. }, scene?: Nullable<Scene>): Mesh;
  68938. }
  68939. }
  68940. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  68941. import { Nullable } from "babylonjs/types";
  68942. import { Scene } from "babylonjs/scene";
  68943. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68944. import { Mesh } from "babylonjs/Meshes/mesh";
  68945. /**
  68946. * Class containing static functions to help procedurally build meshes
  68947. */
  68948. export class TubeBuilder {
  68949. /**
  68950. * Creates a tube mesh.
  68951. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68952. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68953. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68954. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68955. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68956. * * 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)
  68957. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68958. * * 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
  68959. * * 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
  68960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68962. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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 tube mesh
  68968. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68969. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68970. */
  68971. static CreateTube(name: string, options: {
  68972. path: Vector3[];
  68973. radius?: number;
  68974. tessellation?: number;
  68975. radiusFunction?: {
  68976. (i: number, distance: number): number;
  68977. };
  68978. cap?: number;
  68979. arc?: number;
  68980. updatable?: boolean;
  68981. sideOrientation?: number;
  68982. frontUVs?: Vector4;
  68983. backUVs?: Vector4;
  68984. instance?: Mesh;
  68985. invertUV?: boolean;
  68986. }, scene?: Nullable<Scene>): Mesh;
  68987. }
  68988. }
  68989. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  68990. import { Scene } from "babylonjs/scene";
  68991. import { Vector4 } from "babylonjs/Maths/math.vector";
  68992. import { Mesh } from "babylonjs/Meshes/mesh";
  68993. import { Nullable } from "babylonjs/types";
  68994. /**
  68995. * Class containing static functions to help procedurally build meshes
  68996. */
  68997. export class IcoSphereBuilder {
  68998. /**
  68999. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69000. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69001. * * 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`)
  69002. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69003. * * 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
  69004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69007. * @param name defines the name of the mesh
  69008. * @param options defines the options used to create the mesh
  69009. * @param scene defines the hosting scene
  69010. * @returns the icosahedron mesh
  69011. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69012. */
  69013. static CreateIcoSphere(name: string, options: {
  69014. radius?: number;
  69015. radiusX?: number;
  69016. radiusY?: number;
  69017. radiusZ?: number;
  69018. flat?: boolean;
  69019. subdivisions?: number;
  69020. sideOrientation?: number;
  69021. frontUVs?: Vector4;
  69022. backUVs?: Vector4;
  69023. updatable?: boolean;
  69024. }, scene?: Nullable<Scene>): Mesh;
  69025. }
  69026. }
  69027. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69028. import { Vector3 } from "babylonjs/Maths/math.vector";
  69029. import { Mesh } from "babylonjs/Meshes/mesh";
  69030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69031. /**
  69032. * Class containing static functions to help procedurally build meshes
  69033. */
  69034. export class DecalBuilder {
  69035. /**
  69036. * Creates a decal mesh.
  69037. * 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
  69038. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69039. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69040. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69041. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69042. * @param name defines the name of the mesh
  69043. * @param sourceMesh defines the mesh where the decal must be applied
  69044. * @param options defines the options used to create the mesh
  69045. * @param scene defines the hosting scene
  69046. * @returns the decal mesh
  69047. * @see https://doc.babylonjs.com/how_to/decals
  69048. */
  69049. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69050. position?: Vector3;
  69051. normal?: Vector3;
  69052. size?: Vector3;
  69053. angle?: number;
  69054. }): Mesh;
  69055. }
  69056. }
  69057. declare module "babylonjs/Meshes/meshBuilder" {
  69058. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69059. import { Nullable } from "babylonjs/types";
  69060. import { Scene } from "babylonjs/scene";
  69061. import { Mesh } from "babylonjs/Meshes/mesh";
  69062. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69063. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69065. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69066. import { Plane } from "babylonjs/Maths/math.plane";
  69067. /**
  69068. * Class containing static functions to help procedurally build meshes
  69069. */
  69070. export class MeshBuilder {
  69071. /**
  69072. * Creates a box mesh
  69073. * * The parameter `size` sets the size (float) of each box side (default 1)
  69074. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69075. * * 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)
  69076. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69078. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69080. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69081. * @param name defines the name of the mesh
  69082. * @param options defines the options used to create the mesh
  69083. * @param scene defines the hosting scene
  69084. * @returns the box mesh
  69085. */
  69086. static CreateBox(name: string, options: {
  69087. size?: number;
  69088. width?: number;
  69089. height?: number;
  69090. depth?: number;
  69091. faceUV?: Vector4[];
  69092. faceColors?: Color4[];
  69093. sideOrientation?: number;
  69094. frontUVs?: Vector4;
  69095. backUVs?: Vector4;
  69096. wrap?: boolean;
  69097. topBaseAt?: number;
  69098. bottomBaseAt?: number;
  69099. updatable?: boolean;
  69100. }, scene?: Nullable<Scene>): Mesh;
  69101. /**
  69102. * Creates a tiled box mesh
  69103. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69105. * @param name defines the name of the mesh
  69106. * @param options defines the options used to create the mesh
  69107. * @param scene defines the hosting scene
  69108. * @returns the tiled box mesh
  69109. */
  69110. static CreateTiledBox(name: string, options: {
  69111. pattern?: number;
  69112. size?: number;
  69113. width?: number;
  69114. height?: number;
  69115. depth: number;
  69116. tileSize?: number;
  69117. tileWidth?: number;
  69118. tileHeight?: number;
  69119. faceUV?: Vector4[];
  69120. faceColors?: Color4[];
  69121. alignHorizontal?: number;
  69122. alignVertical?: number;
  69123. sideOrientation?: number;
  69124. updatable?: boolean;
  69125. }, scene?: Nullable<Scene>): Mesh;
  69126. /**
  69127. * Creates a sphere mesh
  69128. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69129. * * 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`)
  69130. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69131. * * 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
  69132. * * 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)
  69133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69136. * @param name defines the name of the mesh
  69137. * @param options defines the options used to create the mesh
  69138. * @param scene defines the hosting scene
  69139. * @returns the sphere mesh
  69140. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69141. */
  69142. static CreateSphere(name: string, options: {
  69143. segments?: number;
  69144. diameter?: number;
  69145. diameterX?: number;
  69146. diameterY?: number;
  69147. diameterZ?: number;
  69148. arc?: number;
  69149. slice?: number;
  69150. sideOrientation?: number;
  69151. frontUVs?: Vector4;
  69152. backUVs?: Vector4;
  69153. updatable?: boolean;
  69154. }, scene?: Nullable<Scene>): Mesh;
  69155. /**
  69156. * Creates a plane polygonal mesh. By default, this is a disc
  69157. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69158. * * 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
  69159. * * 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
  69160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69163. * @param name defines the name of the mesh
  69164. * @param options defines the options used to create the mesh
  69165. * @param scene defines the hosting scene
  69166. * @returns the plane polygonal mesh
  69167. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69168. */
  69169. static CreateDisc(name: string, options: {
  69170. radius?: number;
  69171. tessellation?: number;
  69172. arc?: number;
  69173. updatable?: boolean;
  69174. sideOrientation?: number;
  69175. frontUVs?: Vector4;
  69176. backUVs?: Vector4;
  69177. }, scene?: Nullable<Scene>): Mesh;
  69178. /**
  69179. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69180. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69181. * * 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`)
  69182. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69183. * * 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
  69184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69187. * @param name defines the name of the mesh
  69188. * @param options defines the options used to create the mesh
  69189. * @param scene defines the hosting scene
  69190. * @returns the icosahedron mesh
  69191. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69192. */
  69193. static CreateIcoSphere(name: string, options: {
  69194. radius?: number;
  69195. radiusX?: number;
  69196. radiusY?: number;
  69197. radiusZ?: number;
  69198. flat?: boolean;
  69199. subdivisions?: number;
  69200. sideOrientation?: number;
  69201. frontUVs?: Vector4;
  69202. backUVs?: Vector4;
  69203. updatable?: boolean;
  69204. }, scene?: Nullable<Scene>): Mesh;
  69205. /**
  69206. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69207. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69208. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69209. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69210. * * 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
  69211. * * 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
  69212. * * 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
  69213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69214. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69215. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69216. * * 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
  69217. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69218. * * 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
  69219. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  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 ribbon mesh
  69225. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69226. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69227. */
  69228. static CreateRibbon(name: string, options: {
  69229. pathArray: Vector3[][];
  69230. closeArray?: boolean;
  69231. closePath?: boolean;
  69232. offset?: number;
  69233. updatable?: boolean;
  69234. sideOrientation?: number;
  69235. frontUVs?: Vector4;
  69236. backUVs?: Vector4;
  69237. instance?: Mesh;
  69238. invertUV?: boolean;
  69239. uvs?: Vector2[];
  69240. colors?: Color4[];
  69241. }, scene?: Nullable<Scene>): Mesh;
  69242. /**
  69243. * Creates a cylinder or a cone mesh
  69244. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69245. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69246. * * 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.
  69247. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69248. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69249. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69250. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69251. * * 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).
  69252. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69253. * * 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).
  69254. * * 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
  69255. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69256. * * 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
  69257. * * 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.
  69258. * * If `enclose` is false, a ring surface is one element.
  69259. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69260. * * 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
  69261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69264. * @param name defines the name of the mesh
  69265. * @param options defines the options used to create the mesh
  69266. * @param scene defines the hosting scene
  69267. * @returns the cylinder mesh
  69268. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69269. */
  69270. static CreateCylinder(name: string, options: {
  69271. height?: number;
  69272. diameterTop?: number;
  69273. diameterBottom?: number;
  69274. diameter?: number;
  69275. tessellation?: number;
  69276. subdivisions?: number;
  69277. arc?: number;
  69278. faceColors?: Color4[];
  69279. faceUV?: Vector4[];
  69280. updatable?: boolean;
  69281. hasRings?: boolean;
  69282. enclose?: boolean;
  69283. cap?: number;
  69284. sideOrientation?: number;
  69285. frontUVs?: Vector4;
  69286. backUVs?: Vector4;
  69287. }, scene?: Nullable<Scene>): Mesh;
  69288. /**
  69289. * Creates a torus mesh
  69290. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69291. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69292. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69296. * @param name defines the name of the mesh
  69297. * @param options defines the options used to create the mesh
  69298. * @param scene defines the hosting scene
  69299. * @returns the torus mesh
  69300. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69301. */
  69302. static CreateTorus(name: string, options: {
  69303. diameter?: number;
  69304. thickness?: number;
  69305. tessellation?: number;
  69306. updatable?: boolean;
  69307. sideOrientation?: number;
  69308. frontUVs?: Vector4;
  69309. backUVs?: Vector4;
  69310. }, scene?: Nullable<Scene>): Mesh;
  69311. /**
  69312. * Creates a torus knot mesh
  69313. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69314. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69315. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69316. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69318. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69320. * @param name defines the name of the mesh
  69321. * @param options defines the options used to create the mesh
  69322. * @param scene defines the hosting scene
  69323. * @returns the torus knot mesh
  69324. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69325. */
  69326. static CreateTorusKnot(name: string, options: {
  69327. radius?: number;
  69328. tube?: number;
  69329. radialSegments?: number;
  69330. tubularSegments?: number;
  69331. p?: number;
  69332. q?: number;
  69333. updatable?: boolean;
  69334. sideOrientation?: number;
  69335. frontUVs?: Vector4;
  69336. backUVs?: Vector4;
  69337. }, scene?: Nullable<Scene>): Mesh;
  69338. /**
  69339. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69340. * * 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
  69341. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69342. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69343. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69344. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69345. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69346. * * 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
  69347. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69349. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69350. * @param name defines the name of the new line system
  69351. * @param options defines the options used to create the line system
  69352. * @param scene defines the hosting scene
  69353. * @returns a new line system mesh
  69354. */
  69355. static CreateLineSystem(name: string, options: {
  69356. lines: Vector3[][];
  69357. updatable?: boolean;
  69358. instance?: Nullable<LinesMesh>;
  69359. colors?: Nullable<Color4[][]>;
  69360. useVertexAlpha?: boolean;
  69361. }, scene: Nullable<Scene>): LinesMesh;
  69362. /**
  69363. * Creates a line mesh
  69364. * 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
  69365. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69366. * * The parameter `points` is an array successive Vector3
  69367. * * 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
  69368. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69369. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69370. * * When updating an instance, remember that only point positions can change, not the number of points
  69371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69372. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69373. * @param name defines the name of the new line system
  69374. * @param options defines the options used to create the line system
  69375. * @param scene defines the hosting scene
  69376. * @returns a new line mesh
  69377. */
  69378. static CreateLines(name: string, options: {
  69379. points: Vector3[];
  69380. updatable?: boolean;
  69381. instance?: Nullable<LinesMesh>;
  69382. colors?: Color4[];
  69383. useVertexAlpha?: boolean;
  69384. }, scene?: Nullable<Scene>): LinesMesh;
  69385. /**
  69386. * Creates a dashed line mesh
  69387. * * 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
  69388. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69389. * * The parameter `points` is an array successive Vector3
  69390. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69391. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69392. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69393. * * 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
  69394. * * When updating an instance, remember that only point positions can change, not the number of points
  69395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69396. * @param name defines the name of the mesh
  69397. * @param options defines the options used to create the mesh
  69398. * @param scene defines the hosting scene
  69399. * @returns the dashed line mesh
  69400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69401. */
  69402. static CreateDashedLines(name: string, options: {
  69403. points: Vector3[];
  69404. dashSize?: number;
  69405. gapSize?: number;
  69406. dashNb?: number;
  69407. updatable?: boolean;
  69408. instance?: LinesMesh;
  69409. }, scene?: Nullable<Scene>): LinesMesh;
  69410. /**
  69411. * 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.
  69412. * * 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.
  69413. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69414. * * 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.
  69415. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69416. * * 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
  69417. * * 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
  69418. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69420. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69421. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69423. * @param name defines the name of the mesh
  69424. * @param options defines the options used to create the mesh
  69425. * @param scene defines the hosting scene
  69426. * @returns the extruded shape mesh
  69427. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69428. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69429. */
  69430. static ExtrudeShape(name: string, options: {
  69431. shape: Vector3[];
  69432. path: Vector3[];
  69433. scale?: number;
  69434. rotation?: number;
  69435. cap?: number;
  69436. updatable?: boolean;
  69437. sideOrientation?: number;
  69438. frontUVs?: Vector4;
  69439. backUVs?: Vector4;
  69440. instance?: Mesh;
  69441. invertUV?: boolean;
  69442. }, scene?: Nullable<Scene>): Mesh;
  69443. /**
  69444. * Creates an custom extruded shape mesh.
  69445. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69446. * * 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.
  69447. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69448. * * 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
  69449. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69450. * * 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
  69451. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69452. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69453. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69454. * * 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
  69455. * * 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
  69456. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69459. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69461. * @param name defines the name of the mesh
  69462. * @param options defines the options used to create the mesh
  69463. * @param scene defines the hosting scene
  69464. * @returns the custom extruded shape mesh
  69465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69466. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69468. */
  69469. static ExtrudeShapeCustom(name: string, options: {
  69470. shape: Vector3[];
  69471. path: Vector3[];
  69472. scaleFunction?: any;
  69473. rotationFunction?: any;
  69474. ribbonCloseArray?: boolean;
  69475. ribbonClosePath?: boolean;
  69476. cap?: number;
  69477. updatable?: boolean;
  69478. sideOrientation?: number;
  69479. frontUVs?: Vector4;
  69480. backUVs?: Vector4;
  69481. instance?: Mesh;
  69482. invertUV?: boolean;
  69483. }, scene?: Nullable<Scene>): Mesh;
  69484. /**
  69485. * Creates lathe mesh.
  69486. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69487. * * 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
  69488. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69489. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69490. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69491. * * 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
  69492. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69493. * * 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
  69494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69496. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69498. * @param name defines the name of the mesh
  69499. * @param options defines the options used to create the mesh
  69500. * @param scene defines the hosting scene
  69501. * @returns the lathe mesh
  69502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69503. */
  69504. static CreateLathe(name: string, options: {
  69505. shape: Vector3[];
  69506. radius?: number;
  69507. tessellation?: number;
  69508. clip?: number;
  69509. arc?: number;
  69510. closed?: boolean;
  69511. updatable?: boolean;
  69512. sideOrientation?: number;
  69513. frontUVs?: Vector4;
  69514. backUVs?: Vector4;
  69515. cap?: number;
  69516. invertUV?: boolean;
  69517. }, scene?: Nullable<Scene>): Mesh;
  69518. /**
  69519. * Creates a tiled plane mesh
  69520. * * You can set a limited pattern arrangement with the tiles
  69521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69522. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69524. * @param name defines the name of the mesh
  69525. * @param options defines the options used to create the mesh
  69526. * @param scene defines the hosting scene
  69527. * @returns the plane mesh
  69528. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69529. */
  69530. static CreateTiledPlane(name: string, options: {
  69531. pattern?: number;
  69532. tileSize?: number;
  69533. tileWidth?: number;
  69534. tileHeight?: number;
  69535. size?: number;
  69536. width?: number;
  69537. height?: number;
  69538. alignHorizontal?: number;
  69539. alignVertical?: number;
  69540. sideOrientation?: number;
  69541. frontUVs?: Vector4;
  69542. backUVs?: Vector4;
  69543. updatable?: boolean;
  69544. }, scene?: Nullable<Scene>): Mesh;
  69545. /**
  69546. * Creates a plane mesh
  69547. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69548. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69549. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69553. * @param name defines the name of the mesh
  69554. * @param options defines the options used to create the mesh
  69555. * @param scene defines the hosting scene
  69556. * @returns the plane mesh
  69557. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69558. */
  69559. static CreatePlane(name: string, options: {
  69560. size?: number;
  69561. width?: number;
  69562. height?: number;
  69563. sideOrientation?: number;
  69564. frontUVs?: Vector4;
  69565. backUVs?: Vector4;
  69566. updatable?: boolean;
  69567. sourcePlane?: Plane;
  69568. }, scene?: Nullable<Scene>): Mesh;
  69569. /**
  69570. * Creates a ground mesh
  69571. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69572. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69574. * @param name defines the name of the mesh
  69575. * @param options defines the options used to create the mesh
  69576. * @param scene defines the hosting scene
  69577. * @returns the ground mesh
  69578. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69579. */
  69580. static CreateGround(name: string, options: {
  69581. width?: number;
  69582. height?: number;
  69583. subdivisions?: number;
  69584. subdivisionsX?: number;
  69585. subdivisionsY?: number;
  69586. updatable?: boolean;
  69587. }, scene?: Nullable<Scene>): Mesh;
  69588. /**
  69589. * Creates a tiled ground mesh
  69590. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69591. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69592. * * 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
  69593. * * 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
  69594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69595. * @param name defines the name of the mesh
  69596. * @param options defines the options used to create the mesh
  69597. * @param scene defines the hosting scene
  69598. * @returns the tiled ground mesh
  69599. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69600. */
  69601. static CreateTiledGround(name: string, options: {
  69602. xmin: number;
  69603. zmin: number;
  69604. xmax: number;
  69605. zmax: number;
  69606. subdivisions?: {
  69607. w: number;
  69608. h: number;
  69609. };
  69610. precision?: {
  69611. w: number;
  69612. h: number;
  69613. };
  69614. updatable?: boolean;
  69615. }, scene?: Nullable<Scene>): Mesh;
  69616. /**
  69617. * Creates a ground mesh from a height map
  69618. * * The parameter `url` sets the URL of the height map image resource.
  69619. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69620. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69621. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69622. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69623. * * 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.
  69624. * * 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).
  69625. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69627. * @param name defines the name of the mesh
  69628. * @param url defines the url to the height map
  69629. * @param options defines the options used to create the mesh
  69630. * @param scene defines the hosting scene
  69631. * @returns the ground mesh
  69632. * @see https://doc.babylonjs.com/babylon101/height_map
  69633. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69634. */
  69635. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69636. width?: number;
  69637. height?: number;
  69638. subdivisions?: number;
  69639. minHeight?: number;
  69640. maxHeight?: number;
  69641. colorFilter?: Color3;
  69642. alphaFilter?: number;
  69643. updatable?: boolean;
  69644. onReady?: (mesh: GroundMesh) => void;
  69645. }, scene?: Nullable<Scene>): GroundMesh;
  69646. /**
  69647. * Creates a polygon mesh
  69648. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69649. * * 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
  69650. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69652. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69653. * * Remember you can only change the shape positions, not their number when updating a polygon
  69654. * @param name defines the name of the mesh
  69655. * @param options defines the options used to create the mesh
  69656. * @param scene defines the hosting scene
  69657. * @param earcutInjection can be used to inject your own earcut reference
  69658. * @returns the polygon mesh
  69659. */
  69660. static CreatePolygon(name: string, options: {
  69661. shape: Vector3[];
  69662. holes?: Vector3[][];
  69663. depth?: number;
  69664. faceUV?: Vector4[];
  69665. faceColors?: Color4[];
  69666. updatable?: boolean;
  69667. sideOrientation?: number;
  69668. frontUVs?: Vector4;
  69669. backUVs?: Vector4;
  69670. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69671. /**
  69672. * Creates an extruded polygon mesh, with depth in the Y direction.
  69673. * * 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)
  69674. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69675. * @param name defines the name of the mesh
  69676. * @param options defines the options used to create the mesh
  69677. * @param scene defines the hosting scene
  69678. * @param earcutInjection can be used to inject your own earcut reference
  69679. * @returns the polygon mesh
  69680. */
  69681. static ExtrudePolygon(name: string, options: {
  69682. shape: Vector3[];
  69683. holes?: Vector3[][];
  69684. depth?: number;
  69685. faceUV?: Vector4[];
  69686. faceColors?: Color4[];
  69687. updatable?: boolean;
  69688. sideOrientation?: number;
  69689. frontUVs?: Vector4;
  69690. backUVs?: Vector4;
  69691. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69692. /**
  69693. * Creates a tube mesh.
  69694. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69695. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69696. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69697. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69698. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69699. * * 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)
  69700. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69701. * * 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
  69702. * * 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
  69703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69704. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69705. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69707. * @param name defines the name of the mesh
  69708. * @param options defines the options used to create the mesh
  69709. * @param scene defines the hosting scene
  69710. * @returns the tube mesh
  69711. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69712. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69713. */
  69714. static CreateTube(name: string, options: {
  69715. path: Vector3[];
  69716. radius?: number;
  69717. tessellation?: number;
  69718. radiusFunction?: {
  69719. (i: number, distance: number): number;
  69720. };
  69721. cap?: number;
  69722. arc?: number;
  69723. updatable?: boolean;
  69724. sideOrientation?: number;
  69725. frontUVs?: Vector4;
  69726. backUVs?: Vector4;
  69727. instance?: Mesh;
  69728. invertUV?: boolean;
  69729. }, scene?: Nullable<Scene>): Mesh;
  69730. /**
  69731. * Creates a polyhedron mesh
  69732. * * 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
  69733. * * The parameter `size` (positive float, default 1) sets the polygon size
  69734. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69735. * * 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`
  69736. * * 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
  69737. * * 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)`)
  69738. * * 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
  69739. * * 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
  69740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69743. * @param name defines the name of the mesh
  69744. * @param options defines the options used to create the mesh
  69745. * @param scene defines the hosting scene
  69746. * @returns the polyhedron mesh
  69747. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  69748. */
  69749. static CreatePolyhedron(name: string, options: {
  69750. type?: number;
  69751. size?: number;
  69752. sizeX?: number;
  69753. sizeY?: number;
  69754. sizeZ?: number;
  69755. custom?: any;
  69756. faceUV?: Vector4[];
  69757. faceColors?: Color4[];
  69758. flat?: boolean;
  69759. updatable?: boolean;
  69760. sideOrientation?: number;
  69761. frontUVs?: Vector4;
  69762. backUVs?: Vector4;
  69763. }, scene?: Nullable<Scene>): Mesh;
  69764. /**
  69765. * Creates a decal mesh.
  69766. * 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
  69767. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69768. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69769. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69770. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69771. * @param name defines the name of the mesh
  69772. * @param sourceMesh defines the mesh where the decal must be applied
  69773. * @param options defines the options used to create the mesh
  69774. * @param scene defines the hosting scene
  69775. * @returns the decal mesh
  69776. * @see https://doc.babylonjs.com/how_to/decals
  69777. */
  69778. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69779. position?: Vector3;
  69780. normal?: Vector3;
  69781. size?: Vector3;
  69782. angle?: number;
  69783. }): Mesh;
  69784. }
  69785. }
  69786. declare module "babylonjs/Meshes/meshSimplification" {
  69787. import { Mesh } from "babylonjs/Meshes/mesh";
  69788. /**
  69789. * A simplifier interface for future simplification implementations
  69790. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69791. */
  69792. export interface ISimplifier {
  69793. /**
  69794. * Simplification of a given mesh according to the given settings.
  69795. * Since this requires computation, it is assumed that the function runs async.
  69796. * @param settings The settings of the simplification, including quality and distance
  69797. * @param successCallback A callback that will be called after the mesh was simplified.
  69798. * @param errorCallback in case of an error, this callback will be called. optional.
  69799. */
  69800. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  69801. }
  69802. /**
  69803. * Expected simplification settings.
  69804. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  69805. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69806. */
  69807. export interface ISimplificationSettings {
  69808. /**
  69809. * Gets or sets the expected quality
  69810. */
  69811. quality: number;
  69812. /**
  69813. * Gets or sets the distance when this optimized version should be used
  69814. */
  69815. distance: number;
  69816. /**
  69817. * Gets an already optimized mesh
  69818. */
  69819. optimizeMesh?: boolean;
  69820. }
  69821. /**
  69822. * Class used to specify simplification options
  69823. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69824. */
  69825. export class SimplificationSettings implements ISimplificationSettings {
  69826. /** expected quality */
  69827. quality: number;
  69828. /** distance when this optimized version should be used */
  69829. distance: number;
  69830. /** already optimized mesh */
  69831. optimizeMesh?: boolean | undefined;
  69832. /**
  69833. * Creates a SimplificationSettings
  69834. * @param quality expected quality
  69835. * @param distance distance when this optimized version should be used
  69836. * @param optimizeMesh already optimized mesh
  69837. */
  69838. constructor(
  69839. /** expected quality */
  69840. quality: number,
  69841. /** distance when this optimized version should be used */
  69842. distance: number,
  69843. /** already optimized mesh */
  69844. optimizeMesh?: boolean | undefined);
  69845. }
  69846. /**
  69847. * Interface used to define a simplification task
  69848. */
  69849. export interface ISimplificationTask {
  69850. /**
  69851. * Array of settings
  69852. */
  69853. settings: Array<ISimplificationSettings>;
  69854. /**
  69855. * Simplification type
  69856. */
  69857. simplificationType: SimplificationType;
  69858. /**
  69859. * Mesh to simplify
  69860. */
  69861. mesh: Mesh;
  69862. /**
  69863. * Callback called on success
  69864. */
  69865. successCallback?: () => void;
  69866. /**
  69867. * Defines if parallel processing can be used
  69868. */
  69869. parallelProcessing: boolean;
  69870. }
  69871. /**
  69872. * Queue used to order the simplification tasks
  69873. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69874. */
  69875. export class SimplificationQueue {
  69876. private _simplificationArray;
  69877. /**
  69878. * Gets a boolean indicating that the process is still running
  69879. */
  69880. running: boolean;
  69881. /**
  69882. * Creates a new queue
  69883. */
  69884. constructor();
  69885. /**
  69886. * Adds a new simplification task
  69887. * @param task defines a task to add
  69888. */
  69889. addTask(task: ISimplificationTask): void;
  69890. /**
  69891. * Execute next task
  69892. */
  69893. executeNext(): void;
  69894. /**
  69895. * Execute a simplification task
  69896. * @param task defines the task to run
  69897. */
  69898. runSimplification(task: ISimplificationTask): void;
  69899. private getSimplifier;
  69900. }
  69901. /**
  69902. * The implemented types of simplification
  69903. * At the moment only Quadratic Error Decimation is implemented
  69904. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69905. */
  69906. export enum SimplificationType {
  69907. /** Quadratic error decimation */
  69908. QUADRATIC = 0
  69909. }
  69910. /**
  69911. * An implementation of the Quadratic Error simplification algorithm.
  69912. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  69913. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  69914. * @author RaananW
  69915. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69916. */
  69917. export class QuadraticErrorSimplification implements ISimplifier {
  69918. private _mesh;
  69919. private triangles;
  69920. private vertices;
  69921. private references;
  69922. private _reconstructedMesh;
  69923. /** Gets or sets the number pf sync interations */
  69924. syncIterations: number;
  69925. /** Gets or sets the aggressiveness of the simplifier */
  69926. aggressiveness: number;
  69927. /** Gets or sets the number of allowed iterations for decimation */
  69928. decimationIterations: number;
  69929. /** Gets or sets the espilon to use for bounding box computation */
  69930. boundingBoxEpsilon: number;
  69931. /**
  69932. * Creates a new QuadraticErrorSimplification
  69933. * @param _mesh defines the target mesh
  69934. */
  69935. constructor(_mesh: Mesh);
  69936. /**
  69937. * Simplification of a given mesh according to the given settings.
  69938. * Since this requires computation, it is assumed that the function runs async.
  69939. * @param settings The settings of the simplification, including quality and distance
  69940. * @param successCallback A callback that will be called after the mesh was simplified.
  69941. */
  69942. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  69943. private runDecimation;
  69944. private initWithMesh;
  69945. private init;
  69946. private reconstructMesh;
  69947. private initDecimatedMesh;
  69948. private isFlipped;
  69949. private updateTriangles;
  69950. private identifyBorder;
  69951. private updateMesh;
  69952. private vertexError;
  69953. private calculateError;
  69954. }
  69955. }
  69956. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  69957. import { Scene } from "babylonjs/scene";
  69958. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  69959. import { ISceneComponent } from "babylonjs/sceneComponent";
  69960. module "babylonjs/scene" {
  69961. interface Scene {
  69962. /** @hidden (Backing field) */
  69963. _simplificationQueue: SimplificationQueue;
  69964. /**
  69965. * Gets or sets the simplification queue attached to the scene
  69966. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69967. */
  69968. simplificationQueue: SimplificationQueue;
  69969. }
  69970. }
  69971. module "babylonjs/Meshes/mesh" {
  69972. interface Mesh {
  69973. /**
  69974. * Simplify the mesh according to the given array of settings.
  69975. * Function will return immediately and will simplify async
  69976. * @param settings a collection of simplification settings
  69977. * @param parallelProcessing should all levels calculate parallel or one after the other
  69978. * @param simplificationType the type of simplification to run
  69979. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  69980. * @returns the current mesh
  69981. */
  69982. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  69983. }
  69984. }
  69985. /**
  69986. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  69987. * created in a scene
  69988. */
  69989. export class SimplicationQueueSceneComponent implements ISceneComponent {
  69990. /**
  69991. * The component name helpfull to identify the component in the list of scene components.
  69992. */
  69993. readonly name: string;
  69994. /**
  69995. * The scene the component belongs to.
  69996. */
  69997. scene: Scene;
  69998. /**
  69999. * Creates a new instance of the component for the given scene
  70000. * @param scene Defines the scene to register the component in
  70001. */
  70002. constructor(scene: Scene);
  70003. /**
  70004. * Registers the component in a given scene
  70005. */
  70006. register(): void;
  70007. /**
  70008. * Rebuilds the elements related to this component in case of
  70009. * context lost for instance.
  70010. */
  70011. rebuild(): void;
  70012. /**
  70013. * Disposes the component and the associated ressources
  70014. */
  70015. dispose(): void;
  70016. private _beforeCameraUpdate;
  70017. }
  70018. }
  70019. declare module "babylonjs/Meshes/Builders/index" {
  70020. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70021. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70022. export * from "babylonjs/Meshes/Builders/discBuilder";
  70023. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70024. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70025. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70026. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70027. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70028. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70029. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70030. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70031. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70032. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70033. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70034. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70035. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70036. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70037. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70038. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70039. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70040. }
  70041. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70042. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70043. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70044. import { Matrix } from "babylonjs/Maths/math.vector";
  70045. module "babylonjs/Meshes/mesh" {
  70046. interface Mesh {
  70047. /**
  70048. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70049. */
  70050. thinInstanceEnablePicking: boolean;
  70051. /**
  70052. * Creates a new thin instance
  70053. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70054. * @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
  70055. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70056. */
  70057. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70058. /**
  70059. * Adds the transformation (matrix) of the current mesh as a thin instance
  70060. * @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
  70061. * @returns the thin instance index number
  70062. */
  70063. thinInstanceAddSelf(refresh: boolean): number;
  70064. /**
  70065. * Registers a custom attribute to be used with thin instances
  70066. * @param kind name of the attribute
  70067. * @param stride size in floats of the attribute
  70068. */
  70069. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70070. /**
  70071. * Sets the matrix of a thin instance
  70072. * @param index index of the thin instance
  70073. * @param matrix matrix to set
  70074. * @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
  70075. */
  70076. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70077. /**
  70078. * Sets the value of a custom attribute for a thin instance
  70079. * @param kind name of the attribute
  70080. * @param index index of the thin instance
  70081. * @param value value to set
  70082. * @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
  70083. */
  70084. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70085. /**
  70086. * 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.
  70087. */
  70088. thinInstanceCount: number;
  70089. /**
  70090. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70091. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70092. * @param buffer buffer to set
  70093. * @param stride size in floats of each value of the buffer
  70094. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70095. */
  70096. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70097. /**
  70098. * Gets the list of world matrices
  70099. * @return an array containing all the world matrices from the thin instances
  70100. */
  70101. thinInstanceGetWorldMatrices(): Matrix[];
  70102. /**
  70103. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70104. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70105. */
  70106. thinInstanceBufferUpdated(kind: string): void;
  70107. /**
  70108. * Refreshes the bounding info, taking into account all the thin instances defined
  70109. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70110. */
  70111. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70112. /** @hidden */
  70113. _thinInstanceInitializeUserStorage(): void;
  70114. /** @hidden */
  70115. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70116. /** @hidden */
  70117. _userThinInstanceBuffersStorage: {
  70118. data: {
  70119. [key: string]: Float32Array;
  70120. };
  70121. sizes: {
  70122. [key: string]: number;
  70123. };
  70124. vertexBuffers: {
  70125. [key: string]: Nullable<VertexBuffer>;
  70126. };
  70127. strides: {
  70128. [key: string]: number;
  70129. };
  70130. };
  70131. }
  70132. }
  70133. }
  70134. declare module "babylonjs/Meshes/index" {
  70135. export * from "babylonjs/Meshes/abstractMesh";
  70136. export * from "babylonjs/Meshes/buffer";
  70137. export * from "babylonjs/Meshes/Compression/index";
  70138. export * from "babylonjs/Meshes/csg";
  70139. export * from "babylonjs/Meshes/geometry";
  70140. export * from "babylonjs/Meshes/groundMesh";
  70141. export * from "babylonjs/Meshes/trailMesh";
  70142. export * from "babylonjs/Meshes/instancedMesh";
  70143. export * from "babylonjs/Meshes/linesMesh";
  70144. export * from "babylonjs/Meshes/mesh";
  70145. export * from "babylonjs/Meshes/mesh.vertexData";
  70146. export * from "babylonjs/Meshes/meshBuilder";
  70147. export * from "babylonjs/Meshes/meshSimplification";
  70148. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70149. export * from "babylonjs/Meshes/polygonMesh";
  70150. export * from "babylonjs/Meshes/subMesh";
  70151. export * from "babylonjs/Meshes/meshLODLevel";
  70152. export * from "babylonjs/Meshes/transformNode";
  70153. export * from "babylonjs/Meshes/Builders/index";
  70154. export * from "babylonjs/Meshes/dataBuffer";
  70155. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70156. import "babylonjs/Meshes/thinInstanceMesh";
  70157. export * from "babylonjs/Meshes/thinInstanceMesh";
  70158. }
  70159. declare module "babylonjs/Morph/index" {
  70160. export * from "babylonjs/Morph/morphTarget";
  70161. export * from "babylonjs/Morph/morphTargetManager";
  70162. }
  70163. declare module "babylonjs/Navigation/INavigationEngine" {
  70164. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70165. import { Vector3 } from "babylonjs/Maths/math";
  70166. import { Mesh } from "babylonjs/Meshes/mesh";
  70167. import { Scene } from "babylonjs/scene";
  70168. /**
  70169. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70170. */
  70171. export interface INavigationEnginePlugin {
  70172. /**
  70173. * plugin name
  70174. */
  70175. name: string;
  70176. /**
  70177. * Creates a navigation mesh
  70178. * @param meshes array of all the geometry used to compute the navigatio mesh
  70179. * @param parameters bunch of parameters used to filter geometry
  70180. */
  70181. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70182. /**
  70183. * Create a navigation mesh debug mesh
  70184. * @param scene is where the mesh will be added
  70185. * @returns debug display mesh
  70186. */
  70187. createDebugNavMesh(scene: Scene): Mesh;
  70188. /**
  70189. * Get a navigation mesh constrained position, closest to the parameter position
  70190. * @param position world position
  70191. * @returns the closest point to position constrained by the navigation mesh
  70192. */
  70193. getClosestPoint(position: Vector3): Vector3;
  70194. /**
  70195. * Get a navigation mesh constrained position, closest to the parameter position
  70196. * @param position world position
  70197. * @param result output the closest point to position constrained by the navigation mesh
  70198. */
  70199. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70200. /**
  70201. * Get a navigation mesh constrained position, within a particular radius
  70202. * @param position world position
  70203. * @param maxRadius the maximum distance to the constrained world position
  70204. * @returns the closest point to position constrained by the navigation mesh
  70205. */
  70206. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70207. /**
  70208. * Get a navigation mesh constrained position, within a particular radius
  70209. * @param position world position
  70210. * @param maxRadius the maximum distance to the constrained world position
  70211. * @param result output the closest point to position constrained by the navigation mesh
  70212. */
  70213. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70214. /**
  70215. * Compute the final position from a segment made of destination-position
  70216. * @param position world position
  70217. * @param destination world position
  70218. * @returns the resulting point along the navmesh
  70219. */
  70220. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70221. /**
  70222. * Compute the final position from a segment made of destination-position
  70223. * @param position world position
  70224. * @param destination world position
  70225. * @param result output the resulting point along the navmesh
  70226. */
  70227. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70228. /**
  70229. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70230. * @param start world position
  70231. * @param end world position
  70232. * @returns array containing world position composing the path
  70233. */
  70234. computePath(start: Vector3, end: Vector3): Vector3[];
  70235. /**
  70236. * If this plugin is supported
  70237. * @returns true if plugin is supported
  70238. */
  70239. isSupported(): boolean;
  70240. /**
  70241. * Create a new Crowd so you can add agents
  70242. * @param maxAgents the maximum agent count in the crowd
  70243. * @param maxAgentRadius the maximum radius an agent can have
  70244. * @param scene to attach the crowd to
  70245. * @returns the crowd you can add agents to
  70246. */
  70247. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70248. /**
  70249. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70250. * The queries will try to find a solution within those bounds
  70251. * default is (1,1,1)
  70252. * @param extent x,y,z value that define the extent around the queries point of reference
  70253. */
  70254. setDefaultQueryExtent(extent: Vector3): void;
  70255. /**
  70256. * Get the Bounding box extent specified by setDefaultQueryExtent
  70257. * @returns the box extent values
  70258. */
  70259. getDefaultQueryExtent(): Vector3;
  70260. /**
  70261. * build the navmesh from a previously saved state using getNavmeshData
  70262. * @param data the Uint8Array returned by getNavmeshData
  70263. */
  70264. buildFromNavmeshData(data: Uint8Array): void;
  70265. /**
  70266. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70267. * @returns data the Uint8Array that can be saved and reused
  70268. */
  70269. getNavmeshData(): Uint8Array;
  70270. /**
  70271. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70272. * @param result output the box extent values
  70273. */
  70274. getDefaultQueryExtentToRef(result: Vector3): void;
  70275. /**
  70276. * Release all resources
  70277. */
  70278. dispose(): void;
  70279. }
  70280. /**
  70281. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70282. */
  70283. export interface ICrowd {
  70284. /**
  70285. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70286. * You can attach anything to that node. The node position is updated in the scene update tick.
  70287. * @param pos world position that will be constrained by the navigation mesh
  70288. * @param parameters agent parameters
  70289. * @param transform hooked to the agent that will be update by the scene
  70290. * @returns agent index
  70291. */
  70292. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70293. /**
  70294. * Returns the agent position in world space
  70295. * @param index agent index returned by addAgent
  70296. * @returns world space position
  70297. */
  70298. getAgentPosition(index: number): Vector3;
  70299. /**
  70300. * Gets the agent position result in world space
  70301. * @param index agent index returned by addAgent
  70302. * @param result output world space position
  70303. */
  70304. getAgentPositionToRef(index: number, result: Vector3): void;
  70305. /**
  70306. * Gets the agent velocity in world space
  70307. * @param index agent index returned by addAgent
  70308. * @returns world space velocity
  70309. */
  70310. getAgentVelocity(index: number): Vector3;
  70311. /**
  70312. * Gets the agent velocity result in world space
  70313. * @param index agent index returned by addAgent
  70314. * @param result output world space velocity
  70315. */
  70316. getAgentVelocityToRef(index: number, result: Vector3): void;
  70317. /**
  70318. * remove a particular agent previously created
  70319. * @param index agent index returned by addAgent
  70320. */
  70321. removeAgent(index: number): void;
  70322. /**
  70323. * get the list of all agents attached to this crowd
  70324. * @returns list of agent indices
  70325. */
  70326. getAgents(): number[];
  70327. /**
  70328. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70329. * @param deltaTime in seconds
  70330. */
  70331. update(deltaTime: number): void;
  70332. /**
  70333. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70334. * @param index agent index returned by addAgent
  70335. * @param destination targeted world position
  70336. */
  70337. agentGoto(index: number, destination: Vector3): void;
  70338. /**
  70339. * Teleport the agent to a new position
  70340. * @param index agent index returned by addAgent
  70341. * @param destination targeted world position
  70342. */
  70343. agentTeleport(index: number, destination: Vector3): void;
  70344. /**
  70345. * Update agent parameters
  70346. * @param index agent index returned by addAgent
  70347. * @param parameters agent parameters
  70348. */
  70349. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70350. /**
  70351. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70352. * The queries will try to find a solution within those bounds
  70353. * default is (1,1,1)
  70354. * @param extent x,y,z value that define the extent around the queries point of reference
  70355. */
  70356. setDefaultQueryExtent(extent: Vector3): void;
  70357. /**
  70358. * Get the Bounding box extent specified by setDefaultQueryExtent
  70359. * @returns the box extent values
  70360. */
  70361. getDefaultQueryExtent(): Vector3;
  70362. /**
  70363. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70364. * @param result output the box extent values
  70365. */
  70366. getDefaultQueryExtentToRef(result: Vector3): void;
  70367. /**
  70368. * Release all resources
  70369. */
  70370. dispose(): void;
  70371. }
  70372. /**
  70373. * Configures an agent
  70374. */
  70375. export interface IAgentParameters {
  70376. /**
  70377. * Agent radius. [Limit: >= 0]
  70378. */
  70379. radius: number;
  70380. /**
  70381. * Agent height. [Limit: > 0]
  70382. */
  70383. height: number;
  70384. /**
  70385. * Maximum allowed acceleration. [Limit: >= 0]
  70386. */
  70387. maxAcceleration: number;
  70388. /**
  70389. * Maximum allowed speed. [Limit: >= 0]
  70390. */
  70391. maxSpeed: number;
  70392. /**
  70393. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70394. */
  70395. collisionQueryRange: number;
  70396. /**
  70397. * The path visibility optimization range. [Limit: > 0]
  70398. */
  70399. pathOptimizationRange: number;
  70400. /**
  70401. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70402. */
  70403. separationWeight: number;
  70404. }
  70405. /**
  70406. * Configures the navigation mesh creation
  70407. */
  70408. export interface INavMeshParameters {
  70409. /**
  70410. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70411. */
  70412. cs: number;
  70413. /**
  70414. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70415. */
  70416. ch: number;
  70417. /**
  70418. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70419. */
  70420. walkableSlopeAngle: number;
  70421. /**
  70422. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70423. * be considered walkable. [Limit: >= 3] [Units: vx]
  70424. */
  70425. walkableHeight: number;
  70426. /**
  70427. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70428. */
  70429. walkableClimb: number;
  70430. /**
  70431. * The distance to erode/shrink the walkable area of the heightfield away from
  70432. * obstructions. [Limit: >=0] [Units: vx]
  70433. */
  70434. walkableRadius: number;
  70435. /**
  70436. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70437. */
  70438. maxEdgeLen: number;
  70439. /**
  70440. * The maximum distance a simplfied contour's border edges should deviate
  70441. * the original raw contour. [Limit: >=0] [Units: vx]
  70442. */
  70443. maxSimplificationError: number;
  70444. /**
  70445. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70446. */
  70447. minRegionArea: number;
  70448. /**
  70449. * Any regions with a span count smaller than this value will, if possible,
  70450. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70451. */
  70452. mergeRegionArea: number;
  70453. /**
  70454. * The maximum number of vertices allowed for polygons generated during the
  70455. * contour to polygon conversion process. [Limit: >= 3]
  70456. */
  70457. maxVertsPerPoly: number;
  70458. /**
  70459. * Sets the sampling distance to use when generating the detail mesh.
  70460. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70461. */
  70462. detailSampleDist: number;
  70463. /**
  70464. * The maximum distance the detail mesh surface should deviate from heightfield
  70465. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70466. */
  70467. detailSampleMaxError: number;
  70468. }
  70469. }
  70470. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70471. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70472. import { Mesh } from "babylonjs/Meshes/mesh";
  70473. import { Scene } from "babylonjs/scene";
  70474. import { Vector3 } from "babylonjs/Maths/math";
  70475. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70476. /**
  70477. * RecastJS navigation plugin
  70478. */
  70479. export class RecastJSPlugin implements INavigationEnginePlugin {
  70480. /**
  70481. * Reference to the Recast library
  70482. */
  70483. bjsRECAST: any;
  70484. /**
  70485. * plugin name
  70486. */
  70487. name: string;
  70488. /**
  70489. * the first navmesh created. We might extend this to support multiple navmeshes
  70490. */
  70491. navMesh: any;
  70492. /**
  70493. * Initializes the recastJS plugin
  70494. * @param recastInjection can be used to inject your own recast reference
  70495. */
  70496. constructor(recastInjection?: any);
  70497. /**
  70498. * Creates a navigation mesh
  70499. * @param meshes array of all the geometry used to compute the navigatio mesh
  70500. * @param parameters bunch of parameters used to filter geometry
  70501. */
  70502. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70503. /**
  70504. * Create a navigation mesh debug mesh
  70505. * @param scene is where the mesh will be added
  70506. * @returns debug display mesh
  70507. */
  70508. createDebugNavMesh(scene: Scene): Mesh;
  70509. /**
  70510. * Get a navigation mesh constrained position, closest to the parameter position
  70511. * @param position world position
  70512. * @returns the closest point to position constrained by the navigation mesh
  70513. */
  70514. getClosestPoint(position: Vector3): Vector3;
  70515. /**
  70516. * Get a navigation mesh constrained position, closest to the parameter position
  70517. * @param position world position
  70518. * @param result output the closest point to position constrained by the navigation mesh
  70519. */
  70520. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70521. /**
  70522. * Get a navigation mesh constrained position, within a particular radius
  70523. * @param position world position
  70524. * @param maxRadius the maximum distance to the constrained world position
  70525. * @returns the closest point to position constrained by the navigation mesh
  70526. */
  70527. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70528. /**
  70529. * Get a navigation mesh constrained position, within a particular radius
  70530. * @param position world position
  70531. * @param maxRadius the maximum distance to the constrained world position
  70532. * @param result output the closest point to position constrained by the navigation mesh
  70533. */
  70534. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70535. /**
  70536. * Compute the final position from a segment made of destination-position
  70537. * @param position world position
  70538. * @param destination world position
  70539. * @returns the resulting point along the navmesh
  70540. */
  70541. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70542. /**
  70543. * Compute the final position from a segment made of destination-position
  70544. * @param position world position
  70545. * @param destination world position
  70546. * @param result output the resulting point along the navmesh
  70547. */
  70548. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70549. /**
  70550. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70551. * @param start world position
  70552. * @param end world position
  70553. * @returns array containing world position composing the path
  70554. */
  70555. computePath(start: Vector3, end: Vector3): Vector3[];
  70556. /**
  70557. * Create a new Crowd so you can add agents
  70558. * @param maxAgents the maximum agent count in the crowd
  70559. * @param maxAgentRadius the maximum radius an agent can have
  70560. * @param scene to attach the crowd to
  70561. * @returns the crowd you can add agents to
  70562. */
  70563. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70564. /**
  70565. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70566. * The queries will try to find a solution within those bounds
  70567. * default is (1,1,1)
  70568. * @param extent x,y,z value that define the extent around the queries point of reference
  70569. */
  70570. setDefaultQueryExtent(extent: Vector3): void;
  70571. /**
  70572. * Get the Bounding box extent specified by setDefaultQueryExtent
  70573. * @returns the box extent values
  70574. */
  70575. getDefaultQueryExtent(): Vector3;
  70576. /**
  70577. * build the navmesh from a previously saved state using getNavmeshData
  70578. * @param data the Uint8Array returned by getNavmeshData
  70579. */
  70580. buildFromNavmeshData(data: Uint8Array): void;
  70581. /**
  70582. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70583. * @returns data the Uint8Array that can be saved and reused
  70584. */
  70585. getNavmeshData(): Uint8Array;
  70586. /**
  70587. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70588. * @param result output the box extent values
  70589. */
  70590. getDefaultQueryExtentToRef(result: Vector3): void;
  70591. /**
  70592. * Disposes
  70593. */
  70594. dispose(): void;
  70595. /**
  70596. * If this plugin is supported
  70597. * @returns true if plugin is supported
  70598. */
  70599. isSupported(): boolean;
  70600. }
  70601. /**
  70602. * Recast detour crowd implementation
  70603. */
  70604. export class RecastJSCrowd implements ICrowd {
  70605. /**
  70606. * Recast/detour plugin
  70607. */
  70608. bjsRECASTPlugin: RecastJSPlugin;
  70609. /**
  70610. * Link to the detour crowd
  70611. */
  70612. recastCrowd: any;
  70613. /**
  70614. * One transform per agent
  70615. */
  70616. transforms: TransformNode[];
  70617. /**
  70618. * All agents created
  70619. */
  70620. agents: number[];
  70621. /**
  70622. * Link to the scene is kept to unregister the crowd from the scene
  70623. */
  70624. private _scene;
  70625. /**
  70626. * Observer for crowd updates
  70627. */
  70628. private _onBeforeAnimationsObserver;
  70629. /**
  70630. * Constructor
  70631. * @param plugin recastJS plugin
  70632. * @param maxAgents the maximum agent count in the crowd
  70633. * @param maxAgentRadius the maximum radius an agent can have
  70634. * @param scene to attach the crowd to
  70635. * @returns the crowd you can add agents to
  70636. */
  70637. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70638. /**
  70639. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70640. * You can attach anything to that node. The node position is updated in the scene update tick.
  70641. * @param pos world position that will be constrained by the navigation mesh
  70642. * @param parameters agent parameters
  70643. * @param transform hooked to the agent that will be update by the scene
  70644. * @returns agent index
  70645. */
  70646. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70647. /**
  70648. * Returns the agent position in world space
  70649. * @param index agent index returned by addAgent
  70650. * @returns world space position
  70651. */
  70652. getAgentPosition(index: number): Vector3;
  70653. /**
  70654. * Returns the agent position result in world space
  70655. * @param index agent index returned by addAgent
  70656. * @param result output world space position
  70657. */
  70658. getAgentPositionToRef(index: number, result: Vector3): void;
  70659. /**
  70660. * Returns the agent velocity in world space
  70661. * @param index agent index returned by addAgent
  70662. * @returns world space velocity
  70663. */
  70664. getAgentVelocity(index: number): Vector3;
  70665. /**
  70666. * Returns the agent velocity result in world space
  70667. * @param index agent index returned by addAgent
  70668. * @param result output world space velocity
  70669. */
  70670. getAgentVelocityToRef(index: number, result: Vector3): void;
  70671. /**
  70672. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70673. * @param index agent index returned by addAgent
  70674. * @param destination targeted world position
  70675. */
  70676. agentGoto(index: number, destination: Vector3): void;
  70677. /**
  70678. * Teleport the agent to a new position
  70679. * @param index agent index returned by addAgent
  70680. * @param destination targeted world position
  70681. */
  70682. agentTeleport(index: number, destination: Vector3): void;
  70683. /**
  70684. * Update agent parameters
  70685. * @param index agent index returned by addAgent
  70686. * @param parameters agent parameters
  70687. */
  70688. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70689. /**
  70690. * remove a particular agent previously created
  70691. * @param index agent index returned by addAgent
  70692. */
  70693. removeAgent(index: number): void;
  70694. /**
  70695. * get the list of all agents attached to this crowd
  70696. * @returns list of agent indices
  70697. */
  70698. getAgents(): number[];
  70699. /**
  70700. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70701. * @param deltaTime in seconds
  70702. */
  70703. update(deltaTime: number): void;
  70704. /**
  70705. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70706. * The queries will try to find a solution within those bounds
  70707. * default is (1,1,1)
  70708. * @param extent x,y,z value that define the extent around the queries point of reference
  70709. */
  70710. setDefaultQueryExtent(extent: Vector3): void;
  70711. /**
  70712. * Get the Bounding box extent specified by setDefaultQueryExtent
  70713. * @returns the box extent values
  70714. */
  70715. getDefaultQueryExtent(): Vector3;
  70716. /**
  70717. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70718. * @param result output the box extent values
  70719. */
  70720. getDefaultQueryExtentToRef(result: Vector3): void;
  70721. /**
  70722. * Release all resources
  70723. */
  70724. dispose(): void;
  70725. }
  70726. }
  70727. declare module "babylonjs/Navigation/Plugins/index" {
  70728. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  70729. }
  70730. declare module "babylonjs/Navigation/index" {
  70731. export * from "babylonjs/Navigation/INavigationEngine";
  70732. export * from "babylonjs/Navigation/Plugins/index";
  70733. }
  70734. declare module "babylonjs/Offline/database" {
  70735. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  70736. /**
  70737. * Class used to enable access to IndexedDB
  70738. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70739. */
  70740. export class Database implements IOfflineProvider {
  70741. private _callbackManifestChecked;
  70742. private _currentSceneUrl;
  70743. private _db;
  70744. private _enableSceneOffline;
  70745. private _enableTexturesOffline;
  70746. private _manifestVersionFound;
  70747. private _mustUpdateRessources;
  70748. private _hasReachedQuota;
  70749. private _isSupported;
  70750. private _idbFactory;
  70751. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  70752. private static IsUASupportingBlobStorage;
  70753. /**
  70754. * Gets a boolean indicating if Database storate is enabled (off by default)
  70755. */
  70756. static IDBStorageEnabled: boolean;
  70757. /**
  70758. * Gets a boolean indicating if scene must be saved in the database
  70759. */
  70760. get enableSceneOffline(): boolean;
  70761. /**
  70762. * Gets a boolean indicating if textures must be saved in the database
  70763. */
  70764. get enableTexturesOffline(): boolean;
  70765. /**
  70766. * Creates a new Database
  70767. * @param urlToScene defines the url to load the scene
  70768. * @param callbackManifestChecked defines the callback to use when manifest is checked
  70769. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  70770. */
  70771. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  70772. private static _ParseURL;
  70773. private static _ReturnFullUrlLocation;
  70774. private _checkManifestFile;
  70775. /**
  70776. * Open the database and make it available
  70777. * @param successCallback defines the callback to call on success
  70778. * @param errorCallback defines the callback to call on error
  70779. */
  70780. open(successCallback: () => void, errorCallback: () => void): void;
  70781. /**
  70782. * Loads an image from the database
  70783. * @param url defines the url to load from
  70784. * @param image defines the target DOM image
  70785. */
  70786. loadImage(url: string, image: HTMLImageElement): void;
  70787. private _loadImageFromDBAsync;
  70788. private _saveImageIntoDBAsync;
  70789. private _checkVersionFromDB;
  70790. private _loadVersionFromDBAsync;
  70791. private _saveVersionIntoDBAsync;
  70792. /**
  70793. * Loads a file from database
  70794. * @param url defines the URL to load from
  70795. * @param sceneLoaded defines a callback to call on success
  70796. * @param progressCallBack defines a callback to call when progress changed
  70797. * @param errorCallback defines a callback to call on error
  70798. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70799. */
  70800. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70801. private _loadFileAsync;
  70802. private _saveFileAsync;
  70803. /**
  70804. * Validates if xhr data is correct
  70805. * @param xhr defines the request to validate
  70806. * @param dataType defines the expected data type
  70807. * @returns true if data is correct
  70808. */
  70809. private static _ValidateXHRData;
  70810. }
  70811. }
  70812. declare module "babylonjs/Offline/index" {
  70813. export * from "babylonjs/Offline/database";
  70814. export * from "babylonjs/Offline/IOfflineProvider";
  70815. }
  70816. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  70817. /** @hidden */
  70818. export var gpuUpdateParticlesPixelShader: {
  70819. name: string;
  70820. shader: string;
  70821. };
  70822. }
  70823. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  70824. /** @hidden */
  70825. export var gpuUpdateParticlesVertexShader: {
  70826. name: string;
  70827. shader: string;
  70828. };
  70829. }
  70830. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  70831. /** @hidden */
  70832. export var clipPlaneFragmentDeclaration2: {
  70833. name: string;
  70834. shader: string;
  70835. };
  70836. }
  70837. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  70838. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  70839. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  70840. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70841. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  70842. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  70843. /** @hidden */
  70844. export var gpuRenderParticlesPixelShader: {
  70845. name: string;
  70846. shader: string;
  70847. };
  70848. }
  70849. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  70850. /** @hidden */
  70851. export var clipPlaneVertexDeclaration2: {
  70852. name: string;
  70853. shader: string;
  70854. };
  70855. }
  70856. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  70857. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  70858. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  70859. /** @hidden */
  70860. export var gpuRenderParticlesVertexShader: {
  70861. name: string;
  70862. shader: string;
  70863. };
  70864. }
  70865. declare module "babylonjs/Particles/gpuParticleSystem" {
  70866. import { Nullable } from "babylonjs/types";
  70867. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  70868. import { Observable } from "babylonjs/Misc/observable";
  70869. import { Matrix } from "babylonjs/Maths/math.vector";
  70870. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70871. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70872. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  70873. import { IDisposable } from "babylonjs/scene";
  70874. import { Effect } from "babylonjs/Materials/effect";
  70875. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70876. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70877. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  70878. import { Scene } from "babylonjs/scene";
  70879. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  70880. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  70881. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  70882. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  70883. /**
  70884. * This represents a GPU particle system in Babylon
  70885. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  70886. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  70887. */
  70888. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  70889. /**
  70890. * The layer mask we are rendering the particles through.
  70891. */
  70892. layerMask: number;
  70893. private _capacity;
  70894. private _activeCount;
  70895. private _currentActiveCount;
  70896. private _accumulatedCount;
  70897. private _renderEffect;
  70898. private _updateEffect;
  70899. private _buffer0;
  70900. private _buffer1;
  70901. private _spriteBuffer;
  70902. private _updateVAO;
  70903. private _renderVAO;
  70904. private _targetIndex;
  70905. private _sourceBuffer;
  70906. private _targetBuffer;
  70907. private _currentRenderId;
  70908. private _started;
  70909. private _stopped;
  70910. private _timeDelta;
  70911. private _randomTexture;
  70912. private _randomTexture2;
  70913. private _attributesStrideSize;
  70914. private _updateEffectOptions;
  70915. private _randomTextureSize;
  70916. private _actualFrame;
  70917. private _customEffect;
  70918. private readonly _rawTextureWidth;
  70919. /**
  70920. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  70921. */
  70922. static get IsSupported(): boolean;
  70923. /**
  70924. * An event triggered when the system is disposed.
  70925. */
  70926. onDisposeObservable: Observable<IParticleSystem>;
  70927. /**
  70928. * Gets the maximum number of particles active at the same time.
  70929. * @returns The max number of active particles.
  70930. */
  70931. getCapacity(): number;
  70932. /**
  70933. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70934. * to override the particles.
  70935. */
  70936. forceDepthWrite: boolean;
  70937. /**
  70938. * Gets or set the number of active particles
  70939. */
  70940. get activeParticleCount(): number;
  70941. set activeParticleCount(value: number);
  70942. private _preWarmDone;
  70943. /**
  70944. * Specifies if the particles are updated in emitter local space or world space.
  70945. */
  70946. isLocal: boolean;
  70947. /** Gets or sets a matrix to use to compute projection */
  70948. defaultProjectionMatrix: Matrix;
  70949. /**
  70950. * Is this system ready to be used/rendered
  70951. * @return true if the system is ready
  70952. */
  70953. isReady(): boolean;
  70954. /**
  70955. * Gets if the system has been started. (Note: this will still be true after stop is called)
  70956. * @returns True if it has been started, otherwise false.
  70957. */
  70958. isStarted(): boolean;
  70959. /**
  70960. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  70961. * @returns True if it has been stopped, otherwise false.
  70962. */
  70963. isStopped(): boolean;
  70964. /**
  70965. * Gets a boolean indicating that the system is stopping
  70966. * @returns true if the system is currently stopping
  70967. */
  70968. isStopping(): boolean;
  70969. /**
  70970. * Gets the number of particles active at the same time.
  70971. * @returns The number of active particles.
  70972. */
  70973. getActiveCount(): number;
  70974. /**
  70975. * Starts the particle system and begins to emit
  70976. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70977. */
  70978. start(delay?: number): void;
  70979. /**
  70980. * Stops the particle system.
  70981. */
  70982. stop(): void;
  70983. /**
  70984. * Remove all active particles
  70985. */
  70986. reset(): void;
  70987. /**
  70988. * Returns the string "GPUParticleSystem"
  70989. * @returns a string containing the class name
  70990. */
  70991. getClassName(): string;
  70992. /**
  70993. * Gets the custom effect used to render the particles
  70994. * @param blendMode Blend mode for which the effect should be retrieved
  70995. * @returns The effect
  70996. */
  70997. getCustomEffect(blendMode?: number): Nullable<Effect>;
  70998. /**
  70999. * Sets the custom effect used to render the particles
  71000. * @param effect The effect to set
  71001. * @param blendMode Blend mode for which the effect should be set
  71002. */
  71003. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71004. /** @hidden */
  71005. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71006. /**
  71007. * Observable that will be called just before the particles are drawn
  71008. */
  71009. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71010. /**
  71011. * Gets the name of the particle vertex shader
  71012. */
  71013. get vertexShaderName(): string;
  71014. private _colorGradientsTexture;
  71015. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71016. /**
  71017. * Adds a new color gradient
  71018. * @param gradient defines the gradient to use (between 0 and 1)
  71019. * @param color1 defines the color to affect to the specified gradient
  71020. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71021. * @returns the current particle system
  71022. */
  71023. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71024. private _refreshColorGradient;
  71025. /** Force the system to rebuild all gradients that need to be resync */
  71026. forceRefreshGradients(): void;
  71027. /**
  71028. * Remove a specific color gradient
  71029. * @param gradient defines the gradient to remove
  71030. * @returns the current particle system
  71031. */
  71032. removeColorGradient(gradient: number): GPUParticleSystem;
  71033. private _angularSpeedGradientsTexture;
  71034. private _sizeGradientsTexture;
  71035. private _velocityGradientsTexture;
  71036. private _limitVelocityGradientsTexture;
  71037. private _dragGradientsTexture;
  71038. private _addFactorGradient;
  71039. /**
  71040. * Adds a new size gradient
  71041. * @param gradient defines the gradient to use (between 0 and 1)
  71042. * @param factor defines the size factor to affect to the specified gradient
  71043. * @returns the current particle system
  71044. */
  71045. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71046. /**
  71047. * Remove a specific size gradient
  71048. * @param gradient defines the gradient to remove
  71049. * @returns the current particle system
  71050. */
  71051. removeSizeGradient(gradient: number): GPUParticleSystem;
  71052. private _refreshFactorGradient;
  71053. /**
  71054. * Adds a new angular speed gradient
  71055. * @param gradient defines the gradient to use (between 0 and 1)
  71056. * @param factor defines the angular speed to affect to the specified gradient
  71057. * @returns the current particle system
  71058. */
  71059. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71060. /**
  71061. * Remove a specific angular speed gradient
  71062. * @param gradient defines the gradient to remove
  71063. * @returns the current particle system
  71064. */
  71065. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71066. /**
  71067. * Adds a new velocity gradient
  71068. * @param gradient defines the gradient to use (between 0 and 1)
  71069. * @param factor defines the velocity to affect to the specified gradient
  71070. * @returns the current particle system
  71071. */
  71072. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71073. /**
  71074. * Remove a specific velocity gradient
  71075. * @param gradient defines the gradient to remove
  71076. * @returns the current particle system
  71077. */
  71078. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71079. /**
  71080. * Adds a new limit velocity gradient
  71081. * @param gradient defines the gradient to use (between 0 and 1)
  71082. * @param factor defines the limit velocity value to affect to the specified gradient
  71083. * @returns the current particle system
  71084. */
  71085. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71086. /**
  71087. * Remove a specific limit velocity gradient
  71088. * @param gradient defines the gradient to remove
  71089. * @returns the current particle system
  71090. */
  71091. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71092. /**
  71093. * Adds a new drag gradient
  71094. * @param gradient defines the gradient to use (between 0 and 1)
  71095. * @param factor defines the drag value to affect to the specified gradient
  71096. * @returns the current particle system
  71097. */
  71098. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71099. /**
  71100. * Remove a specific drag gradient
  71101. * @param gradient defines the gradient to remove
  71102. * @returns the current particle system
  71103. */
  71104. removeDragGradient(gradient: number): GPUParticleSystem;
  71105. /**
  71106. * Not supported by GPUParticleSystem
  71107. * @param gradient defines the gradient to use (between 0 and 1)
  71108. * @param factor defines the emit rate value to affect to the specified gradient
  71109. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71110. * @returns the current particle system
  71111. */
  71112. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71113. /**
  71114. * Not supported by GPUParticleSystem
  71115. * @param gradient defines the gradient to remove
  71116. * @returns the current particle system
  71117. */
  71118. removeEmitRateGradient(gradient: number): IParticleSystem;
  71119. /**
  71120. * Not supported by GPUParticleSystem
  71121. * @param gradient defines the gradient to use (between 0 and 1)
  71122. * @param factor defines the start size value to affect to the specified gradient
  71123. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71124. * @returns the current particle system
  71125. */
  71126. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71127. /**
  71128. * Not supported by GPUParticleSystem
  71129. * @param gradient defines the gradient to remove
  71130. * @returns the current particle system
  71131. */
  71132. removeStartSizeGradient(gradient: number): IParticleSystem;
  71133. /**
  71134. * Not supported by GPUParticleSystem
  71135. * @param gradient defines the gradient to use (between 0 and 1)
  71136. * @param min defines the color remap minimal range
  71137. * @param max defines the color remap maximal range
  71138. * @returns the current particle system
  71139. */
  71140. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71141. /**
  71142. * Not supported by GPUParticleSystem
  71143. * @param gradient defines the gradient to remove
  71144. * @returns the current particle system
  71145. */
  71146. removeColorRemapGradient(): IParticleSystem;
  71147. /**
  71148. * Not supported by GPUParticleSystem
  71149. * @param gradient defines the gradient to use (between 0 and 1)
  71150. * @param min defines the alpha remap minimal range
  71151. * @param max defines the alpha remap maximal range
  71152. * @returns the current particle system
  71153. */
  71154. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71155. /**
  71156. * Not supported by GPUParticleSystem
  71157. * @param gradient defines the gradient to remove
  71158. * @returns the current particle system
  71159. */
  71160. removeAlphaRemapGradient(): IParticleSystem;
  71161. /**
  71162. * Not supported by GPUParticleSystem
  71163. * @param gradient defines the gradient to use (between 0 and 1)
  71164. * @param color defines the color to affect to the specified gradient
  71165. * @returns the current particle system
  71166. */
  71167. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71168. /**
  71169. * Not supported by GPUParticleSystem
  71170. * @param gradient defines the gradient to remove
  71171. * @returns the current particle system
  71172. */
  71173. removeRampGradient(): IParticleSystem;
  71174. /**
  71175. * Not supported by GPUParticleSystem
  71176. * @returns the list of ramp gradients
  71177. */
  71178. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71179. /**
  71180. * Not supported by GPUParticleSystem
  71181. * Gets or sets a boolean indicating that ramp gradients must be used
  71182. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71183. */
  71184. get useRampGradients(): boolean;
  71185. set useRampGradients(value: boolean);
  71186. /**
  71187. * Not supported by GPUParticleSystem
  71188. * @param gradient defines the gradient to use (between 0 and 1)
  71189. * @param factor defines the life time factor to affect to the specified gradient
  71190. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71191. * @returns the current particle system
  71192. */
  71193. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71194. /**
  71195. * Not supported by GPUParticleSystem
  71196. * @param gradient defines the gradient to remove
  71197. * @returns the current particle system
  71198. */
  71199. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71200. /**
  71201. * Instantiates a GPU particle system.
  71202. * 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.
  71203. * @param name The name of the particle system
  71204. * @param options The options used to create the system
  71205. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71206. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71207. * @param customEffect a custom effect used to change the way particles are rendered by default
  71208. */
  71209. constructor(name: string, options: Partial<{
  71210. capacity: number;
  71211. randomTextureSize: number;
  71212. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71213. protected _reset(): void;
  71214. private _createUpdateVAO;
  71215. private _createRenderVAO;
  71216. private _initialize;
  71217. /** @hidden */
  71218. _recreateUpdateEffect(): void;
  71219. private _getEffect;
  71220. /**
  71221. * Fill the defines array according to the current settings of the particle system
  71222. * @param defines Array to be updated
  71223. * @param blendMode blend mode to take into account when updating the array
  71224. */
  71225. fillDefines(defines: Array<string>, blendMode?: number): void;
  71226. /**
  71227. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71228. * @param uniforms Uniforms array to fill
  71229. * @param attributes Attributes array to fill
  71230. * @param samplers Samplers array to fill
  71231. */
  71232. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71233. /** @hidden */
  71234. _recreateRenderEffect(): Effect;
  71235. /**
  71236. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71237. * @param preWarm defines if we are in the pre-warmimg phase
  71238. */
  71239. animate(preWarm?: boolean): void;
  71240. private _createFactorGradientTexture;
  71241. private _createSizeGradientTexture;
  71242. private _createAngularSpeedGradientTexture;
  71243. private _createVelocityGradientTexture;
  71244. private _createLimitVelocityGradientTexture;
  71245. private _createDragGradientTexture;
  71246. private _createColorGradientTexture;
  71247. /**
  71248. * Renders the particle system in its current state
  71249. * @param preWarm defines if the system should only update the particles but not render them
  71250. * @returns the current number of particles
  71251. */
  71252. render(preWarm?: boolean): number;
  71253. /**
  71254. * Rebuilds the particle system
  71255. */
  71256. rebuild(): void;
  71257. private _releaseBuffers;
  71258. private _releaseVAOs;
  71259. /**
  71260. * Disposes the particle system and free the associated resources
  71261. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71262. */
  71263. dispose(disposeTexture?: boolean): void;
  71264. /**
  71265. * Clones the particle system.
  71266. * @param name The name of the cloned object
  71267. * @param newEmitter The new emitter to use
  71268. * @returns the cloned particle system
  71269. */
  71270. clone(name: string, newEmitter: any): GPUParticleSystem;
  71271. /**
  71272. * Serializes the particle system to a JSON object
  71273. * @param serializeTexture defines if the texture must be serialized as well
  71274. * @returns the JSON object
  71275. */
  71276. serialize(serializeTexture?: boolean): any;
  71277. /**
  71278. * Parses a JSON object to create a GPU particle system.
  71279. * @param parsedParticleSystem The JSON object to parse
  71280. * @param sceneOrEngine The scene or the engine to create the particle system in
  71281. * @param rootUrl The root url to use to load external dependencies like texture
  71282. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71283. * @returns the parsed GPU particle system
  71284. */
  71285. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71286. }
  71287. }
  71288. declare module "babylonjs/Particles/particleSystemSet" {
  71289. import { Nullable } from "babylonjs/types";
  71290. import { Color3 } from "babylonjs/Maths/math.color";
  71291. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71293. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71294. import { Scene, IDisposable } from "babylonjs/scene";
  71295. /**
  71296. * Represents a set of particle systems working together to create a specific effect
  71297. */
  71298. export class ParticleSystemSet implements IDisposable {
  71299. /**
  71300. * Gets or sets base Assets URL
  71301. */
  71302. static BaseAssetsUrl: string;
  71303. private _emitterCreationOptions;
  71304. private _emitterNode;
  71305. /**
  71306. * Gets the particle system list
  71307. */
  71308. systems: IParticleSystem[];
  71309. /**
  71310. * Gets the emitter node used with this set
  71311. */
  71312. get emitterNode(): Nullable<TransformNode>;
  71313. /**
  71314. * Creates a new emitter mesh as a sphere
  71315. * @param options defines the options used to create the sphere
  71316. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71317. * @param scene defines the hosting scene
  71318. */
  71319. setEmitterAsSphere(options: {
  71320. diameter: number;
  71321. segments: number;
  71322. color: Color3;
  71323. }, renderingGroupId: number, scene: Scene): void;
  71324. /**
  71325. * Starts all particle systems of the set
  71326. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71327. */
  71328. start(emitter?: AbstractMesh): void;
  71329. /**
  71330. * Release all associated resources
  71331. */
  71332. dispose(): void;
  71333. /**
  71334. * Serialize the set into a JSON compatible object
  71335. * @param serializeTexture defines if the texture must be serialized as well
  71336. * @returns a JSON compatible representation of the set
  71337. */
  71338. serialize(serializeTexture?: boolean): any;
  71339. /**
  71340. * Parse a new ParticleSystemSet from a serialized source
  71341. * @param data defines a JSON compatible representation of the set
  71342. * @param scene defines the hosting scene
  71343. * @param gpu defines if we want GPU particles or CPU particles
  71344. * @returns a new ParticleSystemSet
  71345. */
  71346. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71347. }
  71348. }
  71349. declare module "babylonjs/Particles/particleHelper" {
  71350. import { Nullable } from "babylonjs/types";
  71351. import { Scene } from "babylonjs/scene";
  71352. import { Vector3 } from "babylonjs/Maths/math.vector";
  71353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71354. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71355. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71356. /**
  71357. * This class is made for on one-liner static method to help creating particle system set.
  71358. */
  71359. export class ParticleHelper {
  71360. /**
  71361. * Gets or sets base Assets URL
  71362. */
  71363. static BaseAssetsUrl: string;
  71364. /** Define the Url to load snippets */
  71365. static SnippetUrl: string;
  71366. /**
  71367. * Create a default particle system that you can tweak
  71368. * @param emitter defines the emitter to use
  71369. * @param capacity defines the system capacity (default is 500 particles)
  71370. * @param scene defines the hosting scene
  71371. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71372. * @returns the new Particle system
  71373. */
  71374. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71375. /**
  71376. * This is the main static method (one-liner) of this helper to create different particle systems
  71377. * @param type This string represents the type to the particle system to create
  71378. * @param scene The scene where the particle system should live
  71379. * @param gpu If the system will use gpu
  71380. * @returns the ParticleSystemSet created
  71381. */
  71382. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71383. /**
  71384. * Static function used to export a particle system to a ParticleSystemSet variable.
  71385. * Please note that the emitter shape is not exported
  71386. * @param systems defines the particle systems to export
  71387. * @returns the created particle system set
  71388. */
  71389. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71390. /**
  71391. * Creates a particle system from a snippet saved in a remote file
  71392. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71393. * @param url defines the url to load from
  71394. * @param scene defines the hosting scene
  71395. * @param gpu If the system will use gpu
  71396. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71397. * @returns a promise that will resolve to the new particle system
  71398. */
  71399. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71400. /**
  71401. * Creates a particle system from a snippet saved by the particle system editor
  71402. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71403. * @param scene defines the hosting scene
  71404. * @param gpu If the system will use gpu
  71405. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71406. * @returns a promise that will resolve to the new particle system
  71407. */
  71408. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71409. }
  71410. }
  71411. declare module "babylonjs/Particles/particleSystemComponent" {
  71412. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71413. import { Effect } from "babylonjs/Materials/effect";
  71414. import "babylonjs/Shaders/particles.vertex";
  71415. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71416. module "babylonjs/Engines/engine" {
  71417. interface Engine {
  71418. /**
  71419. * Create an effect to use with particle systems.
  71420. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71421. * the particle system for which you want to create a custom effect in the last parameter
  71422. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71423. * @param uniformsNames defines a list of attribute names
  71424. * @param samplers defines an array of string used to represent textures
  71425. * @param defines defines the string containing the defines to use to compile the shaders
  71426. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71427. * @param onCompiled defines a function to call when the effect creation is successful
  71428. * @param onError defines a function to call when the effect creation has failed
  71429. * @param particleSystem the particle system you want to create the effect for
  71430. * @returns the new Effect
  71431. */
  71432. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71433. }
  71434. }
  71435. module "babylonjs/Meshes/mesh" {
  71436. interface Mesh {
  71437. /**
  71438. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71439. * @returns an array of IParticleSystem
  71440. */
  71441. getEmittedParticleSystems(): IParticleSystem[];
  71442. /**
  71443. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71444. * @returns an array of IParticleSystem
  71445. */
  71446. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71447. }
  71448. }
  71449. }
  71450. declare module "babylonjs/Particles/pointsCloudSystem" {
  71451. import { Color4 } from "babylonjs/Maths/math";
  71452. import { Mesh } from "babylonjs/Meshes/mesh";
  71453. import { Scene, IDisposable } from "babylonjs/scene";
  71454. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71455. /** Defines the 4 color options */
  71456. export enum PointColor {
  71457. /** color value */
  71458. Color = 2,
  71459. /** uv value */
  71460. UV = 1,
  71461. /** random value */
  71462. Random = 0,
  71463. /** stated value */
  71464. Stated = 3
  71465. }
  71466. /**
  71467. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71468. * 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.
  71469. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71470. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71471. *
  71472. * Full documentation here : TO BE ENTERED
  71473. */
  71474. export class PointsCloudSystem implements IDisposable {
  71475. /**
  71476. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71477. * Example : var p = SPS.particles[i];
  71478. */
  71479. particles: CloudPoint[];
  71480. /**
  71481. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71482. */
  71483. nbParticles: number;
  71484. /**
  71485. * This a counter for your own usage. It's not set by any SPS functions.
  71486. */
  71487. counter: number;
  71488. /**
  71489. * The PCS name. This name is also given to the underlying mesh.
  71490. */
  71491. name: string;
  71492. /**
  71493. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71494. */
  71495. mesh: Mesh;
  71496. /**
  71497. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71498. * Please read :
  71499. */
  71500. vars: any;
  71501. /**
  71502. * @hidden
  71503. */
  71504. _size: number;
  71505. private _scene;
  71506. private _promises;
  71507. private _positions;
  71508. private _indices;
  71509. private _normals;
  71510. private _colors;
  71511. private _uvs;
  71512. private _indices32;
  71513. private _positions32;
  71514. private _colors32;
  71515. private _uvs32;
  71516. private _updatable;
  71517. private _isVisibilityBoxLocked;
  71518. private _alwaysVisible;
  71519. private _groups;
  71520. private _groupCounter;
  71521. private _computeParticleColor;
  71522. private _computeParticleTexture;
  71523. private _computeParticleRotation;
  71524. private _computeBoundingBox;
  71525. private _isReady;
  71526. /**
  71527. * Creates a PCS (Points Cloud System) object
  71528. * @param name (String) is the PCS name, this will be the underlying mesh name
  71529. * @param pointSize (number) is the size for each point
  71530. * @param scene (Scene) is the scene in which the PCS is added
  71531. * @param options defines the options of the PCS e.g.
  71532. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71533. */
  71534. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71535. updatable?: boolean;
  71536. });
  71537. /**
  71538. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71539. * If no points were added to the PCS, the returned mesh is just a single point.
  71540. * @returns a promise for the created mesh
  71541. */
  71542. buildMeshAsync(): Promise<Mesh>;
  71543. /**
  71544. * @hidden
  71545. */
  71546. private _buildMesh;
  71547. private _addParticle;
  71548. private _randomUnitVector;
  71549. private _getColorIndicesForCoord;
  71550. private _setPointsColorOrUV;
  71551. private _colorFromTexture;
  71552. private _calculateDensity;
  71553. /**
  71554. * Adds points to the PCS in random positions within a unit sphere
  71555. * @param nb (positive integer) the number of particles to be created from this model
  71556. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71557. * @returns the number of groups in the system
  71558. */
  71559. addPoints(nb: number, pointFunction?: any): number;
  71560. /**
  71561. * Adds points to the PCS from the surface of the model shape
  71562. * @param mesh is any Mesh object that will be used as a surface model for the points
  71563. * @param nb (positive integer) the number of particles to be created from this model
  71564. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71565. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71566. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71567. * @returns the number of groups in the system
  71568. */
  71569. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71570. /**
  71571. * Adds points to the PCS inside the model shape
  71572. * @param mesh is any Mesh object that will be used as a surface model for the points
  71573. * @param nb (positive integer) the number of particles to be created from this model
  71574. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71575. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71576. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71577. * @returns the number of groups in the system
  71578. */
  71579. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71580. /**
  71581. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71582. * This method calls `updateParticle()` for each particle of the SPS.
  71583. * For an animated SPS, it is usually called within the render loop.
  71584. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71585. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71586. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71587. * @returns the PCS.
  71588. */
  71589. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71590. /**
  71591. * Disposes the PCS.
  71592. */
  71593. dispose(): void;
  71594. /**
  71595. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71596. * doc :
  71597. * @returns the PCS.
  71598. */
  71599. refreshVisibleSize(): PointsCloudSystem;
  71600. /**
  71601. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71602. * @param size the size (float) of the visibility box
  71603. * note : this doesn't lock the PCS mesh bounding box.
  71604. * doc :
  71605. */
  71606. setVisibilityBox(size: number): void;
  71607. /**
  71608. * Gets whether the PCS is always visible or not
  71609. * doc :
  71610. */
  71611. get isAlwaysVisible(): boolean;
  71612. /**
  71613. * Sets the PCS as always visible or not
  71614. * doc :
  71615. */
  71616. set isAlwaysVisible(val: boolean);
  71617. /**
  71618. * Tells to `setParticles()` to compute the particle rotations or not
  71619. * Default value : false. The PCS is faster when it's set to false
  71620. * Note : particle rotations are only applied to parent particles
  71621. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71622. */
  71623. set computeParticleRotation(val: boolean);
  71624. /**
  71625. * Tells to `setParticles()` to compute the particle colors or not.
  71626. * Default value : true. The PCS is faster when it's set to false.
  71627. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71628. */
  71629. set computeParticleColor(val: boolean);
  71630. set computeParticleTexture(val: boolean);
  71631. /**
  71632. * Gets if `setParticles()` computes the particle colors or not.
  71633. * Default value : false. The PCS is faster when it's set to false.
  71634. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71635. */
  71636. get computeParticleColor(): boolean;
  71637. /**
  71638. * Gets if `setParticles()` computes the particle textures or not.
  71639. * Default value : false. The PCS is faster when it's set to false.
  71640. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71641. */
  71642. get computeParticleTexture(): boolean;
  71643. /**
  71644. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71645. */
  71646. set computeBoundingBox(val: boolean);
  71647. /**
  71648. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71649. */
  71650. get computeBoundingBox(): boolean;
  71651. /**
  71652. * This function does nothing. It may be overwritten to set all the particle first values.
  71653. * The PCS doesn't call this function, you may have to call it by your own.
  71654. * doc :
  71655. */
  71656. initParticles(): void;
  71657. /**
  71658. * This function does nothing. It may be overwritten to recycle a particle
  71659. * The PCS doesn't call this function, you can to call it
  71660. * doc :
  71661. * @param particle The particle to recycle
  71662. * @returns the recycled particle
  71663. */
  71664. recycleParticle(particle: CloudPoint): CloudPoint;
  71665. /**
  71666. * Updates a particle : this function should be overwritten by the user.
  71667. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71668. * doc :
  71669. * @example : just set a particle position or velocity and recycle conditions
  71670. * @param particle The particle to update
  71671. * @returns the updated particle
  71672. */
  71673. updateParticle(particle: CloudPoint): CloudPoint;
  71674. /**
  71675. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71676. * This does nothing and may be overwritten by the user.
  71677. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71678. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71679. * @param update the boolean update value actually passed to setParticles()
  71680. */
  71681. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71682. /**
  71683. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71684. * This will be passed three parameters.
  71685. * This does nothing and may be overwritten by the user.
  71686. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71687. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71688. * @param update the boolean update value actually passed to setParticles()
  71689. */
  71690. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71691. }
  71692. }
  71693. declare module "babylonjs/Particles/cloudPoint" {
  71694. import { Nullable } from "babylonjs/types";
  71695. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71696. import { Mesh } from "babylonjs/Meshes/mesh";
  71697. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71698. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71699. /**
  71700. * Represents one particle of a points cloud system.
  71701. */
  71702. export class CloudPoint {
  71703. /**
  71704. * particle global index
  71705. */
  71706. idx: number;
  71707. /**
  71708. * The color of the particle
  71709. */
  71710. color: Nullable<Color4>;
  71711. /**
  71712. * The world space position of the particle.
  71713. */
  71714. position: Vector3;
  71715. /**
  71716. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71717. */
  71718. rotation: Vector3;
  71719. /**
  71720. * The world space rotation quaternion of the particle.
  71721. */
  71722. rotationQuaternion: Nullable<Quaternion>;
  71723. /**
  71724. * The uv of the particle.
  71725. */
  71726. uv: Nullable<Vector2>;
  71727. /**
  71728. * The current speed of the particle.
  71729. */
  71730. velocity: Vector3;
  71731. /**
  71732. * The pivot point in the particle local space.
  71733. */
  71734. pivot: Vector3;
  71735. /**
  71736. * Must the particle be translated from its pivot point in its local space ?
  71737. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  71738. * Default : false
  71739. */
  71740. translateFromPivot: boolean;
  71741. /**
  71742. * Index of this particle in the global "positions" array (Internal use)
  71743. * @hidden
  71744. */
  71745. _pos: number;
  71746. /**
  71747. * @hidden Index of this particle in the global "indices" array (Internal use)
  71748. */
  71749. _ind: number;
  71750. /**
  71751. * Group this particle belongs to
  71752. */
  71753. _group: PointsGroup;
  71754. /**
  71755. * Group id of this particle
  71756. */
  71757. groupId: number;
  71758. /**
  71759. * Index of the particle in its group id (Internal use)
  71760. */
  71761. idxInGroup: number;
  71762. /**
  71763. * @hidden Particle BoundingInfo object (Internal use)
  71764. */
  71765. _boundingInfo: BoundingInfo;
  71766. /**
  71767. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  71768. */
  71769. _pcs: PointsCloudSystem;
  71770. /**
  71771. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  71772. */
  71773. _stillInvisible: boolean;
  71774. /**
  71775. * @hidden Last computed particle rotation matrix
  71776. */
  71777. _rotationMatrix: number[];
  71778. /**
  71779. * Parent particle Id, if any.
  71780. * Default null.
  71781. */
  71782. parentId: Nullable<number>;
  71783. /**
  71784. * @hidden Internal global position in the PCS.
  71785. */
  71786. _globalPosition: Vector3;
  71787. /**
  71788. * Creates a Point Cloud object.
  71789. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  71790. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  71791. * @param group (PointsGroup) is the group the particle belongs to
  71792. * @param groupId (integer) is the group identifier in the PCS.
  71793. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  71794. * @param pcs defines the PCS it is associated to
  71795. */
  71796. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  71797. /**
  71798. * get point size
  71799. */
  71800. get size(): Vector3;
  71801. /**
  71802. * Set point size
  71803. */
  71804. set size(scale: Vector3);
  71805. /**
  71806. * Legacy support, changed quaternion to rotationQuaternion
  71807. */
  71808. get quaternion(): Nullable<Quaternion>;
  71809. /**
  71810. * Legacy support, changed quaternion to rotationQuaternion
  71811. */
  71812. set quaternion(q: Nullable<Quaternion>);
  71813. /**
  71814. * Returns a boolean. True if the particle intersects a mesh, else false
  71815. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  71816. * @param target is the object (point or mesh) what the intersection is computed against
  71817. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  71818. * @returns true if it intersects
  71819. */
  71820. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  71821. /**
  71822. * get the rotation matrix of the particle
  71823. * @hidden
  71824. */
  71825. getRotationMatrix(m: Matrix): void;
  71826. }
  71827. /**
  71828. * Represents a group of points in a points cloud system
  71829. * * PCS internal tool, don't use it manually.
  71830. */
  71831. export class PointsGroup {
  71832. /**
  71833. * The group id
  71834. * @hidden
  71835. */
  71836. groupID: number;
  71837. /**
  71838. * image data for group (internal use)
  71839. * @hidden
  71840. */
  71841. _groupImageData: Nullable<ArrayBufferView>;
  71842. /**
  71843. * Image Width (internal use)
  71844. * @hidden
  71845. */
  71846. _groupImgWidth: number;
  71847. /**
  71848. * Image Height (internal use)
  71849. * @hidden
  71850. */
  71851. _groupImgHeight: number;
  71852. /**
  71853. * Custom position function (internal use)
  71854. * @hidden
  71855. */
  71856. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  71857. /**
  71858. * density per facet for surface points
  71859. * @hidden
  71860. */
  71861. _groupDensity: number[];
  71862. /**
  71863. * Only when points are colored by texture carries pointer to texture list array
  71864. * @hidden
  71865. */
  71866. _textureNb: number;
  71867. /**
  71868. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  71869. * PCS internal tool, don't use it manually.
  71870. * @hidden
  71871. */
  71872. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  71873. }
  71874. }
  71875. declare module "babylonjs/Particles/index" {
  71876. export * from "babylonjs/Particles/baseParticleSystem";
  71877. export * from "babylonjs/Particles/EmitterTypes/index";
  71878. export * from "babylonjs/Particles/gpuParticleSystem";
  71879. export * from "babylonjs/Particles/IParticleSystem";
  71880. export * from "babylonjs/Particles/particle";
  71881. export * from "babylonjs/Particles/particleHelper";
  71882. export * from "babylonjs/Particles/particleSystem";
  71883. import "babylonjs/Particles/particleSystemComponent";
  71884. export * from "babylonjs/Particles/particleSystemComponent";
  71885. export * from "babylonjs/Particles/particleSystemSet";
  71886. export * from "babylonjs/Particles/solidParticle";
  71887. export * from "babylonjs/Particles/solidParticleSystem";
  71888. export * from "babylonjs/Particles/cloudPoint";
  71889. export * from "babylonjs/Particles/pointsCloudSystem";
  71890. export * from "babylonjs/Particles/subEmitter";
  71891. }
  71892. declare module "babylonjs/Physics/physicsEngineComponent" {
  71893. import { Nullable } from "babylonjs/types";
  71894. import { Observable, Observer } from "babylonjs/Misc/observable";
  71895. import { Vector3 } from "babylonjs/Maths/math.vector";
  71896. import { Mesh } from "babylonjs/Meshes/mesh";
  71897. import { ISceneComponent } from "babylonjs/sceneComponent";
  71898. import { Scene } from "babylonjs/scene";
  71899. import { Node } from "babylonjs/node";
  71900. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  71901. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71902. module "babylonjs/scene" {
  71903. interface Scene {
  71904. /** @hidden (Backing field) */
  71905. _physicsEngine: Nullable<IPhysicsEngine>;
  71906. /** @hidden */
  71907. _physicsTimeAccumulator: number;
  71908. /**
  71909. * Gets the current physics engine
  71910. * @returns a IPhysicsEngine or null if none attached
  71911. */
  71912. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  71913. /**
  71914. * Enables physics to the current scene
  71915. * @param gravity defines the scene's gravity for the physics engine
  71916. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  71917. * @return a boolean indicating if the physics engine was initialized
  71918. */
  71919. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  71920. /**
  71921. * Disables and disposes the physics engine associated with the scene
  71922. */
  71923. disablePhysicsEngine(): void;
  71924. /**
  71925. * Gets a boolean indicating if there is an active physics engine
  71926. * @returns a boolean indicating if there is an active physics engine
  71927. */
  71928. isPhysicsEnabled(): boolean;
  71929. /**
  71930. * Deletes a physics compound impostor
  71931. * @param compound defines the compound to delete
  71932. */
  71933. deleteCompoundImpostor(compound: any): void;
  71934. /**
  71935. * An event triggered when physic simulation is about to be run
  71936. */
  71937. onBeforePhysicsObservable: Observable<Scene>;
  71938. /**
  71939. * An event triggered when physic simulation has been done
  71940. */
  71941. onAfterPhysicsObservable: Observable<Scene>;
  71942. }
  71943. }
  71944. module "babylonjs/Meshes/abstractMesh" {
  71945. interface AbstractMesh {
  71946. /** @hidden */
  71947. _physicsImpostor: Nullable<PhysicsImpostor>;
  71948. /**
  71949. * Gets or sets impostor used for physic simulation
  71950. * @see https://doc.babylonjs.com/features/physics_engine
  71951. */
  71952. physicsImpostor: Nullable<PhysicsImpostor>;
  71953. /**
  71954. * Gets the current physics impostor
  71955. * @see https://doc.babylonjs.com/features/physics_engine
  71956. * @returns a physics impostor or null
  71957. */
  71958. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  71959. /** Apply a physic impulse to the mesh
  71960. * @param force defines the force to apply
  71961. * @param contactPoint defines where to apply the force
  71962. * @returns the current mesh
  71963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  71964. */
  71965. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  71966. /**
  71967. * Creates a physic joint between two meshes
  71968. * @param otherMesh defines the other mesh to use
  71969. * @param pivot1 defines the pivot to use on this mesh
  71970. * @param pivot2 defines the pivot to use on the other mesh
  71971. * @param options defines additional options (can be plugin dependent)
  71972. * @returns the current mesh
  71973. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  71974. */
  71975. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  71976. /** @hidden */
  71977. _disposePhysicsObserver: Nullable<Observer<Node>>;
  71978. }
  71979. }
  71980. /**
  71981. * Defines the physics engine scene component responsible to manage a physics engine
  71982. */
  71983. export class PhysicsEngineSceneComponent implements ISceneComponent {
  71984. /**
  71985. * The component name helpful to identify the component in the list of scene components.
  71986. */
  71987. readonly name: string;
  71988. /**
  71989. * The scene the component belongs to.
  71990. */
  71991. scene: Scene;
  71992. /**
  71993. * Creates a new instance of the component for the given scene
  71994. * @param scene Defines the scene to register the component in
  71995. */
  71996. constructor(scene: Scene);
  71997. /**
  71998. * Registers the component in a given scene
  71999. */
  72000. register(): void;
  72001. /**
  72002. * Rebuilds the elements related to this component in case of
  72003. * context lost for instance.
  72004. */
  72005. rebuild(): void;
  72006. /**
  72007. * Disposes the component and the associated ressources
  72008. */
  72009. dispose(): void;
  72010. }
  72011. }
  72012. declare module "babylonjs/Physics/physicsHelper" {
  72013. import { Nullable } from "babylonjs/types";
  72014. import { Vector3 } from "babylonjs/Maths/math.vector";
  72015. import { Mesh } from "babylonjs/Meshes/mesh";
  72016. import { Scene } from "babylonjs/scene";
  72017. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72018. /**
  72019. * A helper for physics simulations
  72020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72021. */
  72022. export class PhysicsHelper {
  72023. private _scene;
  72024. private _physicsEngine;
  72025. /**
  72026. * Initializes the Physics helper
  72027. * @param scene Babylon.js scene
  72028. */
  72029. constructor(scene: Scene);
  72030. /**
  72031. * Applies a radial explosion impulse
  72032. * @param origin the origin of the explosion
  72033. * @param radiusOrEventOptions the radius or the options of radial explosion
  72034. * @param strength the explosion strength
  72035. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72036. * @returns A physics radial explosion event, or null
  72037. */
  72038. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72039. /**
  72040. * Applies a radial explosion force
  72041. * @param origin the origin of the explosion
  72042. * @param radiusOrEventOptions the radius or the options of radial explosion
  72043. * @param strength the explosion strength
  72044. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72045. * @returns A physics radial explosion event, or null
  72046. */
  72047. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72048. /**
  72049. * Creates a gravitational field
  72050. * @param origin the origin of the explosion
  72051. * @param radiusOrEventOptions the radius or the options of radial explosion
  72052. * @param strength the explosion strength
  72053. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72054. * @returns A physics gravitational field event, or null
  72055. */
  72056. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72057. /**
  72058. * Creates a physics updraft event
  72059. * @param origin the origin of the updraft
  72060. * @param radiusOrEventOptions the radius or the options of the updraft
  72061. * @param strength the strength of the updraft
  72062. * @param height the height of the updraft
  72063. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72064. * @returns A physics updraft event, or null
  72065. */
  72066. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72067. /**
  72068. * Creates a physics vortex event
  72069. * @param origin the of the vortex
  72070. * @param radiusOrEventOptions the radius or the options of the vortex
  72071. * @param strength the strength of the vortex
  72072. * @param height the height of the vortex
  72073. * @returns a Physics vortex event, or null
  72074. * A physics vortex event or null
  72075. */
  72076. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72077. }
  72078. /**
  72079. * Represents a physics radial explosion event
  72080. */
  72081. class PhysicsRadialExplosionEvent {
  72082. private _scene;
  72083. private _options;
  72084. private _sphere;
  72085. private _dataFetched;
  72086. /**
  72087. * Initializes a radial explosioin event
  72088. * @param _scene BabylonJS scene
  72089. * @param _options The options for the vortex event
  72090. */
  72091. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72092. /**
  72093. * Returns the data related to the radial explosion event (sphere).
  72094. * @returns The radial explosion event data
  72095. */
  72096. getData(): PhysicsRadialExplosionEventData;
  72097. /**
  72098. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72099. * @param impostor A physics imposter
  72100. * @param origin the origin of the explosion
  72101. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72102. */
  72103. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72104. /**
  72105. * Triggers affecterd impostors callbacks
  72106. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72107. */
  72108. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72109. /**
  72110. * Disposes the sphere.
  72111. * @param force Specifies if the sphere should be disposed by force
  72112. */
  72113. dispose(force?: boolean): void;
  72114. /*** Helpers ***/
  72115. private _prepareSphere;
  72116. private _intersectsWithSphere;
  72117. }
  72118. /**
  72119. * Represents a gravitational field event
  72120. */
  72121. class PhysicsGravitationalFieldEvent {
  72122. private _physicsHelper;
  72123. private _scene;
  72124. private _origin;
  72125. private _options;
  72126. private _tickCallback;
  72127. private _sphere;
  72128. private _dataFetched;
  72129. /**
  72130. * Initializes the physics gravitational field event
  72131. * @param _physicsHelper A physics helper
  72132. * @param _scene BabylonJS scene
  72133. * @param _origin The origin position of the gravitational field event
  72134. * @param _options The options for the vortex event
  72135. */
  72136. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72137. /**
  72138. * Returns the data related to the gravitational field event (sphere).
  72139. * @returns A gravitational field event
  72140. */
  72141. getData(): PhysicsGravitationalFieldEventData;
  72142. /**
  72143. * Enables the gravitational field.
  72144. */
  72145. enable(): void;
  72146. /**
  72147. * Disables the gravitational field.
  72148. */
  72149. disable(): void;
  72150. /**
  72151. * Disposes the sphere.
  72152. * @param force The force to dispose from the gravitational field event
  72153. */
  72154. dispose(force?: boolean): void;
  72155. private _tick;
  72156. }
  72157. /**
  72158. * Represents a physics updraft event
  72159. */
  72160. class PhysicsUpdraftEvent {
  72161. private _scene;
  72162. private _origin;
  72163. private _options;
  72164. private _physicsEngine;
  72165. private _originTop;
  72166. private _originDirection;
  72167. private _tickCallback;
  72168. private _cylinder;
  72169. private _cylinderPosition;
  72170. private _dataFetched;
  72171. /**
  72172. * Initializes the physics updraft event
  72173. * @param _scene BabylonJS scene
  72174. * @param _origin The origin position of the updraft
  72175. * @param _options The options for the updraft event
  72176. */
  72177. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72178. /**
  72179. * Returns the data related to the updraft event (cylinder).
  72180. * @returns A physics updraft event
  72181. */
  72182. getData(): PhysicsUpdraftEventData;
  72183. /**
  72184. * Enables the updraft.
  72185. */
  72186. enable(): void;
  72187. /**
  72188. * Disables the updraft.
  72189. */
  72190. disable(): void;
  72191. /**
  72192. * Disposes the cylinder.
  72193. * @param force Specifies if the updraft should be disposed by force
  72194. */
  72195. dispose(force?: boolean): void;
  72196. private getImpostorHitData;
  72197. private _tick;
  72198. /*** Helpers ***/
  72199. private _prepareCylinder;
  72200. private _intersectsWithCylinder;
  72201. }
  72202. /**
  72203. * Represents a physics vortex event
  72204. */
  72205. class PhysicsVortexEvent {
  72206. private _scene;
  72207. private _origin;
  72208. private _options;
  72209. private _physicsEngine;
  72210. private _originTop;
  72211. private _tickCallback;
  72212. private _cylinder;
  72213. private _cylinderPosition;
  72214. private _dataFetched;
  72215. /**
  72216. * Initializes the physics vortex event
  72217. * @param _scene The BabylonJS scene
  72218. * @param _origin The origin position of the vortex
  72219. * @param _options The options for the vortex event
  72220. */
  72221. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72222. /**
  72223. * Returns the data related to the vortex event (cylinder).
  72224. * @returns The physics vortex event data
  72225. */
  72226. getData(): PhysicsVortexEventData;
  72227. /**
  72228. * Enables the vortex.
  72229. */
  72230. enable(): void;
  72231. /**
  72232. * Disables the cortex.
  72233. */
  72234. disable(): void;
  72235. /**
  72236. * Disposes the sphere.
  72237. * @param force
  72238. */
  72239. dispose(force?: boolean): void;
  72240. private getImpostorHitData;
  72241. private _tick;
  72242. /*** Helpers ***/
  72243. private _prepareCylinder;
  72244. private _intersectsWithCylinder;
  72245. }
  72246. /**
  72247. * Options fot the radial explosion event
  72248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72249. */
  72250. export class PhysicsRadialExplosionEventOptions {
  72251. /**
  72252. * The radius of the sphere for the radial explosion.
  72253. */
  72254. radius: number;
  72255. /**
  72256. * The strenth of the explosion.
  72257. */
  72258. strength: number;
  72259. /**
  72260. * The strenght of the force in correspondence to the distance of the affected object
  72261. */
  72262. falloff: PhysicsRadialImpulseFalloff;
  72263. /**
  72264. * Sphere options for the radial explosion.
  72265. */
  72266. sphere: {
  72267. segments: number;
  72268. diameter: number;
  72269. };
  72270. /**
  72271. * Sphere options for the radial explosion.
  72272. */
  72273. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72274. }
  72275. /**
  72276. * Options fot the updraft event
  72277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72278. */
  72279. export class PhysicsUpdraftEventOptions {
  72280. /**
  72281. * The radius of the cylinder for the vortex
  72282. */
  72283. radius: number;
  72284. /**
  72285. * The strenth of the updraft.
  72286. */
  72287. strength: number;
  72288. /**
  72289. * The height of the cylinder for the updraft.
  72290. */
  72291. height: number;
  72292. /**
  72293. * The mode for the the updraft.
  72294. */
  72295. updraftMode: PhysicsUpdraftMode;
  72296. }
  72297. /**
  72298. * Options fot the vortex event
  72299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72300. */
  72301. export class PhysicsVortexEventOptions {
  72302. /**
  72303. * The radius of the cylinder for the vortex
  72304. */
  72305. radius: number;
  72306. /**
  72307. * The strenth of the vortex.
  72308. */
  72309. strength: number;
  72310. /**
  72311. * The height of the cylinder for the vortex.
  72312. */
  72313. height: number;
  72314. /**
  72315. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72316. */
  72317. centripetalForceThreshold: number;
  72318. /**
  72319. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72320. */
  72321. centripetalForceMultiplier: number;
  72322. /**
  72323. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72324. */
  72325. centrifugalForceMultiplier: number;
  72326. /**
  72327. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72328. */
  72329. updraftForceMultiplier: number;
  72330. }
  72331. /**
  72332. * The strenght of the force in correspondence to the distance of the affected object
  72333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72334. */
  72335. export enum PhysicsRadialImpulseFalloff {
  72336. /** Defines that impulse is constant in strength across it's whole radius */
  72337. Constant = 0,
  72338. /** Defines that impulse gets weaker if it's further from the origin */
  72339. Linear = 1
  72340. }
  72341. /**
  72342. * The strength of the force in correspondence to the distance of the affected object
  72343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72344. */
  72345. export enum PhysicsUpdraftMode {
  72346. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72347. Center = 0,
  72348. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72349. Perpendicular = 1
  72350. }
  72351. /**
  72352. * Interface for a physics hit data
  72353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72354. */
  72355. export interface PhysicsHitData {
  72356. /**
  72357. * The force applied at the contact point
  72358. */
  72359. force: Vector3;
  72360. /**
  72361. * The contact point
  72362. */
  72363. contactPoint: Vector3;
  72364. /**
  72365. * The distance from the origin to the contact point
  72366. */
  72367. distanceFromOrigin: number;
  72368. }
  72369. /**
  72370. * Interface for radial explosion event data
  72371. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72372. */
  72373. export interface PhysicsRadialExplosionEventData {
  72374. /**
  72375. * A sphere used for the radial explosion event
  72376. */
  72377. sphere: Mesh;
  72378. }
  72379. /**
  72380. * Interface for gravitational field event data
  72381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72382. */
  72383. export interface PhysicsGravitationalFieldEventData {
  72384. /**
  72385. * A sphere mesh used for the gravitational field event
  72386. */
  72387. sphere: Mesh;
  72388. }
  72389. /**
  72390. * Interface for updraft event data
  72391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72392. */
  72393. export interface PhysicsUpdraftEventData {
  72394. /**
  72395. * A cylinder used for the updraft event
  72396. */
  72397. cylinder: Mesh;
  72398. }
  72399. /**
  72400. * Interface for vortex event data
  72401. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72402. */
  72403. export interface PhysicsVortexEventData {
  72404. /**
  72405. * A cylinder used for the vortex event
  72406. */
  72407. cylinder: Mesh;
  72408. }
  72409. /**
  72410. * Interface for an affected physics impostor
  72411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72412. */
  72413. export interface PhysicsAffectedImpostorWithData {
  72414. /**
  72415. * The impostor affected by the effect
  72416. */
  72417. impostor: PhysicsImpostor;
  72418. /**
  72419. * The data about the hit/horce from the explosion
  72420. */
  72421. hitData: PhysicsHitData;
  72422. }
  72423. }
  72424. declare module "babylonjs/Physics/Plugins/index" {
  72425. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72426. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72427. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72428. }
  72429. declare module "babylonjs/Physics/index" {
  72430. export * from "babylonjs/Physics/IPhysicsEngine";
  72431. export * from "babylonjs/Physics/physicsEngine";
  72432. export * from "babylonjs/Physics/physicsEngineComponent";
  72433. export * from "babylonjs/Physics/physicsHelper";
  72434. export * from "babylonjs/Physics/physicsImpostor";
  72435. export * from "babylonjs/Physics/physicsJoint";
  72436. export * from "babylonjs/Physics/Plugins/index";
  72437. }
  72438. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72439. /** @hidden */
  72440. export var blackAndWhitePixelShader: {
  72441. name: string;
  72442. shader: string;
  72443. };
  72444. }
  72445. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72446. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72447. import { Camera } from "babylonjs/Cameras/camera";
  72448. import { Engine } from "babylonjs/Engines/engine";
  72449. import "babylonjs/Shaders/blackAndWhite.fragment";
  72450. import { Nullable } from "babylonjs/types";
  72451. import { Scene } from "babylonjs/scene";
  72452. /**
  72453. * Post process used to render in black and white
  72454. */
  72455. export class BlackAndWhitePostProcess extends PostProcess {
  72456. /**
  72457. * Linear about to convert he result to black and white (default: 1)
  72458. */
  72459. degree: number;
  72460. /**
  72461. * Gets a string identifying the name of the class
  72462. * @returns "BlackAndWhitePostProcess" string
  72463. */
  72464. getClassName(): string;
  72465. /**
  72466. * Creates a black and white post process
  72467. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72468. * @param name The name of the effect.
  72469. * @param options The required width/height ratio to downsize to before computing the render pass.
  72470. * @param camera The camera to apply the render pass to.
  72471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72472. * @param engine The engine which the post process will be applied. (default: current engine)
  72473. * @param reusable If the post process can be reused on the same frame. (default: false)
  72474. */
  72475. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72476. /** @hidden */
  72477. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72478. }
  72479. }
  72480. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72481. import { Nullable } from "babylonjs/types";
  72482. import { Camera } from "babylonjs/Cameras/camera";
  72483. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72484. import { Engine } from "babylonjs/Engines/engine";
  72485. /**
  72486. * This represents a set of one or more post processes in Babylon.
  72487. * A post process can be used to apply a shader to a texture after it is rendered.
  72488. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72489. */
  72490. export class PostProcessRenderEffect {
  72491. private _postProcesses;
  72492. private _getPostProcesses;
  72493. private _singleInstance;
  72494. private _cameras;
  72495. private _indicesForCamera;
  72496. /**
  72497. * Name of the effect
  72498. * @hidden
  72499. */
  72500. _name: string;
  72501. /**
  72502. * Instantiates a post process render effect.
  72503. * A post process can be used to apply a shader to a texture after it is rendered.
  72504. * @param engine The engine the effect is tied to
  72505. * @param name The name of the effect
  72506. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72507. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72508. */
  72509. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72510. /**
  72511. * Checks if all the post processes in the effect are supported.
  72512. */
  72513. get isSupported(): boolean;
  72514. /**
  72515. * Updates the current state of the effect
  72516. * @hidden
  72517. */
  72518. _update(): void;
  72519. /**
  72520. * Attaches the effect on cameras
  72521. * @param cameras The camera to attach to.
  72522. * @hidden
  72523. */
  72524. _attachCameras(cameras: Camera): void;
  72525. /**
  72526. * Attaches the effect on cameras
  72527. * @param cameras The camera to attach to.
  72528. * @hidden
  72529. */
  72530. _attachCameras(cameras: Camera[]): void;
  72531. /**
  72532. * Detaches the effect on cameras
  72533. * @param cameras The camera to detatch from.
  72534. * @hidden
  72535. */
  72536. _detachCameras(cameras: Camera): void;
  72537. /**
  72538. * Detatches the effect on cameras
  72539. * @param cameras The camera to detatch from.
  72540. * @hidden
  72541. */
  72542. _detachCameras(cameras: Camera[]): void;
  72543. /**
  72544. * Enables the effect on given cameras
  72545. * @param cameras The camera to enable.
  72546. * @hidden
  72547. */
  72548. _enable(cameras: Camera): void;
  72549. /**
  72550. * Enables the effect on given cameras
  72551. * @param cameras The camera to enable.
  72552. * @hidden
  72553. */
  72554. _enable(cameras: Nullable<Camera[]>): void;
  72555. /**
  72556. * Disables the effect on the given cameras
  72557. * @param cameras The camera to disable.
  72558. * @hidden
  72559. */
  72560. _disable(cameras: Camera): void;
  72561. /**
  72562. * Disables the effect on the given cameras
  72563. * @param cameras The camera to disable.
  72564. * @hidden
  72565. */
  72566. _disable(cameras: Nullable<Camera[]>): void;
  72567. /**
  72568. * Gets a list of the post processes contained in the effect.
  72569. * @param camera The camera to get the post processes on.
  72570. * @returns The list of the post processes in the effect.
  72571. */
  72572. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72573. }
  72574. }
  72575. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72576. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72577. /** @hidden */
  72578. export var extractHighlightsPixelShader: {
  72579. name: string;
  72580. shader: string;
  72581. };
  72582. }
  72583. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72584. import { Nullable } from "babylonjs/types";
  72585. import { Camera } from "babylonjs/Cameras/camera";
  72586. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72587. import { Engine } from "babylonjs/Engines/engine";
  72588. import "babylonjs/Shaders/extractHighlights.fragment";
  72589. /**
  72590. * 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.
  72591. */
  72592. export class ExtractHighlightsPostProcess extends PostProcess {
  72593. /**
  72594. * The luminance threshold, pixels below this value will be set to black.
  72595. */
  72596. threshold: number;
  72597. /** @hidden */
  72598. _exposure: number;
  72599. /**
  72600. * Post process which has the input texture to be used when performing highlight extraction
  72601. * @hidden
  72602. */
  72603. _inputPostProcess: Nullable<PostProcess>;
  72604. /**
  72605. * Gets a string identifying the name of the class
  72606. * @returns "ExtractHighlightsPostProcess" string
  72607. */
  72608. getClassName(): string;
  72609. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72610. }
  72611. }
  72612. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72613. /** @hidden */
  72614. export var bloomMergePixelShader: {
  72615. name: string;
  72616. shader: string;
  72617. };
  72618. }
  72619. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72620. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72621. import { Nullable } from "babylonjs/types";
  72622. import { Engine } from "babylonjs/Engines/engine";
  72623. import { Camera } from "babylonjs/Cameras/camera";
  72624. import "babylonjs/Shaders/bloomMerge.fragment";
  72625. /**
  72626. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72627. */
  72628. export class BloomMergePostProcess extends PostProcess {
  72629. /** Weight of the bloom to be added to the original input. */
  72630. weight: number;
  72631. /**
  72632. * Gets a string identifying the name of the class
  72633. * @returns "BloomMergePostProcess" string
  72634. */
  72635. getClassName(): string;
  72636. /**
  72637. * Creates a new instance of @see BloomMergePostProcess
  72638. * @param name The name of the effect.
  72639. * @param originalFromInput Post process which's input will be used for the merge.
  72640. * @param blurred Blurred highlights post process which's output will be used.
  72641. * @param weight Weight of the bloom to be added to the original input.
  72642. * @param options The required width/height ratio to downsize to before computing the render pass.
  72643. * @param camera The camera to apply the render pass to.
  72644. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72645. * @param engine The engine which the post process will be applied. (default: current engine)
  72646. * @param reusable If the post process can be reused on the same frame. (default: false)
  72647. * @param textureType Type of textures used when performing the post process. (default: 0)
  72648. * @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)
  72649. */
  72650. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72651. /** Weight of the bloom to be added to the original input. */
  72652. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72653. }
  72654. }
  72655. declare module "babylonjs/PostProcesses/bloomEffect" {
  72656. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72657. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72658. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72659. import { Camera } from "babylonjs/Cameras/camera";
  72660. import { Scene } from "babylonjs/scene";
  72661. /**
  72662. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72663. */
  72664. export class BloomEffect extends PostProcessRenderEffect {
  72665. private bloomScale;
  72666. /**
  72667. * @hidden Internal
  72668. */
  72669. _effects: Array<PostProcess>;
  72670. /**
  72671. * @hidden Internal
  72672. */
  72673. _downscale: ExtractHighlightsPostProcess;
  72674. private _blurX;
  72675. private _blurY;
  72676. private _merge;
  72677. /**
  72678. * The luminance threshold to find bright areas of the image to bloom.
  72679. */
  72680. get threshold(): number;
  72681. set threshold(value: number);
  72682. /**
  72683. * The strength of the bloom.
  72684. */
  72685. get weight(): number;
  72686. set weight(value: number);
  72687. /**
  72688. * Specifies the size of the bloom blur kernel, relative to the final output size
  72689. */
  72690. get kernel(): number;
  72691. set kernel(value: number);
  72692. /**
  72693. * Creates a new instance of @see BloomEffect
  72694. * @param scene The scene the effect belongs to.
  72695. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72696. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72697. * @param bloomWeight The the strength of bloom.
  72698. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72699. * @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)
  72700. */
  72701. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72702. /**
  72703. * Disposes each of the internal effects for a given camera.
  72704. * @param camera The camera to dispose the effect on.
  72705. */
  72706. disposeEffects(camera: Camera): void;
  72707. /**
  72708. * @hidden Internal
  72709. */
  72710. _updateEffects(): void;
  72711. /**
  72712. * Internal
  72713. * @returns if all the contained post processes are ready.
  72714. * @hidden
  72715. */
  72716. _isReady(): boolean;
  72717. }
  72718. }
  72719. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72720. /** @hidden */
  72721. export var chromaticAberrationPixelShader: {
  72722. name: string;
  72723. shader: string;
  72724. };
  72725. }
  72726. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  72727. import { Vector2 } from "babylonjs/Maths/math.vector";
  72728. import { Nullable } from "babylonjs/types";
  72729. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72730. import { Camera } from "babylonjs/Cameras/camera";
  72731. import { Engine } from "babylonjs/Engines/engine";
  72732. import "babylonjs/Shaders/chromaticAberration.fragment";
  72733. import { Scene } from "babylonjs/scene";
  72734. /**
  72735. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  72736. */
  72737. export class ChromaticAberrationPostProcess extends PostProcess {
  72738. /**
  72739. * The amount of seperation of rgb channels (default: 30)
  72740. */
  72741. aberrationAmount: number;
  72742. /**
  72743. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  72744. */
  72745. radialIntensity: number;
  72746. /**
  72747. * 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))
  72748. */
  72749. direction: Vector2;
  72750. /**
  72751. * 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))
  72752. */
  72753. centerPosition: Vector2;
  72754. /** The width of the screen to apply the effect on */
  72755. screenWidth: number;
  72756. /** The height of the screen to apply the effect on */
  72757. screenHeight: number;
  72758. /**
  72759. * Gets a string identifying the name of the class
  72760. * @returns "ChromaticAberrationPostProcess" string
  72761. */
  72762. getClassName(): string;
  72763. /**
  72764. * Creates a new instance ChromaticAberrationPostProcess
  72765. * @param name The name of the effect.
  72766. * @param screenWidth The width of the screen to apply the effect on.
  72767. * @param screenHeight The height of the screen to apply the effect on.
  72768. * @param options The required width/height ratio to downsize to before computing the render pass.
  72769. * @param camera The camera to apply the render pass to.
  72770. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72771. * @param engine The engine which the post process will be applied. (default: current engine)
  72772. * @param reusable If the post process can be reused on the same frame. (default: false)
  72773. * @param textureType Type of textures used when performing the post process. (default: 0)
  72774. * @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)
  72775. */
  72776. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72777. /** @hidden */
  72778. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  72779. }
  72780. }
  72781. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  72782. /** @hidden */
  72783. export var circleOfConfusionPixelShader: {
  72784. name: string;
  72785. shader: string;
  72786. };
  72787. }
  72788. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  72789. import { Nullable } from "babylonjs/types";
  72790. import { Engine } from "babylonjs/Engines/engine";
  72791. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72792. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72793. import { Camera } from "babylonjs/Cameras/camera";
  72794. import "babylonjs/Shaders/circleOfConfusion.fragment";
  72795. /**
  72796. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  72797. */
  72798. export class CircleOfConfusionPostProcess extends PostProcess {
  72799. /**
  72800. * 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.
  72801. */
  72802. lensSize: number;
  72803. /**
  72804. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72805. */
  72806. fStop: number;
  72807. /**
  72808. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72809. */
  72810. focusDistance: number;
  72811. /**
  72812. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  72813. */
  72814. focalLength: number;
  72815. /**
  72816. * Gets a string identifying the name of the class
  72817. * @returns "CircleOfConfusionPostProcess" string
  72818. */
  72819. getClassName(): string;
  72820. private _depthTexture;
  72821. /**
  72822. * Creates a new instance CircleOfConfusionPostProcess
  72823. * @param name The name of the effect.
  72824. * @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.
  72825. * @param options The required width/height ratio to downsize to before computing the render pass.
  72826. * @param camera The camera to apply the render pass to.
  72827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72828. * @param engine The engine which the post process will be applied. (default: current engine)
  72829. * @param reusable If the post process can be reused on the same frame. (default: false)
  72830. * @param textureType Type of textures used when performing the post process. (default: 0)
  72831. * @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)
  72832. */
  72833. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72834. /**
  72835. * 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.
  72836. */
  72837. set depthTexture(value: RenderTargetTexture);
  72838. }
  72839. }
  72840. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  72841. /** @hidden */
  72842. export var colorCorrectionPixelShader: {
  72843. name: string;
  72844. shader: string;
  72845. };
  72846. }
  72847. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  72848. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72849. import { Engine } from "babylonjs/Engines/engine";
  72850. import { Camera } from "babylonjs/Cameras/camera";
  72851. import "babylonjs/Shaders/colorCorrection.fragment";
  72852. import { Nullable } from "babylonjs/types";
  72853. import { Scene } from "babylonjs/scene";
  72854. /**
  72855. *
  72856. * This post-process allows the modification of rendered colors by using
  72857. * a 'look-up table' (LUT). This effect is also called Color Grading.
  72858. *
  72859. * The object needs to be provided an url to a texture containing the color
  72860. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  72861. * Use an image editing software to tweak the LUT to match your needs.
  72862. *
  72863. * For an example of a color LUT, see here:
  72864. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  72865. * For explanations on color grading, see here:
  72866. * @see http://udn.epicgames.com/Three/ColorGrading.html
  72867. *
  72868. */
  72869. export class ColorCorrectionPostProcess extends PostProcess {
  72870. private _colorTableTexture;
  72871. /**
  72872. * Gets the color table url used to create the LUT texture
  72873. */
  72874. colorTableUrl: string;
  72875. /**
  72876. * Gets a string identifying the name of the class
  72877. * @returns "ColorCorrectionPostProcess" string
  72878. */
  72879. getClassName(): string;
  72880. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72881. /** @hidden */
  72882. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  72883. }
  72884. }
  72885. declare module "babylonjs/Shaders/convolution.fragment" {
  72886. /** @hidden */
  72887. export var convolutionPixelShader: {
  72888. name: string;
  72889. shader: string;
  72890. };
  72891. }
  72892. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  72893. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72894. import { Nullable } from "babylonjs/types";
  72895. import { Camera } from "babylonjs/Cameras/camera";
  72896. import { Engine } from "babylonjs/Engines/engine";
  72897. import "babylonjs/Shaders/convolution.fragment";
  72898. import { Scene } from "babylonjs/scene";
  72899. /**
  72900. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  72901. * input texture to perform effects such as edge detection or sharpening
  72902. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72903. */
  72904. export class ConvolutionPostProcess extends PostProcess {
  72905. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72906. kernel: number[];
  72907. /**
  72908. * Gets a string identifying the name of the class
  72909. * @returns "ConvolutionPostProcess" string
  72910. */
  72911. getClassName(): string;
  72912. /**
  72913. * Creates a new instance ConvolutionPostProcess
  72914. * @param name The name of the effect.
  72915. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  72916. * @param options The required width/height ratio to downsize to before computing the render pass.
  72917. * @param camera The camera to apply the render pass to.
  72918. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72919. * @param engine The engine which the post process will be applied. (default: current engine)
  72920. * @param reusable If the post process can be reused on the same frame. (default: false)
  72921. * @param textureType Type of textures used when performing the post process. (default: 0)
  72922. */
  72923. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72924. /** @hidden */
  72925. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  72926. /**
  72927. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72928. */
  72929. static EdgeDetect0Kernel: number[];
  72930. /**
  72931. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72932. */
  72933. static EdgeDetect1Kernel: number[];
  72934. /**
  72935. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72936. */
  72937. static EdgeDetect2Kernel: number[];
  72938. /**
  72939. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72940. */
  72941. static SharpenKernel: number[];
  72942. /**
  72943. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72944. */
  72945. static EmbossKernel: number[];
  72946. /**
  72947. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72948. */
  72949. static GaussianKernel: number[];
  72950. }
  72951. }
  72952. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  72953. import { Nullable } from "babylonjs/types";
  72954. import { Vector2 } from "babylonjs/Maths/math.vector";
  72955. import { Camera } from "babylonjs/Cameras/camera";
  72956. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72957. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  72958. import { Engine } from "babylonjs/Engines/engine";
  72959. import { Scene } from "babylonjs/scene";
  72960. /**
  72961. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  72962. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  72963. * based on samples that have a large difference in distance than the center pixel.
  72964. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  72965. */
  72966. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  72967. /**
  72968. * The direction the blur should be applied
  72969. */
  72970. direction: Vector2;
  72971. /**
  72972. * Gets a string identifying the name of the class
  72973. * @returns "DepthOfFieldBlurPostProcess" string
  72974. */
  72975. getClassName(): string;
  72976. /**
  72977. * Creates a new instance CircleOfConfusionPostProcess
  72978. * @param name The name of the effect.
  72979. * @param scene The scene the effect belongs to.
  72980. * @param direction The direction the blur should be applied.
  72981. * @param kernel The size of the kernel used to blur.
  72982. * @param options The required width/height ratio to downsize to before computing the render pass.
  72983. * @param camera The camera to apply the render pass to.
  72984. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  72985. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  72986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72987. * @param engine The engine which the post process will be applied. (default: current engine)
  72988. * @param reusable If the post process can be reused on the same frame. (default: false)
  72989. * @param textureType Type of textures used when performing the post process. (default: 0)
  72990. * @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)
  72991. */
  72992. 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);
  72993. }
  72994. }
  72995. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  72996. /** @hidden */
  72997. export var depthOfFieldMergePixelShader: {
  72998. name: string;
  72999. shader: string;
  73000. };
  73001. }
  73002. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73003. import { Nullable } from "babylonjs/types";
  73004. import { Camera } from "babylonjs/Cameras/camera";
  73005. import { Effect } from "babylonjs/Materials/effect";
  73006. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73007. import { Engine } from "babylonjs/Engines/engine";
  73008. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73009. /**
  73010. * Options to be set when merging outputs from the default pipeline.
  73011. */
  73012. export class DepthOfFieldMergePostProcessOptions {
  73013. /**
  73014. * The original image to merge on top of
  73015. */
  73016. originalFromInput: PostProcess;
  73017. /**
  73018. * Parameters to perform the merge of the depth of field effect
  73019. */
  73020. depthOfField?: {
  73021. circleOfConfusion: PostProcess;
  73022. blurSteps: Array<PostProcess>;
  73023. };
  73024. /**
  73025. * Parameters to perform the merge of bloom effect
  73026. */
  73027. bloom?: {
  73028. blurred: PostProcess;
  73029. weight: number;
  73030. };
  73031. }
  73032. /**
  73033. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73034. */
  73035. export class DepthOfFieldMergePostProcess extends PostProcess {
  73036. private blurSteps;
  73037. /**
  73038. * Gets a string identifying the name of the class
  73039. * @returns "DepthOfFieldMergePostProcess" string
  73040. */
  73041. getClassName(): string;
  73042. /**
  73043. * Creates a new instance of DepthOfFieldMergePostProcess
  73044. * @param name The name of the effect.
  73045. * @param originalFromInput Post process which's input will be used for the merge.
  73046. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73047. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73048. * @param options The required width/height ratio to downsize to before computing the render pass.
  73049. * @param camera The camera to apply the render pass to.
  73050. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73051. * @param engine The engine which the post process will be applied. (default: current engine)
  73052. * @param reusable If the post process can be reused on the same frame. (default: false)
  73053. * @param textureType Type of textures used when performing the post process. (default: 0)
  73054. * @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)
  73055. */
  73056. 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);
  73057. /**
  73058. * Updates the effect with the current post process compile time values and recompiles the shader.
  73059. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73060. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73061. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73062. * @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
  73063. * @param onCompiled Called when the shader has been compiled.
  73064. * @param onError Called if there is an error when compiling a shader.
  73065. */
  73066. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73067. }
  73068. }
  73069. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73070. import { Nullable } from "babylonjs/types";
  73071. import { Camera } from "babylonjs/Cameras/camera";
  73072. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73073. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73074. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73075. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73076. import { Scene } from "babylonjs/scene";
  73077. /**
  73078. * Specifies the level of max blur that should be applied when using the depth of field effect
  73079. */
  73080. export enum DepthOfFieldEffectBlurLevel {
  73081. /**
  73082. * Subtle blur
  73083. */
  73084. Low = 0,
  73085. /**
  73086. * Medium blur
  73087. */
  73088. Medium = 1,
  73089. /**
  73090. * Large blur
  73091. */
  73092. High = 2
  73093. }
  73094. /**
  73095. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73096. */
  73097. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73098. private _circleOfConfusion;
  73099. /**
  73100. * @hidden Internal, blurs from high to low
  73101. */
  73102. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73103. private _depthOfFieldBlurY;
  73104. private _dofMerge;
  73105. /**
  73106. * @hidden Internal post processes in depth of field effect
  73107. */
  73108. _effects: Array<PostProcess>;
  73109. /**
  73110. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73111. */
  73112. set focalLength(value: number);
  73113. get focalLength(): number;
  73114. /**
  73115. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73116. */
  73117. set fStop(value: number);
  73118. get fStop(): number;
  73119. /**
  73120. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73121. */
  73122. set focusDistance(value: number);
  73123. get focusDistance(): number;
  73124. /**
  73125. * 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.
  73126. */
  73127. set lensSize(value: number);
  73128. get lensSize(): number;
  73129. /**
  73130. * Creates a new instance DepthOfFieldEffect
  73131. * @param scene The scene the effect belongs to.
  73132. * @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.
  73133. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73134. * @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)
  73135. */
  73136. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73137. /**
  73138. * Get the current class name of the current effet
  73139. * @returns "DepthOfFieldEffect"
  73140. */
  73141. getClassName(): string;
  73142. /**
  73143. * 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.
  73144. */
  73145. set depthTexture(value: RenderTargetTexture);
  73146. /**
  73147. * Disposes each of the internal effects for a given camera.
  73148. * @param camera The camera to dispose the effect on.
  73149. */
  73150. disposeEffects(camera: Camera): void;
  73151. /**
  73152. * @hidden Internal
  73153. */
  73154. _updateEffects(): void;
  73155. /**
  73156. * Internal
  73157. * @returns if all the contained post processes are ready.
  73158. * @hidden
  73159. */
  73160. _isReady(): boolean;
  73161. }
  73162. }
  73163. declare module "babylonjs/Shaders/displayPass.fragment" {
  73164. /** @hidden */
  73165. export var displayPassPixelShader: {
  73166. name: string;
  73167. shader: string;
  73168. };
  73169. }
  73170. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73171. import { Nullable } from "babylonjs/types";
  73172. import { Camera } from "babylonjs/Cameras/camera";
  73173. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73174. import { Engine } from "babylonjs/Engines/engine";
  73175. import "babylonjs/Shaders/displayPass.fragment";
  73176. import { Scene } from "babylonjs/scene";
  73177. /**
  73178. * DisplayPassPostProcess which produces an output the same as it's input
  73179. */
  73180. export class DisplayPassPostProcess extends PostProcess {
  73181. /**
  73182. * Gets a string identifying the name of the class
  73183. * @returns "DisplayPassPostProcess" string
  73184. */
  73185. getClassName(): string;
  73186. /**
  73187. * Creates the DisplayPassPostProcess
  73188. * @param name The name of the effect.
  73189. * @param options The required width/height ratio to downsize to before computing the render pass.
  73190. * @param camera The camera to apply the render pass to.
  73191. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73192. * @param engine The engine which the post process will be applied. (default: current engine)
  73193. * @param reusable If the post process can be reused on the same frame. (default: false)
  73194. */
  73195. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73196. /** @hidden */
  73197. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73198. }
  73199. }
  73200. declare module "babylonjs/Shaders/filter.fragment" {
  73201. /** @hidden */
  73202. export var filterPixelShader: {
  73203. name: string;
  73204. shader: string;
  73205. };
  73206. }
  73207. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73208. import { Nullable } from "babylonjs/types";
  73209. import { Matrix } from "babylonjs/Maths/math.vector";
  73210. import { Camera } from "babylonjs/Cameras/camera";
  73211. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73212. import { Engine } from "babylonjs/Engines/engine";
  73213. import "babylonjs/Shaders/filter.fragment";
  73214. import { Scene } from "babylonjs/scene";
  73215. /**
  73216. * Applies a kernel filter to the image
  73217. */
  73218. export class FilterPostProcess extends PostProcess {
  73219. /** The matrix to be applied to the image */
  73220. kernelMatrix: Matrix;
  73221. /**
  73222. * Gets a string identifying the name of the class
  73223. * @returns "FilterPostProcess" string
  73224. */
  73225. getClassName(): string;
  73226. /**
  73227. *
  73228. * @param name The name of the effect.
  73229. * @param kernelMatrix The matrix to be applied to the image
  73230. * @param options The required width/height ratio to downsize to before computing the render pass.
  73231. * @param camera The camera to apply the render pass to.
  73232. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73233. * @param engine The engine which the post process will be applied. (default: current engine)
  73234. * @param reusable If the post process can be reused on the same frame. (default: false)
  73235. */
  73236. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73237. /** @hidden */
  73238. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73239. }
  73240. }
  73241. declare module "babylonjs/Shaders/fxaa.fragment" {
  73242. /** @hidden */
  73243. export var fxaaPixelShader: {
  73244. name: string;
  73245. shader: string;
  73246. };
  73247. }
  73248. declare module "babylonjs/Shaders/fxaa.vertex" {
  73249. /** @hidden */
  73250. export var fxaaVertexShader: {
  73251. name: string;
  73252. shader: string;
  73253. };
  73254. }
  73255. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73256. import { Nullable } from "babylonjs/types";
  73257. import { Camera } from "babylonjs/Cameras/camera";
  73258. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73259. import { Engine } from "babylonjs/Engines/engine";
  73260. import "babylonjs/Shaders/fxaa.fragment";
  73261. import "babylonjs/Shaders/fxaa.vertex";
  73262. import { Scene } from "babylonjs/scene";
  73263. /**
  73264. * Fxaa post process
  73265. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73266. */
  73267. export class FxaaPostProcess extends PostProcess {
  73268. /**
  73269. * Gets a string identifying the name of the class
  73270. * @returns "FxaaPostProcess" string
  73271. */
  73272. getClassName(): string;
  73273. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73274. private _getDefines;
  73275. /** @hidden */
  73276. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73277. }
  73278. }
  73279. declare module "babylonjs/Shaders/grain.fragment" {
  73280. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73281. /** @hidden */
  73282. export var grainPixelShader: {
  73283. name: string;
  73284. shader: string;
  73285. };
  73286. }
  73287. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73288. import { Nullable } from "babylonjs/types";
  73289. import { Camera } from "babylonjs/Cameras/camera";
  73290. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73291. import { Engine } from "babylonjs/Engines/engine";
  73292. import "babylonjs/Shaders/grain.fragment";
  73293. import { Scene } from "babylonjs/scene";
  73294. /**
  73295. * The GrainPostProcess adds noise to the image at mid luminance levels
  73296. */
  73297. export class GrainPostProcess extends PostProcess {
  73298. /**
  73299. * The intensity of the grain added (default: 30)
  73300. */
  73301. intensity: number;
  73302. /**
  73303. * If the grain should be randomized on every frame
  73304. */
  73305. animated: boolean;
  73306. /**
  73307. * Gets a string identifying the name of the class
  73308. * @returns "GrainPostProcess" string
  73309. */
  73310. getClassName(): string;
  73311. /**
  73312. * Creates a new instance of @see GrainPostProcess
  73313. * @param name The name of the effect.
  73314. * @param options The required width/height ratio to downsize to before computing the render pass.
  73315. * @param camera The camera to apply the render pass to.
  73316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73317. * @param engine The engine which the post process will be applied. (default: current engine)
  73318. * @param reusable If the post process can be reused on the same frame. (default: false)
  73319. * @param textureType Type of textures used when performing the post process. (default: 0)
  73320. * @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)
  73321. */
  73322. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73323. /** @hidden */
  73324. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73325. }
  73326. }
  73327. declare module "babylonjs/Shaders/highlights.fragment" {
  73328. /** @hidden */
  73329. export var highlightsPixelShader: {
  73330. name: string;
  73331. shader: string;
  73332. };
  73333. }
  73334. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73335. import { Nullable } from "babylonjs/types";
  73336. import { Camera } from "babylonjs/Cameras/camera";
  73337. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73338. import { Engine } from "babylonjs/Engines/engine";
  73339. import "babylonjs/Shaders/highlights.fragment";
  73340. /**
  73341. * Extracts highlights from the image
  73342. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73343. */
  73344. export class HighlightsPostProcess extends PostProcess {
  73345. /**
  73346. * Gets a string identifying the name of the class
  73347. * @returns "HighlightsPostProcess" string
  73348. */
  73349. getClassName(): string;
  73350. /**
  73351. * Extracts highlights from the image
  73352. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73353. * @param name The name of the effect.
  73354. * @param options The required width/height ratio to downsize to before computing the render pass.
  73355. * @param camera The camera to apply the render pass to.
  73356. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73357. * @param engine The engine which the post process will be applied. (default: current engine)
  73358. * @param reusable If the post process can be reused on the same frame. (default: false)
  73359. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73360. */
  73361. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73362. }
  73363. }
  73364. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73365. /** @hidden */
  73366. export var mrtFragmentDeclaration: {
  73367. name: string;
  73368. shader: string;
  73369. };
  73370. }
  73371. declare module "babylonjs/Shaders/geometry.fragment" {
  73372. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73373. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73374. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73375. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73376. /** @hidden */
  73377. export var geometryPixelShader: {
  73378. name: string;
  73379. shader: string;
  73380. };
  73381. }
  73382. declare module "babylonjs/Shaders/geometry.vertex" {
  73383. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73384. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73385. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73386. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73387. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73388. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73389. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73390. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73391. /** @hidden */
  73392. export var geometryVertexShader: {
  73393. name: string;
  73394. shader: string;
  73395. };
  73396. }
  73397. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73398. import { Matrix } from "babylonjs/Maths/math.vector";
  73399. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73400. import { Mesh } from "babylonjs/Meshes/mesh";
  73401. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73402. import { Effect } from "babylonjs/Materials/effect";
  73403. import { Scene } from "babylonjs/scene";
  73404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73405. import "babylonjs/Shaders/geometry.fragment";
  73406. import "babylonjs/Shaders/geometry.vertex";
  73407. /** @hidden */
  73408. interface ISavedTransformationMatrix {
  73409. world: Matrix;
  73410. viewProjection: Matrix;
  73411. }
  73412. /**
  73413. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73414. */
  73415. export class GeometryBufferRenderer {
  73416. /**
  73417. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73418. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73419. */
  73420. static readonly POSITION_TEXTURE_TYPE: number;
  73421. /**
  73422. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73423. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73424. */
  73425. static readonly VELOCITY_TEXTURE_TYPE: number;
  73426. /**
  73427. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73428. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73429. */
  73430. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73431. /**
  73432. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73433. * in order to compute objects velocities when enableVelocity is set to "true"
  73434. * @hidden
  73435. */
  73436. _previousTransformationMatrices: {
  73437. [index: number]: ISavedTransformationMatrix;
  73438. };
  73439. /**
  73440. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73441. * in order to compute objects velocities when enableVelocity is set to "true"
  73442. * @hidden
  73443. */
  73444. _previousBonesTransformationMatrices: {
  73445. [index: number]: Float32Array;
  73446. };
  73447. /**
  73448. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73449. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73450. */
  73451. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73452. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73453. renderTransparentMeshes: boolean;
  73454. private _scene;
  73455. private _resizeObserver;
  73456. private _multiRenderTarget;
  73457. private _ratio;
  73458. private _enablePosition;
  73459. private _enableVelocity;
  73460. private _enableReflectivity;
  73461. private _positionIndex;
  73462. private _velocityIndex;
  73463. private _reflectivityIndex;
  73464. protected _effect: Effect;
  73465. protected _cachedDefines: string;
  73466. /**
  73467. * Set the render list (meshes to be rendered) used in the G buffer.
  73468. */
  73469. set renderList(meshes: Mesh[]);
  73470. /**
  73471. * Gets wether or not G buffer are supported by the running hardware.
  73472. * This requires draw buffer supports
  73473. */
  73474. get isSupported(): boolean;
  73475. /**
  73476. * Returns the index of the given texture type in the G-Buffer textures array
  73477. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73478. * @returns the index of the given texture type in the G-Buffer textures array
  73479. */
  73480. getTextureIndex(textureType: number): number;
  73481. /**
  73482. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73483. */
  73484. get enablePosition(): boolean;
  73485. /**
  73486. * Sets whether or not objects positions are enabled for the G buffer.
  73487. */
  73488. set enablePosition(enable: boolean);
  73489. /**
  73490. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73491. */
  73492. get enableVelocity(): boolean;
  73493. /**
  73494. * Sets wether or not objects velocities are enabled for the G buffer.
  73495. */
  73496. set enableVelocity(enable: boolean);
  73497. /**
  73498. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73499. */
  73500. get enableReflectivity(): boolean;
  73501. /**
  73502. * Sets wether or not objects roughness are enabled for the G buffer.
  73503. */
  73504. set enableReflectivity(enable: boolean);
  73505. /**
  73506. * Gets the scene associated with the buffer.
  73507. */
  73508. get scene(): Scene;
  73509. /**
  73510. * Gets the ratio used by the buffer during its creation.
  73511. * How big is the buffer related to the main canvas.
  73512. */
  73513. get ratio(): number;
  73514. /** @hidden */
  73515. static _SceneComponentInitialization: (scene: Scene) => void;
  73516. /**
  73517. * Creates a new G Buffer for the scene
  73518. * @param scene The scene the buffer belongs to
  73519. * @param ratio How big is the buffer related to the main canvas.
  73520. */
  73521. constructor(scene: Scene, ratio?: number);
  73522. /**
  73523. * Checks wether everything is ready to render a submesh to the G buffer.
  73524. * @param subMesh the submesh to check readiness for
  73525. * @param useInstances is the mesh drawn using instance or not
  73526. * @returns true if ready otherwise false
  73527. */
  73528. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73529. /**
  73530. * Gets the current underlying G Buffer.
  73531. * @returns the buffer
  73532. */
  73533. getGBuffer(): MultiRenderTarget;
  73534. /**
  73535. * Gets the number of samples used to render the buffer (anti aliasing).
  73536. */
  73537. get samples(): number;
  73538. /**
  73539. * Sets the number of samples used to render the buffer (anti aliasing).
  73540. */
  73541. set samples(value: number);
  73542. /**
  73543. * Disposes the renderer and frees up associated resources.
  73544. */
  73545. dispose(): void;
  73546. protected _createRenderTargets(): void;
  73547. private _copyBonesTransformationMatrices;
  73548. }
  73549. }
  73550. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73551. import { Nullable } from "babylonjs/types";
  73552. import { Scene } from "babylonjs/scene";
  73553. import { ISceneComponent } from "babylonjs/sceneComponent";
  73554. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73555. module "babylonjs/scene" {
  73556. interface Scene {
  73557. /** @hidden (Backing field) */
  73558. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73559. /**
  73560. * Gets or Sets the current geometry buffer associated to the scene.
  73561. */
  73562. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73563. /**
  73564. * Enables a GeometryBufferRender and associates it with the scene
  73565. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73566. * @returns the GeometryBufferRenderer
  73567. */
  73568. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73569. /**
  73570. * Disables the GeometryBufferRender associated with the scene
  73571. */
  73572. disableGeometryBufferRenderer(): void;
  73573. }
  73574. }
  73575. /**
  73576. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73577. * in several rendering techniques.
  73578. */
  73579. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73580. /**
  73581. * The component name helpful to identify the component in the list of scene components.
  73582. */
  73583. readonly name: string;
  73584. /**
  73585. * The scene the component belongs to.
  73586. */
  73587. scene: Scene;
  73588. /**
  73589. * Creates a new instance of the component for the given scene
  73590. * @param scene Defines the scene to register the component in
  73591. */
  73592. constructor(scene: Scene);
  73593. /**
  73594. * Registers the component in a given scene
  73595. */
  73596. register(): void;
  73597. /**
  73598. * Rebuilds the elements related to this component in case of
  73599. * context lost for instance.
  73600. */
  73601. rebuild(): void;
  73602. /**
  73603. * Disposes the component and the associated ressources
  73604. */
  73605. dispose(): void;
  73606. private _gatherRenderTargets;
  73607. }
  73608. }
  73609. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73610. /** @hidden */
  73611. export var motionBlurPixelShader: {
  73612. name: string;
  73613. shader: string;
  73614. };
  73615. }
  73616. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73617. import { Nullable } from "babylonjs/types";
  73618. import { Camera } from "babylonjs/Cameras/camera";
  73619. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73621. import "babylonjs/Animations/animatable";
  73622. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73623. import "babylonjs/Shaders/motionBlur.fragment";
  73624. import { Engine } from "babylonjs/Engines/engine";
  73625. import { Scene } from "babylonjs/scene";
  73626. /**
  73627. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73628. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73629. * As an example, all you have to do is to create the post-process:
  73630. * var mb = new BABYLON.MotionBlurPostProcess(
  73631. * 'mb', // The name of the effect.
  73632. * scene, // The scene containing the objects to blur according to their velocity.
  73633. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73634. * camera // The camera to apply the render pass to.
  73635. * );
  73636. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73637. */
  73638. export class MotionBlurPostProcess extends PostProcess {
  73639. /**
  73640. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73641. */
  73642. motionStrength: number;
  73643. /**
  73644. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73645. */
  73646. get motionBlurSamples(): number;
  73647. /**
  73648. * Sets the number of iterations to be used for motion blur quality
  73649. */
  73650. set motionBlurSamples(samples: number);
  73651. private _motionBlurSamples;
  73652. private _geometryBufferRenderer;
  73653. /**
  73654. * Gets a string identifying the name of the class
  73655. * @returns "MotionBlurPostProcess" string
  73656. */
  73657. getClassName(): string;
  73658. /**
  73659. * Creates a new instance MotionBlurPostProcess
  73660. * @param name The name of the effect.
  73661. * @param scene The scene containing the objects to blur according to their velocity.
  73662. * @param options The required width/height ratio to downsize to before computing the render pass.
  73663. * @param camera The camera to apply the render pass to.
  73664. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73665. * @param engine The engine which the post process will be applied. (default: current engine)
  73666. * @param reusable If the post process can be reused on the same frame. (default: false)
  73667. * @param textureType Type of textures used when performing the post process. (default: 0)
  73668. * @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)
  73669. */
  73670. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73671. /**
  73672. * Excludes the given skinned mesh from computing bones velocities.
  73673. * 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.
  73674. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73675. */
  73676. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73677. /**
  73678. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73679. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73680. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73681. */
  73682. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73683. /**
  73684. * Disposes the post process.
  73685. * @param camera The camera to dispose the post process on.
  73686. */
  73687. dispose(camera?: Camera): void;
  73688. /** @hidden */
  73689. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  73690. }
  73691. }
  73692. declare module "babylonjs/Shaders/refraction.fragment" {
  73693. /** @hidden */
  73694. export var refractionPixelShader: {
  73695. name: string;
  73696. shader: string;
  73697. };
  73698. }
  73699. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73700. import { Color3 } from "babylonjs/Maths/math.color";
  73701. import { Camera } from "babylonjs/Cameras/camera";
  73702. import { Texture } from "babylonjs/Materials/Textures/texture";
  73703. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73704. import { Engine } from "babylonjs/Engines/engine";
  73705. import "babylonjs/Shaders/refraction.fragment";
  73706. import { Scene } from "babylonjs/scene";
  73707. /**
  73708. * Post process which applies a refractin texture
  73709. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73710. */
  73711. export class RefractionPostProcess extends PostProcess {
  73712. private _refTexture;
  73713. private _ownRefractionTexture;
  73714. /** the base color of the refraction (used to taint the rendering) */
  73715. color: Color3;
  73716. /** simulated refraction depth */
  73717. depth: number;
  73718. /** the coefficient of the base color (0 to remove base color tainting) */
  73719. colorLevel: number;
  73720. /** Gets the url used to load the refraction texture */
  73721. refractionTextureUrl: string;
  73722. /**
  73723. * Gets or sets the refraction texture
  73724. * Please note that you are responsible for disposing the texture if you set it manually
  73725. */
  73726. get refractionTexture(): Texture;
  73727. set refractionTexture(value: Texture);
  73728. /**
  73729. * Gets a string identifying the name of the class
  73730. * @returns "RefractionPostProcess" string
  73731. */
  73732. getClassName(): string;
  73733. /**
  73734. * Initializes the RefractionPostProcess
  73735. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73736. * @param name The name of the effect.
  73737. * @param refractionTextureUrl Url of the refraction texture to use
  73738. * @param color the base color of the refraction (used to taint the rendering)
  73739. * @param depth simulated refraction depth
  73740. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  73741. * @param camera The camera to apply the render pass to.
  73742. * @param options The required width/height ratio to downsize to before computing the render pass.
  73743. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73744. * @param engine The engine which the post process will be applied. (default: current engine)
  73745. * @param reusable If the post process can be reused on the same frame. (default: false)
  73746. */
  73747. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73748. /**
  73749. * Disposes of the post process
  73750. * @param camera Camera to dispose post process on
  73751. */
  73752. dispose(camera: Camera): void;
  73753. /** @hidden */
  73754. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  73755. }
  73756. }
  73757. declare module "babylonjs/Shaders/sharpen.fragment" {
  73758. /** @hidden */
  73759. export var sharpenPixelShader: {
  73760. name: string;
  73761. shader: string;
  73762. };
  73763. }
  73764. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  73765. import { Nullable } from "babylonjs/types";
  73766. import { Camera } from "babylonjs/Cameras/camera";
  73767. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73768. import "babylonjs/Shaders/sharpen.fragment";
  73769. import { Engine } from "babylonjs/Engines/engine";
  73770. import { Scene } from "babylonjs/scene";
  73771. /**
  73772. * The SharpenPostProcess applies a sharpen kernel to every pixel
  73773. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73774. */
  73775. export class SharpenPostProcess extends PostProcess {
  73776. /**
  73777. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  73778. */
  73779. colorAmount: number;
  73780. /**
  73781. * How much sharpness should be applied (default: 0.3)
  73782. */
  73783. edgeAmount: number;
  73784. /**
  73785. * Gets a string identifying the name of the class
  73786. * @returns "SharpenPostProcess" string
  73787. */
  73788. getClassName(): string;
  73789. /**
  73790. * Creates a new instance ConvolutionPostProcess
  73791. * @param name The name of the effect.
  73792. * @param options The required width/height ratio to downsize to before computing the render pass.
  73793. * @param camera The camera to apply the render pass to.
  73794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73795. * @param engine The engine which the post process will be applied. (default: current engine)
  73796. * @param reusable If the post process can be reused on the same frame. (default: false)
  73797. * @param textureType Type of textures used when performing the post process. (default: 0)
  73798. * @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)
  73799. */
  73800. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73801. /** @hidden */
  73802. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  73803. }
  73804. }
  73805. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  73806. import { Nullable } from "babylonjs/types";
  73807. import { Camera } from "babylonjs/Cameras/camera";
  73808. import { Engine } from "babylonjs/Engines/engine";
  73809. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73810. import { IInspectable } from "babylonjs/Misc/iInspectable";
  73811. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  73812. /**
  73813. * PostProcessRenderPipeline
  73814. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73815. */
  73816. export class PostProcessRenderPipeline {
  73817. private engine;
  73818. private _renderEffects;
  73819. private _renderEffectsForIsolatedPass;
  73820. /**
  73821. * List of inspectable custom properties (used by the Inspector)
  73822. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73823. */
  73824. inspectableCustomProperties: IInspectable[];
  73825. /**
  73826. * @hidden
  73827. */
  73828. protected _cameras: Camera[];
  73829. /** @hidden */
  73830. _name: string;
  73831. /**
  73832. * Gets pipeline name
  73833. */
  73834. get name(): string;
  73835. /** Gets the list of attached cameras */
  73836. get cameras(): Camera[];
  73837. /**
  73838. * Initializes a PostProcessRenderPipeline
  73839. * @param engine engine to add the pipeline to
  73840. * @param name name of the pipeline
  73841. */
  73842. constructor(engine: Engine, name: string);
  73843. /**
  73844. * Gets the class name
  73845. * @returns "PostProcessRenderPipeline"
  73846. */
  73847. getClassName(): string;
  73848. /**
  73849. * If all the render effects in the pipeline are supported
  73850. */
  73851. get isSupported(): boolean;
  73852. /**
  73853. * Adds an effect to the pipeline
  73854. * @param renderEffect the effect to add
  73855. */
  73856. addEffect(renderEffect: PostProcessRenderEffect): void;
  73857. /** @hidden */
  73858. _rebuild(): void;
  73859. /** @hidden */
  73860. _enableEffect(renderEffectName: string, cameras: Camera): void;
  73861. /** @hidden */
  73862. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  73863. /** @hidden */
  73864. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73865. /** @hidden */
  73866. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73867. /** @hidden */
  73868. _attachCameras(cameras: Camera, unique: boolean): void;
  73869. /** @hidden */
  73870. _attachCameras(cameras: Camera[], unique: boolean): void;
  73871. /** @hidden */
  73872. _detachCameras(cameras: Camera): void;
  73873. /** @hidden */
  73874. _detachCameras(cameras: Nullable<Camera[]>): void;
  73875. /** @hidden */
  73876. _update(): void;
  73877. /** @hidden */
  73878. _reset(): void;
  73879. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  73880. /**
  73881. * Sets the required values to the prepass renderer.
  73882. * @param prePassRenderer defines the prepass renderer to setup.
  73883. * @returns true if the pre pass is needed.
  73884. */
  73885. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  73886. /**
  73887. * Disposes of the pipeline
  73888. */
  73889. dispose(): void;
  73890. }
  73891. }
  73892. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  73893. import { Camera } from "babylonjs/Cameras/camera";
  73894. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73895. /**
  73896. * PostProcessRenderPipelineManager class
  73897. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73898. */
  73899. export class PostProcessRenderPipelineManager {
  73900. private _renderPipelines;
  73901. /**
  73902. * Initializes a PostProcessRenderPipelineManager
  73903. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73904. */
  73905. constructor();
  73906. /**
  73907. * Gets the list of supported render pipelines
  73908. */
  73909. get supportedPipelines(): PostProcessRenderPipeline[];
  73910. /**
  73911. * Adds a pipeline to the manager
  73912. * @param renderPipeline The pipeline to add
  73913. */
  73914. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  73915. /**
  73916. * Attaches a camera to the pipeline
  73917. * @param renderPipelineName The name of the pipeline to attach to
  73918. * @param cameras the camera to attach
  73919. * @param unique if the camera can be attached multiple times to the pipeline
  73920. */
  73921. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  73922. /**
  73923. * Detaches a camera from the pipeline
  73924. * @param renderPipelineName The name of the pipeline to detach from
  73925. * @param cameras the camera to detach
  73926. */
  73927. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  73928. /**
  73929. * Enables an effect by name on a pipeline
  73930. * @param renderPipelineName the name of the pipeline to enable the effect in
  73931. * @param renderEffectName the name of the effect to enable
  73932. * @param cameras the cameras that the effect should be enabled on
  73933. */
  73934. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73935. /**
  73936. * Disables an effect by name on a pipeline
  73937. * @param renderPipelineName the name of the pipeline to disable the effect in
  73938. * @param renderEffectName the name of the effect to disable
  73939. * @param cameras the cameras that the effect should be disabled on
  73940. */
  73941. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73942. /**
  73943. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  73944. */
  73945. update(): void;
  73946. /** @hidden */
  73947. _rebuild(): void;
  73948. /**
  73949. * Disposes of the manager and pipelines
  73950. */
  73951. dispose(): void;
  73952. }
  73953. }
  73954. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  73955. import { ISceneComponent } from "babylonjs/sceneComponent";
  73956. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73957. import { Scene } from "babylonjs/scene";
  73958. module "babylonjs/scene" {
  73959. interface Scene {
  73960. /** @hidden (Backing field) */
  73961. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73962. /**
  73963. * Gets the postprocess render pipeline manager
  73964. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73965. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73966. */
  73967. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73968. }
  73969. }
  73970. /**
  73971. * Defines the Render Pipeline scene component responsible to rendering pipelines
  73972. */
  73973. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  73974. /**
  73975. * The component name helpfull to identify the component in the list of scene components.
  73976. */
  73977. readonly name: string;
  73978. /**
  73979. * The scene the component belongs to.
  73980. */
  73981. scene: Scene;
  73982. /**
  73983. * Creates a new instance of the component for the given scene
  73984. * @param scene Defines the scene to register the component in
  73985. */
  73986. constructor(scene: Scene);
  73987. /**
  73988. * Registers the component in a given scene
  73989. */
  73990. register(): void;
  73991. /**
  73992. * Rebuilds the elements related to this component in case of
  73993. * context lost for instance.
  73994. */
  73995. rebuild(): void;
  73996. /**
  73997. * Disposes the component and the associated ressources
  73998. */
  73999. dispose(): void;
  74000. private _gatherRenderTargets;
  74001. }
  74002. }
  74003. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74004. import { Nullable } from "babylonjs/types";
  74005. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74006. import { Camera } from "babylonjs/Cameras/camera";
  74007. import { IDisposable } from "babylonjs/scene";
  74008. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74009. import { Scene } from "babylonjs/scene";
  74010. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74011. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74012. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74013. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74014. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74015. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74016. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74017. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74018. import { Animation } from "babylonjs/Animations/animation";
  74019. /**
  74020. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74021. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74022. */
  74023. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74024. private _scene;
  74025. private _camerasToBeAttached;
  74026. /**
  74027. * ID of the sharpen post process,
  74028. */
  74029. private readonly SharpenPostProcessId;
  74030. /**
  74031. * @ignore
  74032. * ID of the image processing post process;
  74033. */
  74034. readonly ImageProcessingPostProcessId: string;
  74035. /**
  74036. * @ignore
  74037. * ID of the Fast Approximate Anti-Aliasing post process;
  74038. */
  74039. readonly FxaaPostProcessId: string;
  74040. /**
  74041. * ID of the chromatic aberration post process,
  74042. */
  74043. private readonly ChromaticAberrationPostProcessId;
  74044. /**
  74045. * ID of the grain post process
  74046. */
  74047. private readonly GrainPostProcessId;
  74048. /**
  74049. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74050. */
  74051. sharpen: SharpenPostProcess;
  74052. private _sharpenEffect;
  74053. private bloom;
  74054. /**
  74055. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74056. */
  74057. depthOfField: DepthOfFieldEffect;
  74058. /**
  74059. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74060. */
  74061. fxaa: FxaaPostProcess;
  74062. /**
  74063. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74064. */
  74065. imageProcessing: ImageProcessingPostProcess;
  74066. /**
  74067. * Chromatic aberration post process which will shift rgb colors in the image
  74068. */
  74069. chromaticAberration: ChromaticAberrationPostProcess;
  74070. private _chromaticAberrationEffect;
  74071. /**
  74072. * Grain post process which add noise to the image
  74073. */
  74074. grain: GrainPostProcess;
  74075. private _grainEffect;
  74076. /**
  74077. * Glow post process which adds a glow to emissive areas of the image
  74078. */
  74079. private _glowLayer;
  74080. /**
  74081. * Animations which can be used to tweak settings over a period of time
  74082. */
  74083. animations: Animation[];
  74084. private _imageProcessingConfigurationObserver;
  74085. private _sharpenEnabled;
  74086. private _bloomEnabled;
  74087. private _depthOfFieldEnabled;
  74088. private _depthOfFieldBlurLevel;
  74089. private _fxaaEnabled;
  74090. private _imageProcessingEnabled;
  74091. private _defaultPipelineTextureType;
  74092. private _bloomScale;
  74093. private _chromaticAberrationEnabled;
  74094. private _grainEnabled;
  74095. private _buildAllowed;
  74096. /**
  74097. * Gets active scene
  74098. */
  74099. get scene(): Scene;
  74100. /**
  74101. * Enable or disable the sharpen process from the pipeline
  74102. */
  74103. set sharpenEnabled(enabled: boolean);
  74104. get sharpenEnabled(): boolean;
  74105. private _resizeObserver;
  74106. private _hardwareScaleLevel;
  74107. private _bloomKernel;
  74108. /**
  74109. * Specifies the size of the bloom blur kernel, relative to the final output size
  74110. */
  74111. get bloomKernel(): number;
  74112. set bloomKernel(value: number);
  74113. /**
  74114. * Specifies the weight of the bloom in the final rendering
  74115. */
  74116. private _bloomWeight;
  74117. /**
  74118. * Specifies the luma threshold for the area that will be blurred by the bloom
  74119. */
  74120. private _bloomThreshold;
  74121. private _hdr;
  74122. /**
  74123. * The strength of the bloom.
  74124. */
  74125. set bloomWeight(value: number);
  74126. get bloomWeight(): number;
  74127. /**
  74128. * The strength of the bloom.
  74129. */
  74130. set bloomThreshold(value: number);
  74131. get bloomThreshold(): number;
  74132. /**
  74133. * The scale of the bloom, lower value will provide better performance.
  74134. */
  74135. set bloomScale(value: number);
  74136. get bloomScale(): number;
  74137. /**
  74138. * Enable or disable the bloom from the pipeline
  74139. */
  74140. set bloomEnabled(enabled: boolean);
  74141. get bloomEnabled(): boolean;
  74142. private _rebuildBloom;
  74143. /**
  74144. * If the depth of field is enabled.
  74145. */
  74146. get depthOfFieldEnabled(): boolean;
  74147. set depthOfFieldEnabled(enabled: boolean);
  74148. /**
  74149. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74150. */
  74151. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74152. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74153. /**
  74154. * If the anti aliasing is enabled.
  74155. */
  74156. set fxaaEnabled(enabled: boolean);
  74157. get fxaaEnabled(): boolean;
  74158. private _samples;
  74159. /**
  74160. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74161. */
  74162. set samples(sampleCount: number);
  74163. get samples(): number;
  74164. /**
  74165. * If image processing is enabled.
  74166. */
  74167. set imageProcessingEnabled(enabled: boolean);
  74168. get imageProcessingEnabled(): boolean;
  74169. /**
  74170. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74171. */
  74172. set glowLayerEnabled(enabled: boolean);
  74173. get glowLayerEnabled(): boolean;
  74174. /**
  74175. * Gets the glow layer (or null if not defined)
  74176. */
  74177. get glowLayer(): Nullable<GlowLayer>;
  74178. /**
  74179. * Enable or disable the chromaticAberration process from the pipeline
  74180. */
  74181. set chromaticAberrationEnabled(enabled: boolean);
  74182. get chromaticAberrationEnabled(): boolean;
  74183. /**
  74184. * Enable or disable the grain process from the pipeline
  74185. */
  74186. set grainEnabled(enabled: boolean);
  74187. get grainEnabled(): boolean;
  74188. /**
  74189. * @constructor
  74190. * @param name - The rendering pipeline name (default: "")
  74191. * @param hdr - If high dynamic range textures should be used (default: true)
  74192. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74193. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74194. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74195. */
  74196. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74197. /**
  74198. * Get the class name
  74199. * @returns "DefaultRenderingPipeline"
  74200. */
  74201. getClassName(): string;
  74202. /**
  74203. * Force the compilation of the entire pipeline.
  74204. */
  74205. prepare(): void;
  74206. private _hasCleared;
  74207. private _prevPostProcess;
  74208. private _prevPrevPostProcess;
  74209. private _setAutoClearAndTextureSharing;
  74210. private _depthOfFieldSceneObserver;
  74211. private _buildPipeline;
  74212. private _disposePostProcesses;
  74213. /**
  74214. * Adds a camera to the pipeline
  74215. * @param camera the camera to be added
  74216. */
  74217. addCamera(camera: Camera): void;
  74218. /**
  74219. * Removes a camera from the pipeline
  74220. * @param camera the camera to remove
  74221. */
  74222. removeCamera(camera: Camera): void;
  74223. /**
  74224. * Dispose of the pipeline and stop all post processes
  74225. */
  74226. dispose(): void;
  74227. /**
  74228. * Serialize the rendering pipeline (Used when exporting)
  74229. * @returns the serialized object
  74230. */
  74231. serialize(): any;
  74232. /**
  74233. * Parse the serialized pipeline
  74234. * @param source Source pipeline.
  74235. * @param scene The scene to load the pipeline to.
  74236. * @param rootUrl The URL of the serialized pipeline.
  74237. * @returns An instantiated pipeline from the serialized object.
  74238. */
  74239. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74240. }
  74241. }
  74242. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74243. /** @hidden */
  74244. export var lensHighlightsPixelShader: {
  74245. name: string;
  74246. shader: string;
  74247. };
  74248. }
  74249. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74250. /** @hidden */
  74251. export var depthOfFieldPixelShader: {
  74252. name: string;
  74253. shader: string;
  74254. };
  74255. }
  74256. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74257. import { Camera } from "babylonjs/Cameras/camera";
  74258. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74259. import { Scene } from "babylonjs/scene";
  74260. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74261. import "babylonjs/Shaders/chromaticAberration.fragment";
  74262. import "babylonjs/Shaders/lensHighlights.fragment";
  74263. import "babylonjs/Shaders/depthOfField.fragment";
  74264. /**
  74265. * BABYLON.JS Chromatic Aberration GLSL Shader
  74266. * Author: Olivier Guyot
  74267. * Separates very slightly R, G and B colors on the edges of the screen
  74268. * Inspired by Francois Tarlier & Martins Upitis
  74269. */
  74270. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74271. /**
  74272. * @ignore
  74273. * The chromatic aberration PostProcess id in the pipeline
  74274. */
  74275. LensChromaticAberrationEffect: string;
  74276. /**
  74277. * @ignore
  74278. * The highlights enhancing PostProcess id in the pipeline
  74279. */
  74280. HighlightsEnhancingEffect: string;
  74281. /**
  74282. * @ignore
  74283. * The depth-of-field PostProcess id in the pipeline
  74284. */
  74285. LensDepthOfFieldEffect: string;
  74286. private _scene;
  74287. private _depthTexture;
  74288. private _grainTexture;
  74289. private _chromaticAberrationPostProcess;
  74290. private _highlightsPostProcess;
  74291. private _depthOfFieldPostProcess;
  74292. private _edgeBlur;
  74293. private _grainAmount;
  74294. private _chromaticAberration;
  74295. private _distortion;
  74296. private _highlightsGain;
  74297. private _highlightsThreshold;
  74298. private _dofDistance;
  74299. private _dofAperture;
  74300. private _dofDarken;
  74301. private _dofPentagon;
  74302. private _blurNoise;
  74303. /**
  74304. * @constructor
  74305. *
  74306. * Effect parameters are as follow:
  74307. * {
  74308. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74309. * edge_blur: number; // from 0 to x (1 for realism)
  74310. * distortion: number; // from 0 to x (1 for realism)
  74311. * grain_amount: number; // from 0 to 1
  74312. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74313. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74314. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74315. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74316. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74317. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74318. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74319. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74320. * }
  74321. * Note: if an effect parameter is unset, effect is disabled
  74322. *
  74323. * @param name The rendering pipeline name
  74324. * @param parameters - An object containing all parameters (see above)
  74325. * @param scene The scene linked to this pipeline
  74326. * @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)
  74327. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74328. */
  74329. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74330. /**
  74331. * Get the class name
  74332. * @returns "LensRenderingPipeline"
  74333. */
  74334. getClassName(): string;
  74335. /**
  74336. * Gets associated scene
  74337. */
  74338. get scene(): Scene;
  74339. /**
  74340. * Gets or sets the edge blur
  74341. */
  74342. get edgeBlur(): number;
  74343. set edgeBlur(value: number);
  74344. /**
  74345. * Gets or sets the grain amount
  74346. */
  74347. get grainAmount(): number;
  74348. set grainAmount(value: number);
  74349. /**
  74350. * Gets or sets the chromatic aberration amount
  74351. */
  74352. get chromaticAberration(): number;
  74353. set chromaticAberration(value: number);
  74354. /**
  74355. * Gets or sets the depth of field aperture
  74356. */
  74357. get dofAperture(): number;
  74358. set dofAperture(value: number);
  74359. /**
  74360. * Gets or sets the edge distortion
  74361. */
  74362. get edgeDistortion(): number;
  74363. set edgeDistortion(value: number);
  74364. /**
  74365. * Gets or sets the depth of field distortion
  74366. */
  74367. get dofDistortion(): number;
  74368. set dofDistortion(value: number);
  74369. /**
  74370. * Gets or sets the darken out of focus amount
  74371. */
  74372. get darkenOutOfFocus(): number;
  74373. set darkenOutOfFocus(value: number);
  74374. /**
  74375. * Gets or sets a boolean indicating if blur noise is enabled
  74376. */
  74377. get blurNoise(): boolean;
  74378. set blurNoise(value: boolean);
  74379. /**
  74380. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74381. */
  74382. get pentagonBokeh(): boolean;
  74383. set pentagonBokeh(value: boolean);
  74384. /**
  74385. * Gets or sets the highlight grain amount
  74386. */
  74387. get highlightsGain(): number;
  74388. set highlightsGain(value: number);
  74389. /**
  74390. * Gets or sets the highlight threshold
  74391. */
  74392. get highlightsThreshold(): number;
  74393. set highlightsThreshold(value: number);
  74394. /**
  74395. * Sets the amount of blur at the edges
  74396. * @param amount blur amount
  74397. */
  74398. setEdgeBlur(amount: number): void;
  74399. /**
  74400. * Sets edge blur to 0
  74401. */
  74402. disableEdgeBlur(): void;
  74403. /**
  74404. * Sets the amout of grain
  74405. * @param amount Amount of grain
  74406. */
  74407. setGrainAmount(amount: number): void;
  74408. /**
  74409. * Set grain amount to 0
  74410. */
  74411. disableGrain(): void;
  74412. /**
  74413. * Sets the chromatic aberration amount
  74414. * @param amount amount of chromatic aberration
  74415. */
  74416. setChromaticAberration(amount: number): void;
  74417. /**
  74418. * Sets chromatic aberration amount to 0
  74419. */
  74420. disableChromaticAberration(): void;
  74421. /**
  74422. * Sets the EdgeDistortion amount
  74423. * @param amount amount of EdgeDistortion
  74424. */
  74425. setEdgeDistortion(amount: number): void;
  74426. /**
  74427. * Sets edge distortion to 0
  74428. */
  74429. disableEdgeDistortion(): void;
  74430. /**
  74431. * Sets the FocusDistance amount
  74432. * @param amount amount of FocusDistance
  74433. */
  74434. setFocusDistance(amount: number): void;
  74435. /**
  74436. * Disables depth of field
  74437. */
  74438. disableDepthOfField(): void;
  74439. /**
  74440. * Sets the Aperture amount
  74441. * @param amount amount of Aperture
  74442. */
  74443. setAperture(amount: number): void;
  74444. /**
  74445. * Sets the DarkenOutOfFocus amount
  74446. * @param amount amount of DarkenOutOfFocus
  74447. */
  74448. setDarkenOutOfFocus(amount: number): void;
  74449. private _pentagonBokehIsEnabled;
  74450. /**
  74451. * Creates a pentagon bokeh effect
  74452. */
  74453. enablePentagonBokeh(): void;
  74454. /**
  74455. * Disables the pentagon bokeh effect
  74456. */
  74457. disablePentagonBokeh(): void;
  74458. /**
  74459. * Enables noise blur
  74460. */
  74461. enableNoiseBlur(): void;
  74462. /**
  74463. * Disables noise blur
  74464. */
  74465. disableNoiseBlur(): void;
  74466. /**
  74467. * Sets the HighlightsGain amount
  74468. * @param amount amount of HighlightsGain
  74469. */
  74470. setHighlightsGain(amount: number): void;
  74471. /**
  74472. * Sets the HighlightsThreshold amount
  74473. * @param amount amount of HighlightsThreshold
  74474. */
  74475. setHighlightsThreshold(amount: number): void;
  74476. /**
  74477. * Disables highlights
  74478. */
  74479. disableHighlights(): void;
  74480. /**
  74481. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74482. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74483. */
  74484. dispose(disableDepthRender?: boolean): void;
  74485. private _createChromaticAberrationPostProcess;
  74486. private _createHighlightsPostProcess;
  74487. private _createDepthOfFieldPostProcess;
  74488. private _createGrainTexture;
  74489. }
  74490. }
  74491. declare module "babylonjs/Shaders/ssao2.fragment" {
  74492. /** @hidden */
  74493. export var ssao2PixelShader: {
  74494. name: string;
  74495. shader: string;
  74496. };
  74497. }
  74498. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74499. /** @hidden */
  74500. export var ssaoCombinePixelShader: {
  74501. name: string;
  74502. shader: string;
  74503. };
  74504. }
  74505. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74506. import { Camera } from "babylonjs/Cameras/camera";
  74507. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74508. import { Scene } from "babylonjs/scene";
  74509. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74510. import "babylonjs/Shaders/ssao2.fragment";
  74511. import "babylonjs/Shaders/ssaoCombine.fragment";
  74512. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74513. /**
  74514. * Render pipeline to produce ssao effect
  74515. */
  74516. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74517. /**
  74518. * @ignore
  74519. * The PassPostProcess id in the pipeline that contains the original scene color
  74520. */
  74521. SSAOOriginalSceneColorEffect: string;
  74522. /**
  74523. * @ignore
  74524. * The SSAO PostProcess id in the pipeline
  74525. */
  74526. SSAORenderEffect: string;
  74527. /**
  74528. * @ignore
  74529. * The horizontal blur PostProcess id in the pipeline
  74530. */
  74531. SSAOBlurHRenderEffect: string;
  74532. /**
  74533. * @ignore
  74534. * The vertical blur PostProcess id in the pipeline
  74535. */
  74536. SSAOBlurVRenderEffect: string;
  74537. /**
  74538. * @ignore
  74539. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74540. */
  74541. SSAOCombineRenderEffect: string;
  74542. /**
  74543. * The output strength of the SSAO post-process. Default value is 1.0.
  74544. */
  74545. totalStrength: number;
  74546. /**
  74547. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74548. */
  74549. maxZ: number;
  74550. /**
  74551. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74552. */
  74553. minZAspect: number;
  74554. private _samples;
  74555. /**
  74556. * Number of samples used for the SSAO calculations. Default value is 8
  74557. */
  74558. set samples(n: number);
  74559. get samples(): number;
  74560. private _textureSamples;
  74561. /**
  74562. * Number of samples to use for antialiasing
  74563. */
  74564. set textureSamples(n: number);
  74565. get textureSamples(): number;
  74566. /**
  74567. * Force rendering the geometry through geometry buffer
  74568. */
  74569. private _forceGeometryBuffer;
  74570. /**
  74571. * Ratio object used for SSAO ratio and blur ratio
  74572. */
  74573. private _ratio;
  74574. /**
  74575. * Dynamically generated sphere sampler.
  74576. */
  74577. private _sampleSphere;
  74578. /**
  74579. * Blur filter offsets
  74580. */
  74581. private _samplerOffsets;
  74582. private _expensiveBlur;
  74583. /**
  74584. * If bilateral blur should be used
  74585. */
  74586. set expensiveBlur(b: boolean);
  74587. get expensiveBlur(): boolean;
  74588. /**
  74589. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74590. */
  74591. radius: number;
  74592. /**
  74593. * The base color of the SSAO post-process
  74594. * The final result is "base + ssao" between [0, 1]
  74595. */
  74596. base: number;
  74597. /**
  74598. * Support test.
  74599. */
  74600. static get IsSupported(): boolean;
  74601. private _scene;
  74602. private _randomTexture;
  74603. private _originalColorPostProcess;
  74604. private _ssaoPostProcess;
  74605. private _blurHPostProcess;
  74606. private _blurVPostProcess;
  74607. private _ssaoCombinePostProcess;
  74608. private _prePassRenderer;
  74609. /**
  74610. * Gets active scene
  74611. */
  74612. get scene(): Scene;
  74613. /**
  74614. * @constructor
  74615. * @param name The rendering pipeline name
  74616. * @param scene The scene linked to this pipeline
  74617. * @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 }
  74618. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74619. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74620. */
  74621. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74622. /**
  74623. * Get the class name
  74624. * @returns "SSAO2RenderingPipeline"
  74625. */
  74626. getClassName(): string;
  74627. /**
  74628. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74629. */
  74630. dispose(disableGeometryBufferRenderer?: boolean): void;
  74631. private _createBlurPostProcess;
  74632. /** @hidden */
  74633. _rebuild(): void;
  74634. private _bits;
  74635. private _radicalInverse_VdC;
  74636. private _hammersley;
  74637. private _hemisphereSample_uniform;
  74638. private _generateHemisphere;
  74639. private _getDefinesForSSAO;
  74640. private _createSSAOPostProcess;
  74641. private _createSSAOCombinePostProcess;
  74642. private _createRandomTexture;
  74643. /**
  74644. * Serialize the rendering pipeline (Used when exporting)
  74645. * @returns the serialized object
  74646. */
  74647. serialize(): any;
  74648. /**
  74649. * Parse the serialized pipeline
  74650. * @param source Source pipeline.
  74651. * @param scene The scene to load the pipeline to.
  74652. * @param rootUrl The URL of the serialized pipeline.
  74653. * @returns An instantiated pipeline from the serialized object.
  74654. */
  74655. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74656. /**
  74657. * Sets the required values to the prepass renderer.
  74658. * @param prePassRenderer defines the prepass renderer to setup
  74659. * @returns true if the pre pass is needed.
  74660. */
  74661. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74662. }
  74663. }
  74664. declare module "babylonjs/Shaders/ssao.fragment" {
  74665. /** @hidden */
  74666. export var ssaoPixelShader: {
  74667. name: string;
  74668. shader: string;
  74669. };
  74670. }
  74671. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74672. import { Camera } from "babylonjs/Cameras/camera";
  74673. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74674. import { Scene } from "babylonjs/scene";
  74675. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74676. import "babylonjs/Shaders/ssao.fragment";
  74677. import "babylonjs/Shaders/ssaoCombine.fragment";
  74678. /**
  74679. * Render pipeline to produce ssao effect
  74680. */
  74681. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74682. /**
  74683. * @ignore
  74684. * The PassPostProcess id in the pipeline that contains the original scene color
  74685. */
  74686. SSAOOriginalSceneColorEffect: string;
  74687. /**
  74688. * @ignore
  74689. * The SSAO PostProcess id in the pipeline
  74690. */
  74691. SSAORenderEffect: string;
  74692. /**
  74693. * @ignore
  74694. * The horizontal blur PostProcess id in the pipeline
  74695. */
  74696. SSAOBlurHRenderEffect: string;
  74697. /**
  74698. * @ignore
  74699. * The vertical blur PostProcess id in the pipeline
  74700. */
  74701. SSAOBlurVRenderEffect: string;
  74702. /**
  74703. * @ignore
  74704. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74705. */
  74706. SSAOCombineRenderEffect: string;
  74707. /**
  74708. * The output strength of the SSAO post-process. Default value is 1.0.
  74709. */
  74710. totalStrength: number;
  74711. /**
  74712. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74713. */
  74714. radius: number;
  74715. /**
  74716. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74717. * Must not be equal to fallOff and superior to fallOff.
  74718. * Default value is 0.0075
  74719. */
  74720. area: number;
  74721. /**
  74722. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74723. * Must not be equal to area and inferior to area.
  74724. * Default value is 0.000001
  74725. */
  74726. fallOff: number;
  74727. /**
  74728. * The base color of the SSAO post-process
  74729. * The final result is "base + ssao" between [0, 1]
  74730. */
  74731. base: number;
  74732. private _scene;
  74733. private _depthTexture;
  74734. private _randomTexture;
  74735. private _originalColorPostProcess;
  74736. private _ssaoPostProcess;
  74737. private _blurHPostProcess;
  74738. private _blurVPostProcess;
  74739. private _ssaoCombinePostProcess;
  74740. private _firstUpdate;
  74741. /**
  74742. * Gets active scene
  74743. */
  74744. get scene(): Scene;
  74745. /**
  74746. * @constructor
  74747. * @param name - The rendering pipeline name
  74748. * @param scene - The scene linked to this pipeline
  74749. * @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 }
  74750. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  74751. */
  74752. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  74753. /**
  74754. * Get the class name
  74755. * @returns "SSAORenderingPipeline"
  74756. */
  74757. getClassName(): string;
  74758. /**
  74759. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74760. */
  74761. dispose(disableDepthRender?: boolean): void;
  74762. private _createBlurPostProcess;
  74763. /** @hidden */
  74764. _rebuild(): void;
  74765. private _createSSAOPostProcess;
  74766. private _createSSAOCombinePostProcess;
  74767. private _createRandomTexture;
  74768. }
  74769. }
  74770. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  74771. /** @hidden */
  74772. export var screenSpaceReflectionPixelShader: {
  74773. name: string;
  74774. shader: string;
  74775. };
  74776. }
  74777. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  74778. import { Nullable } from "babylonjs/types";
  74779. import { Camera } from "babylonjs/Cameras/camera";
  74780. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74781. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  74782. import { Engine } from "babylonjs/Engines/engine";
  74783. import { Scene } from "babylonjs/scene";
  74784. /**
  74785. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  74786. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  74787. */
  74788. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  74789. /**
  74790. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  74791. */
  74792. threshold: number;
  74793. /**
  74794. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  74795. */
  74796. strength: number;
  74797. /**
  74798. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  74799. */
  74800. reflectionSpecularFalloffExponent: number;
  74801. /**
  74802. * 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]
  74803. */
  74804. step: number;
  74805. /**
  74806. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  74807. */
  74808. roughnessFactor: number;
  74809. private _geometryBufferRenderer;
  74810. private _enableSmoothReflections;
  74811. private _reflectionSamples;
  74812. private _smoothSteps;
  74813. /**
  74814. * Gets a string identifying the name of the class
  74815. * @returns "ScreenSpaceReflectionPostProcess" string
  74816. */
  74817. getClassName(): string;
  74818. /**
  74819. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  74820. * @param name The name of the effect.
  74821. * @param scene The scene containing the objects to calculate reflections.
  74822. * @param options The required width/height ratio to downsize to before computing the render pass.
  74823. * @param camera The camera to apply the render pass to.
  74824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74825. * @param engine The engine which the post process will be applied. (default: current engine)
  74826. * @param reusable If the post process can be reused on the same frame. (default: false)
  74827. * @param textureType Type of textures used when performing the post process. (default: 0)
  74828. * @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)
  74829. */
  74830. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74831. /**
  74832. * Gets wether or not smoothing reflections is enabled.
  74833. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74834. */
  74835. get enableSmoothReflections(): boolean;
  74836. /**
  74837. * Sets wether or not smoothing reflections is enabled.
  74838. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74839. */
  74840. set enableSmoothReflections(enabled: boolean);
  74841. /**
  74842. * Gets the number of samples taken while computing reflections. More samples count is high,
  74843. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74844. */
  74845. get reflectionSamples(): number;
  74846. /**
  74847. * Sets the number of samples taken while computing reflections. More samples count is high,
  74848. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74849. */
  74850. set reflectionSamples(samples: number);
  74851. /**
  74852. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  74853. * more the post-process will require GPU power and can generate a drop in FPS.
  74854. * Default value (5.0) work pretty well in all cases but can be adjusted.
  74855. */
  74856. get smoothSteps(): number;
  74857. set smoothSteps(steps: number);
  74858. private _updateEffectDefines;
  74859. /** @hidden */
  74860. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  74861. }
  74862. }
  74863. declare module "babylonjs/Shaders/standard.fragment" {
  74864. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  74865. /** @hidden */
  74866. export var standardPixelShader: {
  74867. name: string;
  74868. shader: string;
  74869. };
  74870. }
  74871. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  74872. import { Nullable } from "babylonjs/types";
  74873. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74874. import { Camera } from "babylonjs/Cameras/camera";
  74875. import { Texture } from "babylonjs/Materials/Textures/texture";
  74876. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74877. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74878. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74879. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74880. import { IDisposable } from "babylonjs/scene";
  74881. import { SpotLight } from "babylonjs/Lights/spotLight";
  74882. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  74883. import { Scene } from "babylonjs/scene";
  74884. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74885. import { Animation } from "babylonjs/Animations/animation";
  74886. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74887. import "babylonjs/Shaders/standard.fragment";
  74888. /**
  74889. * Standard rendering pipeline
  74890. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74891. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  74892. */
  74893. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74894. /**
  74895. * Public members
  74896. */
  74897. /**
  74898. * Post-process which contains the original scene color before the pipeline applies all the effects
  74899. */
  74900. originalPostProcess: Nullable<PostProcess>;
  74901. /**
  74902. * Post-process used to down scale an image x4
  74903. */
  74904. downSampleX4PostProcess: Nullable<PostProcess>;
  74905. /**
  74906. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  74907. */
  74908. brightPassPostProcess: Nullable<PostProcess>;
  74909. /**
  74910. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  74911. */
  74912. blurHPostProcesses: PostProcess[];
  74913. /**
  74914. * Post-process array storing all the vertical blur post-processes used by the pipeline
  74915. */
  74916. blurVPostProcesses: PostProcess[];
  74917. /**
  74918. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  74919. */
  74920. textureAdderPostProcess: Nullable<PostProcess>;
  74921. /**
  74922. * Post-process used to create volumetric lighting effect
  74923. */
  74924. volumetricLightPostProcess: Nullable<PostProcess>;
  74925. /**
  74926. * Post-process used to smooth the previous volumetric light post-process on the X axis
  74927. */
  74928. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  74929. /**
  74930. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  74931. */
  74932. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  74933. /**
  74934. * Post-process used to merge the volumetric light effect and the real scene color
  74935. */
  74936. volumetricLightMergePostProces: Nullable<PostProcess>;
  74937. /**
  74938. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  74939. */
  74940. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  74941. /**
  74942. * Base post-process used to calculate the average luminance of the final image for HDR
  74943. */
  74944. luminancePostProcess: Nullable<PostProcess>;
  74945. /**
  74946. * Post-processes used to create down sample post-processes in order to get
  74947. * the average luminance of the final image for HDR
  74948. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  74949. */
  74950. luminanceDownSamplePostProcesses: PostProcess[];
  74951. /**
  74952. * Post-process used to create a HDR effect (light adaptation)
  74953. */
  74954. hdrPostProcess: Nullable<PostProcess>;
  74955. /**
  74956. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  74957. */
  74958. textureAdderFinalPostProcess: Nullable<PostProcess>;
  74959. /**
  74960. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  74961. */
  74962. lensFlareFinalPostProcess: Nullable<PostProcess>;
  74963. /**
  74964. * Post-process used to merge the final HDR post-process and the real scene color
  74965. */
  74966. hdrFinalPostProcess: Nullable<PostProcess>;
  74967. /**
  74968. * Post-process used to create a lens flare effect
  74969. */
  74970. lensFlarePostProcess: Nullable<PostProcess>;
  74971. /**
  74972. * Post-process that merges the result of the lens flare post-process and the real scene color
  74973. */
  74974. lensFlareComposePostProcess: Nullable<PostProcess>;
  74975. /**
  74976. * Post-process used to create a motion blur effect
  74977. */
  74978. motionBlurPostProcess: Nullable<PostProcess>;
  74979. /**
  74980. * Post-process used to create a depth of field effect
  74981. */
  74982. depthOfFieldPostProcess: Nullable<PostProcess>;
  74983. /**
  74984. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74985. */
  74986. fxaaPostProcess: Nullable<FxaaPostProcess>;
  74987. /**
  74988. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  74989. */
  74990. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  74991. /**
  74992. * Represents the brightness threshold in order to configure the illuminated surfaces
  74993. */
  74994. brightThreshold: number;
  74995. /**
  74996. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  74997. */
  74998. blurWidth: number;
  74999. /**
  75000. * Sets if the blur for highlighted surfaces must be only horizontal
  75001. */
  75002. horizontalBlur: boolean;
  75003. /**
  75004. * Gets the overall exposure used by the pipeline
  75005. */
  75006. get exposure(): number;
  75007. /**
  75008. * Sets the overall exposure used by the pipeline
  75009. */
  75010. set exposure(value: number);
  75011. /**
  75012. * Texture used typically to simulate "dirty" on camera lens
  75013. */
  75014. lensTexture: Nullable<Texture>;
  75015. /**
  75016. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75017. */
  75018. volumetricLightCoefficient: number;
  75019. /**
  75020. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75021. */
  75022. volumetricLightPower: number;
  75023. /**
  75024. * Used the set the blur intensity to smooth the volumetric lights
  75025. */
  75026. volumetricLightBlurScale: number;
  75027. /**
  75028. * Light (spot or directional) used to generate the volumetric lights rays
  75029. * The source light must have a shadow generate so the pipeline can get its
  75030. * depth map
  75031. */
  75032. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75033. /**
  75034. * For eye adaptation, represents the minimum luminance the eye can see
  75035. */
  75036. hdrMinimumLuminance: number;
  75037. /**
  75038. * For eye adaptation, represents the decrease luminance speed
  75039. */
  75040. hdrDecreaseRate: number;
  75041. /**
  75042. * For eye adaptation, represents the increase luminance speed
  75043. */
  75044. hdrIncreaseRate: number;
  75045. /**
  75046. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75047. */
  75048. get hdrAutoExposure(): boolean;
  75049. /**
  75050. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75051. */
  75052. set hdrAutoExposure(value: boolean);
  75053. /**
  75054. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75055. */
  75056. lensColorTexture: Nullable<Texture>;
  75057. /**
  75058. * The overall strengh for the lens flare effect
  75059. */
  75060. lensFlareStrength: number;
  75061. /**
  75062. * Dispersion coefficient for lens flare ghosts
  75063. */
  75064. lensFlareGhostDispersal: number;
  75065. /**
  75066. * Main lens flare halo width
  75067. */
  75068. lensFlareHaloWidth: number;
  75069. /**
  75070. * Based on the lens distortion effect, defines how much the lens flare result
  75071. * is distorted
  75072. */
  75073. lensFlareDistortionStrength: number;
  75074. /**
  75075. * Configures the blur intensity used for for lens flare (halo)
  75076. */
  75077. lensFlareBlurWidth: number;
  75078. /**
  75079. * Lens star texture must be used to simulate rays on the flares and is available
  75080. * in the documentation
  75081. */
  75082. lensStarTexture: Nullable<Texture>;
  75083. /**
  75084. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75085. * flare effect by taking account of the dirt texture
  75086. */
  75087. lensFlareDirtTexture: Nullable<Texture>;
  75088. /**
  75089. * Represents the focal length for the depth of field effect
  75090. */
  75091. depthOfFieldDistance: number;
  75092. /**
  75093. * Represents the blur intensity for the blurred part of the depth of field effect
  75094. */
  75095. depthOfFieldBlurWidth: number;
  75096. /**
  75097. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75098. */
  75099. get motionStrength(): number;
  75100. /**
  75101. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75102. */
  75103. set motionStrength(strength: number);
  75104. /**
  75105. * Gets wether or not the motion blur post-process is object based or screen based.
  75106. */
  75107. get objectBasedMotionBlur(): boolean;
  75108. /**
  75109. * Sets wether or not the motion blur post-process should be object based or screen based
  75110. */
  75111. set objectBasedMotionBlur(value: boolean);
  75112. /**
  75113. * List of animations for the pipeline (IAnimatable implementation)
  75114. */
  75115. animations: Animation[];
  75116. /**
  75117. * Private members
  75118. */
  75119. private _scene;
  75120. private _currentDepthOfFieldSource;
  75121. private _basePostProcess;
  75122. private _fixedExposure;
  75123. private _currentExposure;
  75124. private _hdrAutoExposure;
  75125. private _hdrCurrentLuminance;
  75126. private _motionStrength;
  75127. private _isObjectBasedMotionBlur;
  75128. private _floatTextureType;
  75129. private _camerasToBeAttached;
  75130. private _ratio;
  75131. private _bloomEnabled;
  75132. private _depthOfFieldEnabled;
  75133. private _vlsEnabled;
  75134. private _lensFlareEnabled;
  75135. private _hdrEnabled;
  75136. private _motionBlurEnabled;
  75137. private _fxaaEnabled;
  75138. private _screenSpaceReflectionsEnabled;
  75139. private _motionBlurSamples;
  75140. private _volumetricLightStepsCount;
  75141. private _samples;
  75142. /**
  75143. * @ignore
  75144. * Specifies if the bloom pipeline is enabled
  75145. */
  75146. get BloomEnabled(): boolean;
  75147. set BloomEnabled(enabled: boolean);
  75148. /**
  75149. * @ignore
  75150. * Specifies if the depth of field pipeline is enabed
  75151. */
  75152. get DepthOfFieldEnabled(): boolean;
  75153. set DepthOfFieldEnabled(enabled: boolean);
  75154. /**
  75155. * @ignore
  75156. * Specifies if the lens flare pipeline is enabed
  75157. */
  75158. get LensFlareEnabled(): boolean;
  75159. set LensFlareEnabled(enabled: boolean);
  75160. /**
  75161. * @ignore
  75162. * Specifies if the HDR pipeline is enabled
  75163. */
  75164. get HDREnabled(): boolean;
  75165. set HDREnabled(enabled: boolean);
  75166. /**
  75167. * @ignore
  75168. * Specifies if the volumetric lights scattering effect is enabled
  75169. */
  75170. get VLSEnabled(): boolean;
  75171. set VLSEnabled(enabled: boolean);
  75172. /**
  75173. * @ignore
  75174. * Specifies if the motion blur effect is enabled
  75175. */
  75176. get MotionBlurEnabled(): boolean;
  75177. set MotionBlurEnabled(enabled: boolean);
  75178. /**
  75179. * Specifies if anti-aliasing is enabled
  75180. */
  75181. get fxaaEnabled(): boolean;
  75182. set fxaaEnabled(enabled: boolean);
  75183. /**
  75184. * Specifies if screen space reflections are enabled.
  75185. */
  75186. get screenSpaceReflectionsEnabled(): boolean;
  75187. set screenSpaceReflectionsEnabled(enabled: boolean);
  75188. /**
  75189. * Specifies the number of steps used to calculate the volumetric lights
  75190. * Typically in interval [50, 200]
  75191. */
  75192. get volumetricLightStepsCount(): number;
  75193. set volumetricLightStepsCount(count: number);
  75194. /**
  75195. * Specifies the number of samples used for the motion blur effect
  75196. * Typically in interval [16, 64]
  75197. */
  75198. get motionBlurSamples(): number;
  75199. set motionBlurSamples(samples: number);
  75200. /**
  75201. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75202. */
  75203. get samples(): number;
  75204. set samples(sampleCount: number);
  75205. /**
  75206. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75207. * @constructor
  75208. * @param name The rendering pipeline name
  75209. * @param scene The scene linked to this pipeline
  75210. * @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)
  75211. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75212. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75213. */
  75214. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75215. private _buildPipeline;
  75216. private _createDownSampleX4PostProcess;
  75217. private _createBrightPassPostProcess;
  75218. private _createBlurPostProcesses;
  75219. private _createTextureAdderPostProcess;
  75220. private _createVolumetricLightPostProcess;
  75221. private _createLuminancePostProcesses;
  75222. private _createHdrPostProcess;
  75223. private _createLensFlarePostProcess;
  75224. private _createDepthOfFieldPostProcess;
  75225. private _createMotionBlurPostProcess;
  75226. private _getDepthTexture;
  75227. private _disposePostProcesses;
  75228. /**
  75229. * Dispose of the pipeline and stop all post processes
  75230. */
  75231. dispose(): void;
  75232. /**
  75233. * Serialize the rendering pipeline (Used when exporting)
  75234. * @returns the serialized object
  75235. */
  75236. serialize(): any;
  75237. /**
  75238. * Parse the serialized pipeline
  75239. * @param source Source pipeline.
  75240. * @param scene The scene to load the pipeline to.
  75241. * @param rootUrl The URL of the serialized pipeline.
  75242. * @returns An instantiated pipeline from the serialized object.
  75243. */
  75244. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75245. /**
  75246. * Luminance steps
  75247. */
  75248. static LuminanceSteps: number;
  75249. }
  75250. }
  75251. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75252. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75253. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75254. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75255. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75256. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75257. }
  75258. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75259. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75260. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75261. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75262. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75263. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75264. }
  75265. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75266. /** @hidden */
  75267. export var stereoscopicInterlacePixelShader: {
  75268. name: string;
  75269. shader: string;
  75270. };
  75271. }
  75272. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75273. import { Camera } from "babylonjs/Cameras/camera";
  75274. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75275. import { Engine } from "babylonjs/Engines/engine";
  75276. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75277. /**
  75278. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75279. */
  75280. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75281. private _stepSize;
  75282. private _passedProcess;
  75283. /**
  75284. * Gets a string identifying the name of the class
  75285. * @returns "StereoscopicInterlacePostProcessI" string
  75286. */
  75287. getClassName(): string;
  75288. /**
  75289. * Initializes a StereoscopicInterlacePostProcessI
  75290. * @param name The name of the effect.
  75291. * @param rigCameras The rig cameras to be appled to the post process
  75292. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75293. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75295. * @param engine The engine which the post process will be applied. (default: current engine)
  75296. * @param reusable If the post process can be reused on the same frame. (default: false)
  75297. */
  75298. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75299. }
  75300. /**
  75301. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75302. */
  75303. export class StereoscopicInterlacePostProcess extends PostProcess {
  75304. private _stepSize;
  75305. private _passedProcess;
  75306. /**
  75307. * Gets a string identifying the name of the class
  75308. * @returns "StereoscopicInterlacePostProcess" string
  75309. */
  75310. getClassName(): string;
  75311. /**
  75312. * Initializes a StereoscopicInterlacePostProcess
  75313. * @param name The name of the effect.
  75314. * @param rigCameras The rig cameras to be appled to the post process
  75315. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75317. * @param engine The engine which the post process will be applied. (default: current engine)
  75318. * @param reusable If the post process can be reused on the same frame. (default: false)
  75319. */
  75320. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75321. }
  75322. }
  75323. declare module "babylonjs/Shaders/tonemap.fragment" {
  75324. /** @hidden */
  75325. export var tonemapPixelShader: {
  75326. name: string;
  75327. shader: string;
  75328. };
  75329. }
  75330. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75331. import { Camera } from "babylonjs/Cameras/camera";
  75332. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75333. import "babylonjs/Shaders/tonemap.fragment";
  75334. import { Engine } from "babylonjs/Engines/engine";
  75335. /** Defines operator used for tonemapping */
  75336. export enum TonemappingOperator {
  75337. /** Hable */
  75338. Hable = 0,
  75339. /** Reinhard */
  75340. Reinhard = 1,
  75341. /** HejiDawson */
  75342. HejiDawson = 2,
  75343. /** Photographic */
  75344. Photographic = 3
  75345. }
  75346. /**
  75347. * Defines a post process to apply tone mapping
  75348. */
  75349. export class TonemapPostProcess extends PostProcess {
  75350. private _operator;
  75351. /** Defines the required exposure adjustement */
  75352. exposureAdjustment: number;
  75353. /**
  75354. * Gets a string identifying the name of the class
  75355. * @returns "TonemapPostProcess" string
  75356. */
  75357. getClassName(): string;
  75358. /**
  75359. * Creates a new TonemapPostProcess
  75360. * @param name defines the name of the postprocess
  75361. * @param _operator defines the operator to use
  75362. * @param exposureAdjustment defines the required exposure adjustement
  75363. * @param camera defines the camera to use (can be null)
  75364. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75365. * @param engine defines the hosting engine (can be ignore if camera is set)
  75366. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75367. */
  75368. constructor(name: string, _operator: TonemappingOperator,
  75369. /** Defines the required exposure adjustement */
  75370. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75371. }
  75372. }
  75373. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75374. /** @hidden */
  75375. export var volumetricLightScatteringPixelShader: {
  75376. name: string;
  75377. shader: string;
  75378. };
  75379. }
  75380. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75381. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75382. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75383. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75384. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75385. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75386. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75387. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75388. /** @hidden */
  75389. export var volumetricLightScatteringPassVertexShader: {
  75390. name: string;
  75391. shader: string;
  75392. };
  75393. }
  75394. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75395. /** @hidden */
  75396. export var volumetricLightScatteringPassPixelShader: {
  75397. name: string;
  75398. shader: string;
  75399. };
  75400. }
  75401. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75402. import { Vector3 } from "babylonjs/Maths/math.vector";
  75403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75404. import { Mesh } from "babylonjs/Meshes/mesh";
  75405. import { Camera } from "babylonjs/Cameras/camera";
  75406. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75407. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75408. import { Scene } from "babylonjs/scene";
  75409. import "babylonjs/Meshes/Builders/planeBuilder";
  75410. import "babylonjs/Shaders/depth.vertex";
  75411. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75412. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75413. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75414. import { Engine } from "babylonjs/Engines/engine";
  75415. /**
  75416. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75417. */
  75418. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75419. private _volumetricLightScatteringPass;
  75420. private _volumetricLightScatteringRTT;
  75421. private _viewPort;
  75422. private _screenCoordinates;
  75423. private _cachedDefines;
  75424. /**
  75425. * If not undefined, the mesh position is computed from the attached node position
  75426. */
  75427. attachedNode: {
  75428. position: Vector3;
  75429. };
  75430. /**
  75431. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75432. */
  75433. customMeshPosition: Vector3;
  75434. /**
  75435. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75436. */
  75437. useCustomMeshPosition: boolean;
  75438. /**
  75439. * If the post-process should inverse the light scattering direction
  75440. */
  75441. invert: boolean;
  75442. /**
  75443. * The internal mesh used by the post-process
  75444. */
  75445. mesh: Mesh;
  75446. /**
  75447. * @hidden
  75448. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75449. */
  75450. get useDiffuseColor(): boolean;
  75451. set useDiffuseColor(useDiffuseColor: boolean);
  75452. /**
  75453. * Array containing the excluded meshes not rendered in the internal pass
  75454. */
  75455. excludedMeshes: AbstractMesh[];
  75456. /**
  75457. * Controls the overall intensity of the post-process
  75458. */
  75459. exposure: number;
  75460. /**
  75461. * Dissipates each sample's contribution in range [0, 1]
  75462. */
  75463. decay: number;
  75464. /**
  75465. * Controls the overall intensity of each sample
  75466. */
  75467. weight: number;
  75468. /**
  75469. * Controls the density of each sample
  75470. */
  75471. density: number;
  75472. /**
  75473. * @constructor
  75474. * @param name The post-process name
  75475. * @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)
  75476. * @param camera The camera that the post-process will be attached to
  75477. * @param mesh The mesh used to create the light scattering
  75478. * @param samples The post-process quality, default 100
  75479. * @param samplingModeThe post-process filtering mode
  75480. * @param engine The babylon engine
  75481. * @param reusable If the post-process is reusable
  75482. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75483. */
  75484. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75485. /**
  75486. * Returns the string "VolumetricLightScatteringPostProcess"
  75487. * @returns "VolumetricLightScatteringPostProcess"
  75488. */
  75489. getClassName(): string;
  75490. private _isReady;
  75491. /**
  75492. * Sets the new light position for light scattering effect
  75493. * @param position The new custom light position
  75494. */
  75495. setCustomMeshPosition(position: Vector3): void;
  75496. /**
  75497. * Returns the light position for light scattering effect
  75498. * @return Vector3 The custom light position
  75499. */
  75500. getCustomMeshPosition(): Vector3;
  75501. /**
  75502. * Disposes the internal assets and detaches the post-process from the camera
  75503. */
  75504. dispose(camera: Camera): void;
  75505. /**
  75506. * Returns the render target texture used by the post-process
  75507. * @return the render target texture used by the post-process
  75508. */
  75509. getPass(): RenderTargetTexture;
  75510. private _meshExcluded;
  75511. private _createPass;
  75512. private _updateMeshScreenCoordinates;
  75513. /**
  75514. * Creates a default mesh for the Volumeric Light Scattering post-process
  75515. * @param name The mesh name
  75516. * @param scene The scene where to create the mesh
  75517. * @return the default mesh
  75518. */
  75519. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75520. }
  75521. }
  75522. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75523. /** @hidden */
  75524. export var screenSpaceCurvaturePixelShader: {
  75525. name: string;
  75526. shader: string;
  75527. };
  75528. }
  75529. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75530. import { Nullable } from "babylonjs/types";
  75531. import { Camera } from "babylonjs/Cameras/camera";
  75532. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75533. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75534. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75535. import { Engine } from "babylonjs/Engines/engine";
  75536. import { Scene } from "babylonjs/scene";
  75537. /**
  75538. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75539. */
  75540. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75541. /**
  75542. * Defines how much ridge the curvature effect displays.
  75543. */
  75544. ridge: number;
  75545. /**
  75546. * Defines how much valley the curvature effect displays.
  75547. */
  75548. valley: number;
  75549. private _geometryBufferRenderer;
  75550. /**
  75551. * Gets a string identifying the name of the class
  75552. * @returns "ScreenSpaceCurvaturePostProcess" string
  75553. */
  75554. getClassName(): string;
  75555. /**
  75556. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75557. * @param name The name of the effect.
  75558. * @param scene The scene containing the objects to blur according to their velocity.
  75559. * @param options The required width/height ratio to downsize to before computing the render pass.
  75560. * @param camera The camera to apply the render pass to.
  75561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75562. * @param engine The engine which the post process will be applied. (default: current engine)
  75563. * @param reusable If the post process can be reused on the same frame. (default: false)
  75564. * @param textureType Type of textures used when performing the post process. (default: 0)
  75565. * @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)
  75566. */
  75567. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75568. /**
  75569. * Support test.
  75570. */
  75571. static get IsSupported(): boolean;
  75572. /** @hidden */
  75573. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75574. }
  75575. }
  75576. declare module "babylonjs/PostProcesses/index" {
  75577. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75578. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75579. export * from "babylonjs/PostProcesses/bloomEffect";
  75580. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75581. export * from "babylonjs/PostProcesses/blurPostProcess";
  75582. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75583. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75584. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75585. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75586. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75587. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75588. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75589. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75590. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75591. export * from "babylonjs/PostProcesses/filterPostProcess";
  75592. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75593. export * from "babylonjs/PostProcesses/grainPostProcess";
  75594. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75595. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75596. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75597. export * from "babylonjs/PostProcesses/passPostProcess";
  75598. export * from "babylonjs/PostProcesses/postProcess";
  75599. export * from "babylonjs/PostProcesses/postProcessManager";
  75600. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75601. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75602. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75603. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75604. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75605. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75606. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75607. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75608. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75609. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75610. }
  75611. declare module "babylonjs/Probes/index" {
  75612. export * from "babylonjs/Probes/reflectionProbe";
  75613. }
  75614. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75615. import { Scene } from "babylonjs/scene";
  75616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75617. import { SmartArray } from "babylonjs/Misc/smartArray";
  75618. import { ISceneComponent } from "babylonjs/sceneComponent";
  75619. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75620. import "babylonjs/Meshes/Builders/boxBuilder";
  75621. import "babylonjs/Shaders/color.fragment";
  75622. import "babylonjs/Shaders/color.vertex";
  75623. import { Color3 } from "babylonjs/Maths/math.color";
  75624. import { Observable } from "babylonjs/Misc/observable";
  75625. module "babylonjs/scene" {
  75626. interface Scene {
  75627. /** @hidden (Backing field) */
  75628. _boundingBoxRenderer: BoundingBoxRenderer;
  75629. /** @hidden (Backing field) */
  75630. _forceShowBoundingBoxes: boolean;
  75631. /**
  75632. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75633. */
  75634. forceShowBoundingBoxes: boolean;
  75635. /**
  75636. * Gets the bounding box renderer associated with the scene
  75637. * @returns a BoundingBoxRenderer
  75638. */
  75639. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75640. }
  75641. }
  75642. module "babylonjs/Meshes/abstractMesh" {
  75643. interface AbstractMesh {
  75644. /** @hidden (Backing field) */
  75645. _showBoundingBox: boolean;
  75646. /**
  75647. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75648. */
  75649. showBoundingBox: boolean;
  75650. }
  75651. }
  75652. /**
  75653. * Component responsible of rendering the bounding box of the meshes in a scene.
  75654. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75655. */
  75656. export class BoundingBoxRenderer implements ISceneComponent {
  75657. /**
  75658. * The component name helpfull to identify the component in the list of scene components.
  75659. */
  75660. readonly name: string;
  75661. /**
  75662. * The scene the component belongs to.
  75663. */
  75664. scene: Scene;
  75665. /**
  75666. * Color of the bounding box lines placed in front of an object
  75667. */
  75668. frontColor: Color3;
  75669. /**
  75670. * Color of the bounding box lines placed behind an object
  75671. */
  75672. backColor: Color3;
  75673. /**
  75674. * Defines if the renderer should show the back lines or not
  75675. */
  75676. showBackLines: boolean;
  75677. /**
  75678. * Observable raised before rendering a bounding box
  75679. */
  75680. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75681. /**
  75682. * Observable raised after rendering a bounding box
  75683. */
  75684. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75685. /**
  75686. * @hidden
  75687. */
  75688. renderList: SmartArray<BoundingBox>;
  75689. private _colorShader;
  75690. private _vertexBuffers;
  75691. private _indexBuffer;
  75692. private _fillIndexBuffer;
  75693. private _fillIndexData;
  75694. /**
  75695. * Instantiates a new bounding box renderer in a scene.
  75696. * @param scene the scene the renderer renders in
  75697. */
  75698. constructor(scene: Scene);
  75699. /**
  75700. * Registers the component in a given scene
  75701. */
  75702. register(): void;
  75703. private _evaluateSubMesh;
  75704. private _activeMesh;
  75705. private _prepareRessources;
  75706. private _createIndexBuffer;
  75707. /**
  75708. * Rebuilds the elements related to this component in case of
  75709. * context lost for instance.
  75710. */
  75711. rebuild(): void;
  75712. /**
  75713. * @hidden
  75714. */
  75715. reset(): void;
  75716. /**
  75717. * Render the bounding boxes of a specific rendering group
  75718. * @param renderingGroupId defines the rendering group to render
  75719. */
  75720. render(renderingGroupId: number): void;
  75721. /**
  75722. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75723. * @param mesh Define the mesh to render the occlusion bounding box for
  75724. */
  75725. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  75726. /**
  75727. * Dispose and release the resources attached to this renderer.
  75728. */
  75729. dispose(): void;
  75730. }
  75731. }
  75732. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  75733. import { Nullable } from "babylonjs/types";
  75734. import { Scene } from "babylonjs/scene";
  75735. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  75736. import { Camera } from "babylonjs/Cameras/camera";
  75737. import { ISceneComponent } from "babylonjs/sceneComponent";
  75738. module "babylonjs/scene" {
  75739. interface Scene {
  75740. /** @hidden (Backing field) */
  75741. _depthRenderer: {
  75742. [id: string]: DepthRenderer;
  75743. };
  75744. /**
  75745. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  75746. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  75747. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  75748. * @returns the created depth renderer
  75749. */
  75750. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  75751. /**
  75752. * Disables a depth renderer for a given camera
  75753. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  75754. */
  75755. disableDepthRenderer(camera?: Nullable<Camera>): void;
  75756. }
  75757. }
  75758. /**
  75759. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  75760. * in several rendering techniques.
  75761. */
  75762. export class DepthRendererSceneComponent implements ISceneComponent {
  75763. /**
  75764. * The component name helpfull to identify the component in the list of scene components.
  75765. */
  75766. readonly name: string;
  75767. /**
  75768. * The scene the component belongs to.
  75769. */
  75770. scene: Scene;
  75771. /**
  75772. * Creates a new instance of the component for the given scene
  75773. * @param scene Defines the scene to register the component in
  75774. */
  75775. constructor(scene: Scene);
  75776. /**
  75777. * Registers the component in a given scene
  75778. */
  75779. register(): void;
  75780. /**
  75781. * Rebuilds the elements related to this component in case of
  75782. * context lost for instance.
  75783. */
  75784. rebuild(): void;
  75785. /**
  75786. * Disposes the component and the associated ressources
  75787. */
  75788. dispose(): void;
  75789. private _gatherRenderTargets;
  75790. private _gatherActiveCameraRenderTargets;
  75791. }
  75792. }
  75793. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  75794. import { Nullable } from "babylonjs/types";
  75795. import { Scene } from "babylonjs/scene";
  75796. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  75797. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75798. import { AbstractScene } from "babylonjs/abstractScene";
  75799. module "babylonjs/abstractScene" {
  75800. interface AbstractScene {
  75801. /** @hidden (Backing field) */
  75802. _prePassRenderer: Nullable<PrePassRenderer>;
  75803. /**
  75804. * Gets or Sets the current prepass renderer associated to the scene.
  75805. */
  75806. prePassRenderer: Nullable<PrePassRenderer>;
  75807. /**
  75808. * Enables the prepass and associates it with the scene
  75809. * @returns the PrePassRenderer
  75810. */
  75811. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  75812. /**
  75813. * Disables the prepass associated with the scene
  75814. */
  75815. disablePrePassRenderer(): void;
  75816. }
  75817. }
  75818. /**
  75819. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75820. * in several rendering techniques.
  75821. */
  75822. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  75823. /**
  75824. * The component name helpful to identify the component in the list of scene components.
  75825. */
  75826. readonly name: string;
  75827. /**
  75828. * The scene the component belongs to.
  75829. */
  75830. scene: Scene;
  75831. /**
  75832. * Creates a new instance of the component for the given scene
  75833. * @param scene Defines the scene to register the component in
  75834. */
  75835. constructor(scene: Scene);
  75836. /**
  75837. * Registers the component in a given scene
  75838. */
  75839. register(): void;
  75840. private _beforeCameraDraw;
  75841. private _afterCameraDraw;
  75842. private _beforeClearStage;
  75843. /**
  75844. * Serializes the component data to the specified json object
  75845. * @param serializationObject The object to serialize to
  75846. */
  75847. serialize(serializationObject: any): void;
  75848. /**
  75849. * Adds all the elements from the container to the scene
  75850. * @param container the container holding the elements
  75851. */
  75852. addFromContainer(container: AbstractScene): void;
  75853. /**
  75854. * Removes all the elements in the container from the scene
  75855. * @param container contains the elements to remove
  75856. * @param dispose if the removed element should be disposed (default: false)
  75857. */
  75858. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75859. /**
  75860. * Rebuilds the elements related to this component in case of
  75861. * context lost for instance.
  75862. */
  75863. rebuild(): void;
  75864. /**
  75865. * Disposes the component and the associated ressources
  75866. */
  75867. dispose(): void;
  75868. }
  75869. }
  75870. declare module "babylonjs/Shaders/outline.fragment" {
  75871. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75872. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  75873. /** @hidden */
  75874. export var outlinePixelShader: {
  75875. name: string;
  75876. shader: string;
  75877. };
  75878. }
  75879. declare module "babylonjs/Shaders/outline.vertex" {
  75880. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75881. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75882. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75883. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75884. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75885. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75886. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75887. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75888. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  75889. /** @hidden */
  75890. export var outlineVertexShader: {
  75891. name: string;
  75892. shader: string;
  75893. };
  75894. }
  75895. declare module "babylonjs/Rendering/outlineRenderer" {
  75896. import { SubMesh } from "babylonjs/Meshes/subMesh";
  75897. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  75898. import { Scene } from "babylonjs/scene";
  75899. import { ISceneComponent } from "babylonjs/sceneComponent";
  75900. import "babylonjs/Shaders/outline.fragment";
  75901. import "babylonjs/Shaders/outline.vertex";
  75902. module "babylonjs/scene" {
  75903. interface Scene {
  75904. /** @hidden */
  75905. _outlineRenderer: OutlineRenderer;
  75906. /**
  75907. * Gets the outline renderer associated with the scene
  75908. * @returns a OutlineRenderer
  75909. */
  75910. getOutlineRenderer(): OutlineRenderer;
  75911. }
  75912. }
  75913. module "babylonjs/Meshes/abstractMesh" {
  75914. interface AbstractMesh {
  75915. /** @hidden (Backing field) */
  75916. _renderOutline: boolean;
  75917. /**
  75918. * Gets or sets a boolean indicating if the outline must be rendered as well
  75919. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  75920. */
  75921. renderOutline: boolean;
  75922. /** @hidden (Backing field) */
  75923. _renderOverlay: boolean;
  75924. /**
  75925. * Gets or sets a boolean indicating if the overlay must be rendered as well
  75926. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  75927. */
  75928. renderOverlay: boolean;
  75929. }
  75930. }
  75931. /**
  75932. * This class is responsible to draw bothe outline/overlay of meshes.
  75933. * It should not be used directly but through the available method on mesh.
  75934. */
  75935. export class OutlineRenderer implements ISceneComponent {
  75936. /**
  75937. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  75938. */
  75939. private static _StencilReference;
  75940. /**
  75941. * The name of the component. Each component must have a unique name.
  75942. */
  75943. name: string;
  75944. /**
  75945. * The scene the component belongs to.
  75946. */
  75947. scene: Scene;
  75948. /**
  75949. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  75950. */
  75951. zOffset: number;
  75952. private _engine;
  75953. private _effect;
  75954. private _cachedDefines;
  75955. private _savedDepthWrite;
  75956. /**
  75957. * Instantiates a new outline renderer. (There could be only one per scene).
  75958. * @param scene Defines the scene it belongs to
  75959. */
  75960. constructor(scene: Scene);
  75961. /**
  75962. * Register the component to one instance of a scene.
  75963. */
  75964. register(): void;
  75965. /**
  75966. * Rebuilds the elements related to this component in case of
  75967. * context lost for instance.
  75968. */
  75969. rebuild(): void;
  75970. /**
  75971. * Disposes the component and the associated ressources.
  75972. */
  75973. dispose(): void;
  75974. /**
  75975. * Renders the outline in the canvas.
  75976. * @param subMesh Defines the sumesh to render
  75977. * @param batch Defines the batch of meshes in case of instances
  75978. * @param useOverlay Defines if the rendering is for the overlay or the outline
  75979. */
  75980. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  75981. /**
  75982. * Returns whether or not the outline renderer is ready for a given submesh.
  75983. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  75984. * @param subMesh Defines the submesh to check readyness for
  75985. * @param useInstances Defines wheter wee are trying to render instances or not
  75986. * @returns true if ready otherwise false
  75987. */
  75988. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75989. private _beforeRenderingMesh;
  75990. private _afterRenderingMesh;
  75991. }
  75992. }
  75993. declare module "babylonjs/Rendering/index" {
  75994. export * from "babylonjs/Rendering/boundingBoxRenderer";
  75995. export * from "babylonjs/Rendering/depthRenderer";
  75996. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  75997. export * from "babylonjs/Rendering/edgesRenderer";
  75998. export * from "babylonjs/Rendering/geometryBufferRenderer";
  75999. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76000. export * from "babylonjs/Rendering/prePassRenderer";
  76001. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76002. export * from "babylonjs/Rendering/outlineRenderer";
  76003. export * from "babylonjs/Rendering/renderingGroup";
  76004. export * from "babylonjs/Rendering/renderingManager";
  76005. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76006. }
  76007. declare module "babylonjs/Sprites/ISprites" {
  76008. /**
  76009. * Defines the basic options interface of a Sprite Frame Source Size.
  76010. */
  76011. export interface ISpriteJSONSpriteSourceSize {
  76012. /**
  76013. * number of the original width of the Frame
  76014. */
  76015. w: number;
  76016. /**
  76017. * number of the original height of the Frame
  76018. */
  76019. h: number;
  76020. }
  76021. /**
  76022. * Defines the basic options interface of a Sprite Frame Data.
  76023. */
  76024. export interface ISpriteJSONSpriteFrameData {
  76025. /**
  76026. * number of the x offset of the Frame
  76027. */
  76028. x: number;
  76029. /**
  76030. * number of the y offset of the Frame
  76031. */
  76032. y: number;
  76033. /**
  76034. * number of the width of the Frame
  76035. */
  76036. w: number;
  76037. /**
  76038. * number of the height of the Frame
  76039. */
  76040. h: number;
  76041. }
  76042. /**
  76043. * Defines the basic options interface of a JSON Sprite.
  76044. */
  76045. export interface ISpriteJSONSprite {
  76046. /**
  76047. * string name of the Frame
  76048. */
  76049. filename: string;
  76050. /**
  76051. * ISpriteJSONSpriteFrame basic object of the frame data
  76052. */
  76053. frame: ISpriteJSONSpriteFrameData;
  76054. /**
  76055. * boolean to flag is the frame was rotated.
  76056. */
  76057. rotated: boolean;
  76058. /**
  76059. * boolean to flag is the frame was trimmed.
  76060. */
  76061. trimmed: boolean;
  76062. /**
  76063. * ISpriteJSONSpriteFrame basic object of the source data
  76064. */
  76065. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76066. /**
  76067. * ISpriteJSONSpriteFrame basic object of the source data
  76068. */
  76069. sourceSize: ISpriteJSONSpriteSourceSize;
  76070. }
  76071. /**
  76072. * Defines the basic options interface of a JSON atlas.
  76073. */
  76074. export interface ISpriteJSONAtlas {
  76075. /**
  76076. * Array of objects that contain the frame data.
  76077. */
  76078. frames: Array<ISpriteJSONSprite>;
  76079. /**
  76080. * object basic object containing the sprite meta data.
  76081. */
  76082. meta?: object;
  76083. }
  76084. }
  76085. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76086. /** @hidden */
  76087. export var spriteMapPixelShader: {
  76088. name: string;
  76089. shader: string;
  76090. };
  76091. }
  76092. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76093. /** @hidden */
  76094. export var spriteMapVertexShader: {
  76095. name: string;
  76096. shader: string;
  76097. };
  76098. }
  76099. declare module "babylonjs/Sprites/spriteMap" {
  76100. import { IDisposable, Scene } from "babylonjs/scene";
  76101. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76102. import { Texture } from "babylonjs/Materials/Textures/texture";
  76103. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76104. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76105. import "babylonjs/Meshes/Builders/planeBuilder";
  76106. import "babylonjs/Shaders/spriteMap.fragment";
  76107. import "babylonjs/Shaders/spriteMap.vertex";
  76108. /**
  76109. * Defines the basic options interface of a SpriteMap
  76110. */
  76111. export interface ISpriteMapOptions {
  76112. /**
  76113. * Vector2 of the number of cells in the grid.
  76114. */
  76115. stageSize?: Vector2;
  76116. /**
  76117. * Vector2 of the size of the output plane in World Units.
  76118. */
  76119. outputSize?: Vector2;
  76120. /**
  76121. * Vector3 of the position of the output plane in World Units.
  76122. */
  76123. outputPosition?: Vector3;
  76124. /**
  76125. * Vector3 of the rotation of the output plane.
  76126. */
  76127. outputRotation?: Vector3;
  76128. /**
  76129. * number of layers that the system will reserve in resources.
  76130. */
  76131. layerCount?: number;
  76132. /**
  76133. * number of max animation frames a single cell will reserve in resources.
  76134. */
  76135. maxAnimationFrames?: number;
  76136. /**
  76137. * number cell index of the base tile when the system compiles.
  76138. */
  76139. baseTile?: number;
  76140. /**
  76141. * boolean flip the sprite after its been repositioned by the framing data.
  76142. */
  76143. flipU?: boolean;
  76144. /**
  76145. * Vector3 scalar of the global RGB values of the SpriteMap.
  76146. */
  76147. colorMultiply?: Vector3;
  76148. }
  76149. /**
  76150. * Defines the IDisposable interface in order to be cleanable from resources.
  76151. */
  76152. export interface ISpriteMap extends IDisposable {
  76153. /**
  76154. * String name of the SpriteMap.
  76155. */
  76156. name: string;
  76157. /**
  76158. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76159. */
  76160. atlasJSON: ISpriteJSONAtlas;
  76161. /**
  76162. * Texture of the SpriteMap.
  76163. */
  76164. spriteSheet: Texture;
  76165. /**
  76166. * The parameters to initialize the SpriteMap with.
  76167. */
  76168. options: ISpriteMapOptions;
  76169. }
  76170. /**
  76171. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76172. */
  76173. export class SpriteMap implements ISpriteMap {
  76174. /** The Name of the spriteMap */
  76175. name: string;
  76176. /** The JSON file with the frame and meta data */
  76177. atlasJSON: ISpriteJSONAtlas;
  76178. /** The systems Sprite Sheet Texture */
  76179. spriteSheet: Texture;
  76180. /** Arguments passed with the Constructor */
  76181. options: ISpriteMapOptions;
  76182. /** Public Sprite Storage array, parsed from atlasJSON */
  76183. sprites: Array<ISpriteJSONSprite>;
  76184. /** Returns the Number of Sprites in the System */
  76185. get spriteCount(): number;
  76186. /** Returns the Position of Output Plane*/
  76187. get position(): Vector3;
  76188. /** Returns the Position of Output Plane*/
  76189. set position(v: Vector3);
  76190. /** Returns the Rotation of Output Plane*/
  76191. get rotation(): Vector3;
  76192. /** Returns the Rotation of Output Plane*/
  76193. set rotation(v: Vector3);
  76194. /** Sets the AnimationMap*/
  76195. get animationMap(): RawTexture;
  76196. /** Sets the AnimationMap*/
  76197. set animationMap(v: RawTexture);
  76198. /** Scene that the SpriteMap was created in */
  76199. private _scene;
  76200. /** Texture Buffer of Float32 that holds tile frame data*/
  76201. private _frameMap;
  76202. /** Texture Buffers of Float32 that holds tileMap data*/
  76203. private _tileMaps;
  76204. /** Texture Buffer of Float32 that holds Animation Data*/
  76205. private _animationMap;
  76206. /** Custom ShaderMaterial Central to the System*/
  76207. private _material;
  76208. /** Custom ShaderMaterial Central to the System*/
  76209. private _output;
  76210. /** Systems Time Ticker*/
  76211. private _time;
  76212. /**
  76213. * Creates a new SpriteMap
  76214. * @param name defines the SpriteMaps Name
  76215. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76216. * @param spriteSheet is the Texture that the Sprites are on.
  76217. * @param options a basic deployment configuration
  76218. * @param scene The Scene that the map is deployed on
  76219. */
  76220. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76221. /**
  76222. * Returns tileID location
  76223. * @returns Vector2 the cell position ID
  76224. */
  76225. getTileID(): Vector2;
  76226. /**
  76227. * Gets the UV location of the mouse over the SpriteMap.
  76228. * @returns Vector2 the UV position of the mouse interaction
  76229. */
  76230. getMousePosition(): Vector2;
  76231. /**
  76232. * Creates the "frame" texture Buffer
  76233. * -------------------------------------
  76234. * Structure of frames
  76235. * "filename": "Falling-Water-2.png",
  76236. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76237. * "rotated": true,
  76238. * "trimmed": true,
  76239. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76240. * "sourceSize": {"w":32,"h":32}
  76241. * @returns RawTexture of the frameMap
  76242. */
  76243. private _createFrameBuffer;
  76244. /**
  76245. * Creates the tileMap texture Buffer
  76246. * @param buffer normally and array of numbers, or a false to generate from scratch
  76247. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76248. * @returns RawTexture of the tileMap
  76249. */
  76250. private _createTileBuffer;
  76251. /**
  76252. * Modifies the data of the tileMaps
  76253. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76254. * @param pos is the iVector2 Coordinates of the Tile
  76255. * @param tile The SpriteIndex of the new Tile
  76256. */
  76257. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76258. /**
  76259. * Creates the animationMap texture Buffer
  76260. * @param buffer normally and array of numbers, or a false to generate from scratch
  76261. * @returns RawTexture of the animationMap
  76262. */
  76263. private _createTileAnimationBuffer;
  76264. /**
  76265. * Modifies the data of the animationMap
  76266. * @param cellID is the Index of the Sprite
  76267. * @param _frame is the target Animation frame
  76268. * @param toCell is the Target Index of the next frame of the animation
  76269. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76270. * @param speed is a global scalar of the time variable on the map.
  76271. */
  76272. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76273. /**
  76274. * Exports the .tilemaps file
  76275. */
  76276. saveTileMaps(): void;
  76277. /**
  76278. * Imports the .tilemaps file
  76279. * @param url of the .tilemaps file
  76280. */
  76281. loadTileMaps(url: string): void;
  76282. /**
  76283. * Release associated resources
  76284. */
  76285. dispose(): void;
  76286. }
  76287. }
  76288. declare module "babylonjs/Sprites/spritePackedManager" {
  76289. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  76290. import { Scene } from "babylonjs/scene";
  76291. /**
  76292. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76293. * @see https://doc.babylonjs.com/babylon101/sprites
  76294. */
  76295. export class SpritePackedManager extends SpriteManager {
  76296. /** defines the packed manager's name */
  76297. name: string;
  76298. /**
  76299. * Creates a new sprite manager from a packed sprite sheet
  76300. * @param name defines the manager's name
  76301. * @param imgUrl defines the sprite sheet url
  76302. * @param capacity defines the maximum allowed number of sprites
  76303. * @param scene defines the hosting scene
  76304. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76305. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76306. * @param samplingMode defines the smapling mode to use with spritesheet
  76307. * @param fromPacked set to true; do not alter
  76308. */
  76309. constructor(
  76310. /** defines the packed manager's name */
  76311. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76312. }
  76313. }
  76314. declare module "babylonjs/Sprites/index" {
  76315. export * from "babylonjs/Sprites/sprite";
  76316. export * from "babylonjs/Sprites/ISprites";
  76317. export * from "babylonjs/Sprites/spriteManager";
  76318. export * from "babylonjs/Sprites/spriteMap";
  76319. export * from "babylonjs/Sprites/spritePackedManager";
  76320. export * from "babylonjs/Sprites/spriteSceneComponent";
  76321. }
  76322. declare module "babylonjs/States/index" {
  76323. export * from "babylonjs/States/alphaCullingState";
  76324. export * from "babylonjs/States/depthCullingState";
  76325. export * from "babylonjs/States/stencilState";
  76326. }
  76327. declare module "babylonjs/Misc/assetsManager" {
  76328. import { Scene } from "babylonjs/scene";
  76329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76330. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76331. import { Skeleton } from "babylonjs/Bones/skeleton";
  76332. import { Observable } from "babylonjs/Misc/observable";
  76333. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  76334. import { Texture } from "babylonjs/Materials/Textures/texture";
  76335. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  76336. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  76337. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  76338. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  76339. import { AssetContainer } from "babylonjs/assetContainer";
  76340. /**
  76341. * Defines the list of states available for a task inside a AssetsManager
  76342. */
  76343. export enum AssetTaskState {
  76344. /**
  76345. * Initialization
  76346. */
  76347. INIT = 0,
  76348. /**
  76349. * Running
  76350. */
  76351. RUNNING = 1,
  76352. /**
  76353. * Done
  76354. */
  76355. DONE = 2,
  76356. /**
  76357. * Error
  76358. */
  76359. ERROR = 3
  76360. }
  76361. /**
  76362. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76363. */
  76364. export abstract class AbstractAssetTask {
  76365. /**
  76366. * Task name
  76367. */ name: string;
  76368. /**
  76369. * Callback called when the task is successful
  76370. */
  76371. onSuccess: (task: any) => void;
  76372. /**
  76373. * Callback called when the task is not successful
  76374. */
  76375. onError: (task: any, message?: string, exception?: any) => void;
  76376. /**
  76377. * Creates a new AssetsManager
  76378. * @param name defines the name of the task
  76379. */
  76380. constructor(
  76381. /**
  76382. * Task name
  76383. */ name: string);
  76384. private _isCompleted;
  76385. private _taskState;
  76386. private _errorObject;
  76387. /**
  76388. * Get if the task is completed
  76389. */
  76390. get isCompleted(): boolean;
  76391. /**
  76392. * Gets the current state of the task
  76393. */
  76394. get taskState(): AssetTaskState;
  76395. /**
  76396. * Gets the current error object (if task is in error)
  76397. */
  76398. get errorObject(): {
  76399. message?: string;
  76400. exception?: any;
  76401. };
  76402. /**
  76403. * Internal only
  76404. * @hidden
  76405. */
  76406. _setErrorObject(message?: string, exception?: any): void;
  76407. /**
  76408. * Execute the current task
  76409. * @param scene defines the scene where you want your assets to be loaded
  76410. * @param onSuccess is a callback called when the task is successfully executed
  76411. * @param onError is a callback called if an error occurs
  76412. */
  76413. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76414. /**
  76415. * Execute the current task
  76416. * @param scene defines the scene where you want your assets to be loaded
  76417. * @param onSuccess is a callback called when the task is successfully executed
  76418. * @param onError is a callback called if an error occurs
  76419. */
  76420. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76421. /**
  76422. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76423. * This can be used with failed tasks that have the reason for failure fixed.
  76424. */
  76425. reset(): void;
  76426. private onErrorCallback;
  76427. private onDoneCallback;
  76428. }
  76429. /**
  76430. * Define the interface used by progress events raised during assets loading
  76431. */
  76432. export interface IAssetsProgressEvent {
  76433. /**
  76434. * Defines the number of remaining tasks to process
  76435. */
  76436. remainingCount: number;
  76437. /**
  76438. * Defines the total number of tasks
  76439. */
  76440. totalCount: number;
  76441. /**
  76442. * Defines the task that was just processed
  76443. */
  76444. task: AbstractAssetTask;
  76445. }
  76446. /**
  76447. * Class used to share progress information about assets loading
  76448. */
  76449. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76450. /**
  76451. * Defines the number of remaining tasks to process
  76452. */
  76453. remainingCount: number;
  76454. /**
  76455. * Defines the total number of tasks
  76456. */
  76457. totalCount: number;
  76458. /**
  76459. * Defines the task that was just processed
  76460. */
  76461. task: AbstractAssetTask;
  76462. /**
  76463. * Creates a AssetsProgressEvent
  76464. * @param remainingCount defines the number of remaining tasks to process
  76465. * @param totalCount defines the total number of tasks
  76466. * @param task defines the task that was just processed
  76467. */
  76468. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76469. }
  76470. /**
  76471. * Define a task used by AssetsManager to load assets into a container
  76472. */
  76473. export class ContainerAssetTask extends AbstractAssetTask {
  76474. /**
  76475. * Defines the name of the task
  76476. */
  76477. name: string;
  76478. /**
  76479. * Defines the list of mesh's names you want to load
  76480. */
  76481. meshesNames: any;
  76482. /**
  76483. * Defines the root url to use as a base to load your meshes and associated resources
  76484. */
  76485. rootUrl: string;
  76486. /**
  76487. * Defines the filename or File of the scene to load from
  76488. */
  76489. sceneFilename: string | File;
  76490. /**
  76491. * Get the loaded asset container
  76492. */
  76493. loadedContainer: AssetContainer;
  76494. /**
  76495. * Gets the list of loaded meshes
  76496. */
  76497. loadedMeshes: Array<AbstractMesh>;
  76498. /**
  76499. * Gets the list of loaded particle systems
  76500. */
  76501. loadedParticleSystems: Array<IParticleSystem>;
  76502. /**
  76503. * Gets the list of loaded skeletons
  76504. */
  76505. loadedSkeletons: Array<Skeleton>;
  76506. /**
  76507. * Gets the list of loaded animation groups
  76508. */
  76509. loadedAnimationGroups: Array<AnimationGroup>;
  76510. /**
  76511. * Callback called when the task is successful
  76512. */
  76513. onSuccess: (task: ContainerAssetTask) => void;
  76514. /**
  76515. * Callback called when the task is successful
  76516. */
  76517. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76518. /**
  76519. * Creates a new ContainerAssetTask
  76520. * @param name defines the name of the task
  76521. * @param meshesNames defines the list of mesh's names you want to load
  76522. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76523. * @param sceneFilename defines the filename or File of the scene to load from
  76524. */
  76525. constructor(
  76526. /**
  76527. * Defines the name of the task
  76528. */
  76529. name: string,
  76530. /**
  76531. * Defines the list of mesh's names you want to load
  76532. */
  76533. meshesNames: any,
  76534. /**
  76535. * Defines the root url to use as a base to load your meshes and associated resources
  76536. */
  76537. rootUrl: string,
  76538. /**
  76539. * Defines the filename or File of the scene to load from
  76540. */
  76541. sceneFilename: string | File);
  76542. /**
  76543. * Execute the current task
  76544. * @param scene defines the scene where you want your assets to be loaded
  76545. * @param onSuccess is a callback called when the task is successfully executed
  76546. * @param onError is a callback called if an error occurs
  76547. */
  76548. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76549. }
  76550. /**
  76551. * Define a task used by AssetsManager to load meshes
  76552. */
  76553. export class MeshAssetTask extends AbstractAssetTask {
  76554. /**
  76555. * Defines the name of the task
  76556. */
  76557. name: string;
  76558. /**
  76559. * Defines the list of mesh's names you want to load
  76560. */
  76561. meshesNames: any;
  76562. /**
  76563. * Defines the root url to use as a base to load your meshes and associated resources
  76564. */
  76565. rootUrl: string;
  76566. /**
  76567. * Defines the filename or File of the scene to load from
  76568. */
  76569. sceneFilename: string | File;
  76570. /**
  76571. * Gets the list of loaded meshes
  76572. */
  76573. loadedMeshes: Array<AbstractMesh>;
  76574. /**
  76575. * Gets the list of loaded particle systems
  76576. */
  76577. loadedParticleSystems: Array<IParticleSystem>;
  76578. /**
  76579. * Gets the list of loaded skeletons
  76580. */
  76581. loadedSkeletons: Array<Skeleton>;
  76582. /**
  76583. * Gets the list of loaded animation groups
  76584. */
  76585. loadedAnimationGroups: Array<AnimationGroup>;
  76586. /**
  76587. * Callback called when the task is successful
  76588. */
  76589. onSuccess: (task: MeshAssetTask) => void;
  76590. /**
  76591. * Callback called when the task is successful
  76592. */
  76593. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  76594. /**
  76595. * Creates a new MeshAssetTask
  76596. * @param name defines the name of the task
  76597. * @param meshesNames defines the list of mesh's names you want to load
  76598. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76599. * @param sceneFilename defines the filename or File of the scene to load from
  76600. */
  76601. constructor(
  76602. /**
  76603. * Defines the name of the task
  76604. */
  76605. name: string,
  76606. /**
  76607. * Defines the list of mesh's names you want to load
  76608. */
  76609. meshesNames: any,
  76610. /**
  76611. * Defines the root url to use as a base to load your meshes and associated resources
  76612. */
  76613. rootUrl: string,
  76614. /**
  76615. * Defines the filename or File of the scene to load from
  76616. */
  76617. sceneFilename: string | File);
  76618. /**
  76619. * Execute the current task
  76620. * @param scene defines the scene where you want your assets to be loaded
  76621. * @param onSuccess is a callback called when the task is successfully executed
  76622. * @param onError is a callback called if an error occurs
  76623. */
  76624. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76625. }
  76626. /**
  76627. * Define a task used by AssetsManager to load text content
  76628. */
  76629. export class TextFileAssetTask extends AbstractAssetTask {
  76630. /**
  76631. * Defines the name of the task
  76632. */
  76633. name: string;
  76634. /**
  76635. * Defines the location of the file to load
  76636. */
  76637. url: string;
  76638. /**
  76639. * Gets the loaded text string
  76640. */
  76641. text: string;
  76642. /**
  76643. * Callback called when the task is successful
  76644. */
  76645. onSuccess: (task: TextFileAssetTask) => void;
  76646. /**
  76647. * Callback called when the task is successful
  76648. */
  76649. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  76650. /**
  76651. * Creates a new TextFileAssetTask object
  76652. * @param name defines the name of the task
  76653. * @param url defines the location of the file to load
  76654. */
  76655. constructor(
  76656. /**
  76657. * Defines the name of the task
  76658. */
  76659. name: string,
  76660. /**
  76661. * Defines the location of the file to load
  76662. */
  76663. url: string);
  76664. /**
  76665. * Execute the current task
  76666. * @param scene defines the scene where you want your assets to be loaded
  76667. * @param onSuccess is a callback called when the task is successfully executed
  76668. * @param onError is a callback called if an error occurs
  76669. */
  76670. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76671. }
  76672. /**
  76673. * Define a task used by AssetsManager to load binary data
  76674. */
  76675. export class BinaryFileAssetTask extends AbstractAssetTask {
  76676. /**
  76677. * Defines the name of the task
  76678. */
  76679. name: string;
  76680. /**
  76681. * Defines the location of the file to load
  76682. */
  76683. url: string;
  76684. /**
  76685. * Gets the lodaded data (as an array buffer)
  76686. */
  76687. data: ArrayBuffer;
  76688. /**
  76689. * Callback called when the task is successful
  76690. */
  76691. onSuccess: (task: BinaryFileAssetTask) => void;
  76692. /**
  76693. * Callback called when the task is successful
  76694. */
  76695. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  76696. /**
  76697. * Creates a new BinaryFileAssetTask object
  76698. * @param name defines the name of the new task
  76699. * @param url defines the location of the file to load
  76700. */
  76701. constructor(
  76702. /**
  76703. * Defines the name of the task
  76704. */
  76705. name: string,
  76706. /**
  76707. * Defines the location of the file to load
  76708. */
  76709. url: string);
  76710. /**
  76711. * Execute the current task
  76712. * @param scene defines the scene where you want your assets to be loaded
  76713. * @param onSuccess is a callback called when the task is successfully executed
  76714. * @param onError is a callback called if an error occurs
  76715. */
  76716. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76717. }
  76718. /**
  76719. * Define a task used by AssetsManager to load images
  76720. */
  76721. export class ImageAssetTask extends AbstractAssetTask {
  76722. /**
  76723. * Defines the name of the task
  76724. */
  76725. name: string;
  76726. /**
  76727. * Defines the location of the image to load
  76728. */
  76729. url: string;
  76730. /**
  76731. * Gets the loaded images
  76732. */
  76733. image: HTMLImageElement;
  76734. /**
  76735. * Callback called when the task is successful
  76736. */
  76737. onSuccess: (task: ImageAssetTask) => void;
  76738. /**
  76739. * Callback called when the task is successful
  76740. */
  76741. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  76742. /**
  76743. * Creates a new ImageAssetTask
  76744. * @param name defines the name of the task
  76745. * @param url defines the location of the image to load
  76746. */
  76747. constructor(
  76748. /**
  76749. * Defines the name of the task
  76750. */
  76751. name: string,
  76752. /**
  76753. * Defines the location of the image to load
  76754. */
  76755. url: string);
  76756. /**
  76757. * Execute the current task
  76758. * @param scene defines the scene where you want your assets to be loaded
  76759. * @param onSuccess is a callback called when the task is successfully executed
  76760. * @param onError is a callback called if an error occurs
  76761. */
  76762. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76763. }
  76764. /**
  76765. * Defines the interface used by texture loading tasks
  76766. */
  76767. export interface ITextureAssetTask<TEX extends BaseTexture> {
  76768. /**
  76769. * Gets the loaded texture
  76770. */
  76771. texture: TEX;
  76772. }
  76773. /**
  76774. * Define a task used by AssetsManager to load 2D textures
  76775. */
  76776. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  76777. /**
  76778. * Defines the name of the task
  76779. */
  76780. name: string;
  76781. /**
  76782. * Defines the location of the file to load
  76783. */
  76784. url: string;
  76785. /**
  76786. * Defines if mipmap should not be generated (default is false)
  76787. */
  76788. noMipmap?: boolean | undefined;
  76789. /**
  76790. * Defines if texture must be inverted on Y axis (default is true)
  76791. */
  76792. invertY: boolean;
  76793. /**
  76794. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76795. */
  76796. samplingMode: number;
  76797. /**
  76798. * Gets the loaded texture
  76799. */
  76800. texture: Texture;
  76801. /**
  76802. * Callback called when the task is successful
  76803. */
  76804. onSuccess: (task: TextureAssetTask) => void;
  76805. /**
  76806. * Callback called when the task is successful
  76807. */
  76808. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  76809. /**
  76810. * Creates a new TextureAssetTask object
  76811. * @param name defines the name of the task
  76812. * @param url defines the location of the file to load
  76813. * @param noMipmap defines if mipmap should not be generated (default is false)
  76814. * @param invertY defines if texture must be inverted on Y axis (default is true)
  76815. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76816. */
  76817. constructor(
  76818. /**
  76819. * Defines the name of the task
  76820. */
  76821. name: string,
  76822. /**
  76823. * Defines the location of the file to load
  76824. */
  76825. url: string,
  76826. /**
  76827. * Defines if mipmap should not be generated (default is false)
  76828. */
  76829. noMipmap?: boolean | undefined,
  76830. /**
  76831. * Defines if texture must be inverted on Y axis (default is true)
  76832. */
  76833. invertY?: boolean,
  76834. /**
  76835. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76836. */
  76837. samplingMode?: number);
  76838. /**
  76839. * Execute the current task
  76840. * @param scene defines the scene where you want your assets to be loaded
  76841. * @param onSuccess is a callback called when the task is successfully executed
  76842. * @param onError is a callback called if an error occurs
  76843. */
  76844. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76845. }
  76846. /**
  76847. * Define a task used by AssetsManager to load cube textures
  76848. */
  76849. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  76850. /**
  76851. * Defines the name of the task
  76852. */
  76853. name: string;
  76854. /**
  76855. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76856. */
  76857. url: string;
  76858. /**
  76859. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76860. */
  76861. extensions?: string[] | undefined;
  76862. /**
  76863. * Defines if mipmaps should not be generated (default is false)
  76864. */
  76865. noMipmap?: boolean | undefined;
  76866. /**
  76867. * Defines the explicit list of files (undefined by default)
  76868. */
  76869. files?: string[] | undefined;
  76870. /**
  76871. * Gets the loaded texture
  76872. */
  76873. texture: CubeTexture;
  76874. /**
  76875. * Callback called when the task is successful
  76876. */
  76877. onSuccess: (task: CubeTextureAssetTask) => void;
  76878. /**
  76879. * Callback called when the task is successful
  76880. */
  76881. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  76882. /**
  76883. * Creates a new CubeTextureAssetTask
  76884. * @param name defines the name of the task
  76885. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76886. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76887. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76888. * @param files defines the explicit list of files (undefined by default)
  76889. */
  76890. constructor(
  76891. /**
  76892. * Defines the name of the task
  76893. */
  76894. name: string,
  76895. /**
  76896. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76897. */
  76898. url: string,
  76899. /**
  76900. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76901. */
  76902. extensions?: string[] | undefined,
  76903. /**
  76904. * Defines if mipmaps should not be generated (default is false)
  76905. */
  76906. noMipmap?: boolean | undefined,
  76907. /**
  76908. * Defines the explicit list of files (undefined by default)
  76909. */
  76910. files?: string[] | undefined);
  76911. /**
  76912. * Execute the current task
  76913. * @param scene defines the scene where you want your assets to be loaded
  76914. * @param onSuccess is a callback called when the task is successfully executed
  76915. * @param onError is a callback called if an error occurs
  76916. */
  76917. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76918. }
  76919. /**
  76920. * Define a task used by AssetsManager to load HDR cube textures
  76921. */
  76922. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  76923. /**
  76924. * Defines the name of the task
  76925. */
  76926. name: string;
  76927. /**
  76928. * Defines the location of the file to load
  76929. */
  76930. url: string;
  76931. /**
  76932. * Defines the desired size (the more it increases the longer the generation will be)
  76933. */
  76934. size: number;
  76935. /**
  76936. * Defines if mipmaps should not be generated (default is false)
  76937. */
  76938. noMipmap: boolean;
  76939. /**
  76940. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76941. */
  76942. generateHarmonics: boolean;
  76943. /**
  76944. * 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)
  76945. */
  76946. gammaSpace: boolean;
  76947. /**
  76948. * Internal Use Only
  76949. */
  76950. reserved: boolean;
  76951. /**
  76952. * Gets the loaded texture
  76953. */
  76954. texture: HDRCubeTexture;
  76955. /**
  76956. * Callback called when the task is successful
  76957. */
  76958. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  76959. /**
  76960. * Callback called when the task is successful
  76961. */
  76962. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  76963. /**
  76964. * Creates a new HDRCubeTextureAssetTask object
  76965. * @param name defines the name of the task
  76966. * @param url defines the location of the file to load
  76967. * @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.
  76968. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76969. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76970. * @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)
  76971. * @param reserved Internal use only
  76972. */
  76973. constructor(
  76974. /**
  76975. * Defines the name of the task
  76976. */
  76977. name: string,
  76978. /**
  76979. * Defines the location of the file to load
  76980. */
  76981. url: string,
  76982. /**
  76983. * Defines the desired size (the more it increases the longer the generation will be)
  76984. */
  76985. size: number,
  76986. /**
  76987. * Defines if mipmaps should not be generated (default is false)
  76988. */
  76989. noMipmap?: boolean,
  76990. /**
  76991. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76992. */
  76993. generateHarmonics?: boolean,
  76994. /**
  76995. * 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)
  76996. */
  76997. gammaSpace?: boolean,
  76998. /**
  76999. * Internal Use Only
  77000. */
  77001. reserved?: boolean);
  77002. /**
  77003. * Execute the current task
  77004. * @param scene defines the scene where you want your assets to be loaded
  77005. * @param onSuccess is a callback called when the task is successfully executed
  77006. * @param onError is a callback called if an error occurs
  77007. */
  77008. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77009. }
  77010. /**
  77011. * Define a task used by AssetsManager to load Equirectangular cube textures
  77012. */
  77013. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77014. /**
  77015. * Defines the name of the task
  77016. */
  77017. name: string;
  77018. /**
  77019. * Defines the location of the file to load
  77020. */
  77021. url: string;
  77022. /**
  77023. * Defines the desired size (the more it increases the longer the generation will be)
  77024. */
  77025. size: number;
  77026. /**
  77027. * Defines if mipmaps should not be generated (default is false)
  77028. */
  77029. noMipmap: boolean;
  77030. /**
  77031. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77032. * but the standard material would require them in Gamma space) (default is true)
  77033. */
  77034. gammaSpace: boolean;
  77035. /**
  77036. * Gets the loaded texture
  77037. */
  77038. texture: EquiRectangularCubeTexture;
  77039. /**
  77040. * Callback called when the task is successful
  77041. */
  77042. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77043. /**
  77044. * Callback called when the task is successful
  77045. */
  77046. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77047. /**
  77048. * Creates a new EquiRectangularCubeTextureAssetTask object
  77049. * @param name defines the name of the task
  77050. * @param url defines the location of the file to load
  77051. * @param size defines the desired size (the more it increases the longer the generation will be)
  77052. * If the size is omitted this implies you are using a preprocessed cubemap.
  77053. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77054. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77055. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77056. * (default is true)
  77057. */
  77058. constructor(
  77059. /**
  77060. * Defines the name of the task
  77061. */
  77062. name: string,
  77063. /**
  77064. * Defines the location of the file to load
  77065. */
  77066. url: string,
  77067. /**
  77068. * Defines the desired size (the more it increases the longer the generation will be)
  77069. */
  77070. size: number,
  77071. /**
  77072. * Defines if mipmaps should not be generated (default is false)
  77073. */
  77074. noMipmap?: boolean,
  77075. /**
  77076. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77077. * but the standard material would require them in Gamma space) (default is true)
  77078. */
  77079. gammaSpace?: boolean);
  77080. /**
  77081. * Execute the current task
  77082. * @param scene defines the scene where you want your assets to be loaded
  77083. * @param onSuccess is a callback called when the task is successfully executed
  77084. * @param onError is a callback called if an error occurs
  77085. */
  77086. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77087. }
  77088. /**
  77089. * This class can be used to easily import assets into a scene
  77090. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77091. */
  77092. export class AssetsManager {
  77093. private _scene;
  77094. private _isLoading;
  77095. protected _tasks: AbstractAssetTask[];
  77096. protected _waitingTasksCount: number;
  77097. protected _totalTasksCount: number;
  77098. /**
  77099. * Callback called when all tasks are processed
  77100. */
  77101. onFinish: (tasks: AbstractAssetTask[]) => void;
  77102. /**
  77103. * Callback called when a task is successful
  77104. */
  77105. onTaskSuccess: (task: AbstractAssetTask) => void;
  77106. /**
  77107. * Callback called when a task had an error
  77108. */
  77109. onTaskError: (task: AbstractAssetTask) => void;
  77110. /**
  77111. * Callback called when a task is done (whatever the result is)
  77112. */
  77113. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77114. /**
  77115. * Observable called when all tasks are processed
  77116. */
  77117. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77118. /**
  77119. * Observable called when a task had an error
  77120. */
  77121. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77122. /**
  77123. * Observable called when all tasks were executed
  77124. */
  77125. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77126. /**
  77127. * Observable called when a task is done (whatever the result is)
  77128. */
  77129. onProgressObservable: Observable<IAssetsProgressEvent>;
  77130. /**
  77131. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77132. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77133. */
  77134. useDefaultLoadingScreen: boolean;
  77135. /**
  77136. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77137. * when all assets have been downloaded.
  77138. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77139. */
  77140. autoHideLoadingUI: boolean;
  77141. /**
  77142. * Creates a new AssetsManager
  77143. * @param scene defines the scene to work on
  77144. */
  77145. constructor(scene: Scene);
  77146. /**
  77147. * Add a ContainerAssetTask to the list of active tasks
  77148. * @param taskName defines the name of the new task
  77149. * @param meshesNames defines the name of meshes to load
  77150. * @param rootUrl defines the root url to use to locate files
  77151. * @param sceneFilename defines the filename of the scene file
  77152. * @returns a new ContainerAssetTask object
  77153. */
  77154. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77155. /**
  77156. * Add a MeshAssetTask to the list of active tasks
  77157. * @param taskName defines the name of the new task
  77158. * @param meshesNames defines the name of meshes to load
  77159. * @param rootUrl defines the root url to use to locate files
  77160. * @param sceneFilename defines the filename of the scene file
  77161. * @returns a new MeshAssetTask object
  77162. */
  77163. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77164. /**
  77165. * Add a TextFileAssetTask to the list of active tasks
  77166. * @param taskName defines the name of the new task
  77167. * @param url defines the url of the file to load
  77168. * @returns a new TextFileAssetTask object
  77169. */
  77170. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77171. /**
  77172. * Add a BinaryFileAssetTask to the list of active tasks
  77173. * @param taskName defines the name of the new task
  77174. * @param url defines the url of the file to load
  77175. * @returns a new BinaryFileAssetTask object
  77176. */
  77177. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77178. /**
  77179. * Add a ImageAssetTask to the list of active tasks
  77180. * @param taskName defines the name of the new task
  77181. * @param url defines the url of the file to load
  77182. * @returns a new ImageAssetTask object
  77183. */
  77184. addImageTask(taskName: string, url: string): ImageAssetTask;
  77185. /**
  77186. * Add a TextureAssetTask to the list of active tasks
  77187. * @param taskName defines the name of the new task
  77188. * @param url defines the url of the file to load
  77189. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77190. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77191. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77192. * @returns a new TextureAssetTask object
  77193. */
  77194. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77195. /**
  77196. * Add a CubeTextureAssetTask to the list of active tasks
  77197. * @param taskName defines the name of the new task
  77198. * @param url defines the url of the file to load
  77199. * @param extensions defines the extension to use to load the cube map (can be null)
  77200. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77201. * @param files defines the list of files to load (can be null)
  77202. * @returns a new CubeTextureAssetTask object
  77203. */
  77204. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77205. /**
  77206. *
  77207. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77208. * @param taskName defines the name of the new task
  77209. * @param url defines the url of the file to load
  77210. * @param size defines the size you want for the cubemap (can be null)
  77211. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77212. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77213. * @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)
  77214. * @param reserved Internal use only
  77215. * @returns a new HDRCubeTextureAssetTask object
  77216. */
  77217. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77218. /**
  77219. *
  77220. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77221. * @param taskName defines the name of the new task
  77222. * @param url defines the url of the file to load
  77223. * @param size defines the size you want for the cubemap (can be null)
  77224. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77225. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77226. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77227. * @returns a new EquiRectangularCubeTextureAssetTask object
  77228. */
  77229. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77230. /**
  77231. * Remove a task from the assets manager.
  77232. * @param task the task to remove
  77233. */
  77234. removeTask(task: AbstractAssetTask): void;
  77235. private _decreaseWaitingTasksCount;
  77236. private _runTask;
  77237. /**
  77238. * Reset the AssetsManager and remove all tasks
  77239. * @return the current instance of the AssetsManager
  77240. */
  77241. reset(): AssetsManager;
  77242. /**
  77243. * Start the loading process
  77244. * @return the current instance of the AssetsManager
  77245. */
  77246. load(): AssetsManager;
  77247. /**
  77248. * Start the loading process as an async operation
  77249. * @return a promise returning the list of failed tasks
  77250. */
  77251. loadAsync(): Promise<void>;
  77252. }
  77253. }
  77254. declare module "babylonjs/Misc/deferred" {
  77255. /**
  77256. * Wrapper class for promise with external resolve and reject.
  77257. */
  77258. export class Deferred<T> {
  77259. /**
  77260. * The promise associated with this deferred object.
  77261. */
  77262. readonly promise: Promise<T>;
  77263. private _resolve;
  77264. private _reject;
  77265. /**
  77266. * The resolve method of the promise associated with this deferred object.
  77267. */
  77268. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  77269. /**
  77270. * The reject method of the promise associated with this deferred object.
  77271. */
  77272. get reject(): (reason?: any) => void;
  77273. /**
  77274. * Constructor for this deferred object.
  77275. */
  77276. constructor();
  77277. }
  77278. }
  77279. declare module "babylonjs/Misc/meshExploder" {
  77280. import { Mesh } from "babylonjs/Meshes/mesh";
  77281. /**
  77282. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77283. */
  77284. export class MeshExploder {
  77285. private _centerMesh;
  77286. private _meshes;
  77287. private _meshesOrigins;
  77288. private _toCenterVectors;
  77289. private _scaledDirection;
  77290. private _newPosition;
  77291. private _centerPosition;
  77292. /**
  77293. * Explodes meshes from a center mesh.
  77294. * @param meshes The meshes to explode.
  77295. * @param centerMesh The mesh to be center of explosion.
  77296. */
  77297. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77298. private _setCenterMesh;
  77299. /**
  77300. * Get class name
  77301. * @returns "MeshExploder"
  77302. */
  77303. getClassName(): string;
  77304. /**
  77305. * "Exploded meshes"
  77306. * @returns Array of meshes with the centerMesh at index 0.
  77307. */
  77308. getMeshes(): Array<Mesh>;
  77309. /**
  77310. * Explodes meshes giving a specific direction
  77311. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77312. */
  77313. explode(direction?: number): void;
  77314. }
  77315. }
  77316. declare module "babylonjs/Misc/filesInput" {
  77317. import { Engine } from "babylonjs/Engines/engine";
  77318. import { Scene } from "babylonjs/scene";
  77319. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  77320. import { Nullable } from "babylonjs/types";
  77321. /**
  77322. * Class used to help managing file picking and drag'n'drop
  77323. */
  77324. export class FilesInput {
  77325. /**
  77326. * List of files ready to be loaded
  77327. */
  77328. static get FilesToLoad(): {
  77329. [key: string]: File;
  77330. };
  77331. /**
  77332. * Callback called when a file is processed
  77333. */
  77334. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  77335. private _engine;
  77336. private _currentScene;
  77337. private _sceneLoadedCallback;
  77338. private _progressCallback;
  77339. private _additionalRenderLoopLogicCallback;
  77340. private _textureLoadingCallback;
  77341. private _startingProcessingFilesCallback;
  77342. private _onReloadCallback;
  77343. private _errorCallback;
  77344. private _elementToMonitor;
  77345. private _sceneFileToLoad;
  77346. private _filesToLoad;
  77347. /**
  77348. * Creates a new FilesInput
  77349. * @param engine defines the rendering engine
  77350. * @param scene defines the hosting scene
  77351. * @param sceneLoadedCallback callback called when scene is loaded
  77352. * @param progressCallback callback called to track progress
  77353. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77354. * @param textureLoadingCallback callback called when a texture is loading
  77355. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77356. * @param onReloadCallback callback called when a reload is requested
  77357. * @param errorCallback callback call if an error occurs
  77358. */
  77359. 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>);
  77360. private _dragEnterHandler;
  77361. private _dragOverHandler;
  77362. private _dropHandler;
  77363. /**
  77364. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77365. * @param elementToMonitor defines the DOM element to track
  77366. */
  77367. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77368. /** Gets the current list of files to load */
  77369. get filesToLoad(): File[];
  77370. /**
  77371. * Release all associated resources
  77372. */
  77373. dispose(): void;
  77374. private renderFunction;
  77375. private drag;
  77376. private drop;
  77377. private _traverseFolder;
  77378. private _processFiles;
  77379. /**
  77380. * Load files from a drop event
  77381. * @param event defines the drop event to use as source
  77382. */
  77383. loadFiles(event: any): void;
  77384. private _processReload;
  77385. /**
  77386. * Reload the current scene from the loaded files
  77387. */
  77388. reload(): void;
  77389. }
  77390. }
  77391. declare module "babylonjs/Misc/HighDynamicRange/index" {
  77392. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  77393. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  77394. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  77395. }
  77396. declare module "babylonjs/Misc/sceneOptimizer" {
  77397. import { Scene, IDisposable } from "babylonjs/scene";
  77398. import { Observable } from "babylonjs/Misc/observable";
  77399. /**
  77400. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77401. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77402. */
  77403. export class SceneOptimization {
  77404. /**
  77405. * Defines the priority of this optimization (0 by default which means first in the list)
  77406. */
  77407. priority: number;
  77408. /**
  77409. * Gets a string describing the action executed by the current optimization
  77410. * @returns description string
  77411. */
  77412. getDescription(): string;
  77413. /**
  77414. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77415. * @param scene defines the current scene where to apply this optimization
  77416. * @param optimizer defines the current optimizer
  77417. * @returns true if everything that can be done was applied
  77418. */
  77419. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77420. /**
  77421. * Creates the SceneOptimization object
  77422. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77423. * @param desc defines the description associated with the optimization
  77424. */
  77425. constructor(
  77426. /**
  77427. * Defines the priority of this optimization (0 by default which means first in the list)
  77428. */
  77429. priority?: number);
  77430. }
  77431. /**
  77432. * Defines an optimization used to reduce the size of render target textures
  77433. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77434. */
  77435. export class TextureOptimization extends SceneOptimization {
  77436. /**
  77437. * Defines the priority of this optimization (0 by default which means first in the list)
  77438. */
  77439. priority: number;
  77440. /**
  77441. * 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
  77442. */
  77443. maximumSize: number;
  77444. /**
  77445. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77446. */
  77447. step: number;
  77448. /**
  77449. * Gets a string describing the action executed by the current optimization
  77450. * @returns description string
  77451. */
  77452. getDescription(): string;
  77453. /**
  77454. * Creates the TextureOptimization object
  77455. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77456. * @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
  77457. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77458. */
  77459. constructor(
  77460. /**
  77461. * Defines the priority of this optimization (0 by default which means first in the list)
  77462. */
  77463. priority?: number,
  77464. /**
  77465. * 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
  77466. */
  77467. maximumSize?: number,
  77468. /**
  77469. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77470. */
  77471. step?: number);
  77472. /**
  77473. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77474. * @param scene defines the current scene where to apply this optimization
  77475. * @param optimizer defines the current optimizer
  77476. * @returns true if everything that can be done was applied
  77477. */
  77478. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77479. }
  77480. /**
  77481. * Defines an optimization used to increase or decrease the rendering resolution
  77482. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77483. */
  77484. export class HardwareScalingOptimization extends SceneOptimization {
  77485. /**
  77486. * Defines the priority of this optimization (0 by default which means first in the list)
  77487. */
  77488. priority: number;
  77489. /**
  77490. * Defines the maximum scale to use (2 by default)
  77491. */
  77492. maximumScale: number;
  77493. /**
  77494. * Defines the step to use between two passes (0.5 by default)
  77495. */
  77496. step: number;
  77497. private _currentScale;
  77498. private _directionOffset;
  77499. /**
  77500. * Gets a string describing the action executed by the current optimization
  77501. * @return description string
  77502. */
  77503. getDescription(): string;
  77504. /**
  77505. * Creates the HardwareScalingOptimization object
  77506. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77507. * @param maximumScale defines the maximum scale to use (2 by default)
  77508. * @param step defines the step to use between two passes (0.5 by default)
  77509. */
  77510. constructor(
  77511. /**
  77512. * Defines the priority of this optimization (0 by default which means first in the list)
  77513. */
  77514. priority?: number,
  77515. /**
  77516. * Defines the maximum scale to use (2 by default)
  77517. */
  77518. maximumScale?: number,
  77519. /**
  77520. * Defines the step to use between two passes (0.5 by default)
  77521. */
  77522. step?: number);
  77523. /**
  77524. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77525. * @param scene defines the current scene where to apply this optimization
  77526. * @param optimizer defines the current optimizer
  77527. * @returns true if everything that can be done was applied
  77528. */
  77529. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77530. }
  77531. /**
  77532. * Defines an optimization used to remove shadows
  77533. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77534. */
  77535. export class ShadowsOptimization extends SceneOptimization {
  77536. /**
  77537. * Gets a string describing the action executed by the current optimization
  77538. * @return description string
  77539. */
  77540. getDescription(): string;
  77541. /**
  77542. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77543. * @param scene defines the current scene where to apply this optimization
  77544. * @param optimizer defines the current optimizer
  77545. * @returns true if everything that can be done was applied
  77546. */
  77547. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77548. }
  77549. /**
  77550. * Defines an optimization used to turn post-processes off
  77551. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77552. */
  77553. export class PostProcessesOptimization extends SceneOptimization {
  77554. /**
  77555. * Gets a string describing the action executed by the current optimization
  77556. * @return description string
  77557. */
  77558. getDescription(): string;
  77559. /**
  77560. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77561. * @param scene defines the current scene where to apply this optimization
  77562. * @param optimizer defines the current optimizer
  77563. * @returns true if everything that can be done was applied
  77564. */
  77565. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77566. }
  77567. /**
  77568. * Defines an optimization used to turn lens flares off
  77569. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77570. */
  77571. export class LensFlaresOptimization extends SceneOptimization {
  77572. /**
  77573. * Gets a string describing the action executed by the current optimization
  77574. * @return description string
  77575. */
  77576. getDescription(): string;
  77577. /**
  77578. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77579. * @param scene defines the current scene where to apply this optimization
  77580. * @param optimizer defines the current optimizer
  77581. * @returns true if everything that can be done was applied
  77582. */
  77583. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77584. }
  77585. /**
  77586. * Defines an optimization based on user defined callback.
  77587. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77588. */
  77589. export class CustomOptimization extends SceneOptimization {
  77590. /**
  77591. * Callback called to apply the custom optimization.
  77592. */
  77593. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  77594. /**
  77595. * Callback called to get custom description
  77596. */
  77597. onGetDescription: () => string;
  77598. /**
  77599. * Gets a string describing the action executed by the current optimization
  77600. * @returns description string
  77601. */
  77602. getDescription(): string;
  77603. /**
  77604. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77605. * @param scene defines the current scene where to apply this optimization
  77606. * @param optimizer defines the current optimizer
  77607. * @returns true if everything that can be done was applied
  77608. */
  77609. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77610. }
  77611. /**
  77612. * Defines an optimization used to turn particles off
  77613. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77614. */
  77615. export class ParticlesOptimization extends SceneOptimization {
  77616. /**
  77617. * Gets a string describing the action executed by the current optimization
  77618. * @return description string
  77619. */
  77620. getDescription(): string;
  77621. /**
  77622. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77623. * @param scene defines the current scene where to apply this optimization
  77624. * @param optimizer defines the current optimizer
  77625. * @returns true if everything that can be done was applied
  77626. */
  77627. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77628. }
  77629. /**
  77630. * Defines an optimization used to turn render targets off
  77631. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77632. */
  77633. export class RenderTargetsOptimization extends SceneOptimization {
  77634. /**
  77635. * Gets a string describing the action executed by the current optimization
  77636. * @return description string
  77637. */
  77638. getDescription(): string;
  77639. /**
  77640. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77641. * @param scene defines the current scene where to apply this optimization
  77642. * @param optimizer defines the current optimizer
  77643. * @returns true if everything that can be done was applied
  77644. */
  77645. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77646. }
  77647. /**
  77648. * Defines an optimization used to merge meshes with compatible materials
  77649. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77650. */
  77651. export class MergeMeshesOptimization extends SceneOptimization {
  77652. private static _UpdateSelectionTree;
  77653. /**
  77654. * Gets or sets a boolean which defines if optimization octree has to be updated
  77655. */
  77656. static get UpdateSelectionTree(): boolean;
  77657. /**
  77658. * Gets or sets a boolean which defines if optimization octree has to be updated
  77659. */
  77660. static set UpdateSelectionTree(value: boolean);
  77661. /**
  77662. * Gets a string describing the action executed by the current optimization
  77663. * @return description string
  77664. */
  77665. getDescription(): string;
  77666. private _canBeMerged;
  77667. /**
  77668. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77669. * @param scene defines the current scene where to apply this optimization
  77670. * @param optimizer defines the current optimizer
  77671. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  77672. * @returns true if everything that can be done was applied
  77673. */
  77674. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  77675. }
  77676. /**
  77677. * Defines a list of options used by SceneOptimizer
  77678. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77679. */
  77680. export class SceneOptimizerOptions {
  77681. /**
  77682. * Defines the target frame rate to reach (60 by default)
  77683. */
  77684. targetFrameRate: number;
  77685. /**
  77686. * Defines the interval between two checkes (2000ms by default)
  77687. */
  77688. trackerDuration: number;
  77689. /**
  77690. * Gets the list of optimizations to apply
  77691. */
  77692. optimizations: SceneOptimization[];
  77693. /**
  77694. * Creates a new list of options used by SceneOptimizer
  77695. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  77696. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  77697. */
  77698. constructor(
  77699. /**
  77700. * Defines the target frame rate to reach (60 by default)
  77701. */
  77702. targetFrameRate?: number,
  77703. /**
  77704. * Defines the interval between two checkes (2000ms by default)
  77705. */
  77706. trackerDuration?: number);
  77707. /**
  77708. * Add a new optimization
  77709. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  77710. * @returns the current SceneOptimizerOptions
  77711. */
  77712. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  77713. /**
  77714. * Add a new custom optimization
  77715. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  77716. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  77717. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77718. * @returns the current SceneOptimizerOptions
  77719. */
  77720. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  77721. /**
  77722. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  77723. * @param targetFrameRate defines the target frame rate (60 by default)
  77724. * @returns a SceneOptimizerOptions object
  77725. */
  77726. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77727. /**
  77728. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  77729. * @param targetFrameRate defines the target frame rate (60 by default)
  77730. * @returns a SceneOptimizerOptions object
  77731. */
  77732. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77733. /**
  77734. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  77735. * @param targetFrameRate defines the target frame rate (60 by default)
  77736. * @returns a SceneOptimizerOptions object
  77737. */
  77738. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77739. }
  77740. /**
  77741. * Class used to run optimizations in order to reach a target frame rate
  77742. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77743. */
  77744. export class SceneOptimizer implements IDisposable {
  77745. private _isRunning;
  77746. private _options;
  77747. private _scene;
  77748. private _currentPriorityLevel;
  77749. private _targetFrameRate;
  77750. private _trackerDuration;
  77751. private _currentFrameRate;
  77752. private _sceneDisposeObserver;
  77753. private _improvementMode;
  77754. /**
  77755. * Defines an observable called when the optimizer reaches the target frame rate
  77756. */
  77757. onSuccessObservable: Observable<SceneOptimizer>;
  77758. /**
  77759. * Defines an observable called when the optimizer enables an optimization
  77760. */
  77761. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  77762. /**
  77763. * Defines an observable called when the optimizer is not able to reach the target frame rate
  77764. */
  77765. onFailureObservable: Observable<SceneOptimizer>;
  77766. /**
  77767. * Gets a boolean indicating if the optimizer is in improvement mode
  77768. */
  77769. get isInImprovementMode(): boolean;
  77770. /**
  77771. * Gets the current priority level (0 at start)
  77772. */
  77773. get currentPriorityLevel(): number;
  77774. /**
  77775. * Gets the current frame rate checked by the SceneOptimizer
  77776. */
  77777. get currentFrameRate(): number;
  77778. /**
  77779. * Gets or sets the current target frame rate (60 by default)
  77780. */
  77781. get targetFrameRate(): number;
  77782. /**
  77783. * Gets or sets the current target frame rate (60 by default)
  77784. */
  77785. set targetFrameRate(value: number);
  77786. /**
  77787. * Gets or sets the current interval between two checks (every 2000ms by default)
  77788. */
  77789. get trackerDuration(): number;
  77790. /**
  77791. * Gets or sets the current interval between two checks (every 2000ms by default)
  77792. */
  77793. set trackerDuration(value: number);
  77794. /**
  77795. * Gets the list of active optimizations
  77796. */
  77797. get optimizations(): SceneOptimization[];
  77798. /**
  77799. * Creates a new SceneOptimizer
  77800. * @param scene defines the scene to work on
  77801. * @param options defines the options to use with the SceneOptimizer
  77802. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  77803. * @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)
  77804. */
  77805. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  77806. /**
  77807. * Stops the current optimizer
  77808. */
  77809. stop(): void;
  77810. /**
  77811. * Reset the optimizer to initial step (current priority level = 0)
  77812. */
  77813. reset(): void;
  77814. /**
  77815. * Start the optimizer. By default it will try to reach a specific framerate
  77816. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  77817. */
  77818. start(): void;
  77819. private _checkCurrentState;
  77820. /**
  77821. * Release all resources
  77822. */
  77823. dispose(): void;
  77824. /**
  77825. * Helper function to create a SceneOptimizer with one single line of code
  77826. * @param scene defines the scene to work on
  77827. * @param options defines the options to use with the SceneOptimizer
  77828. * @param onSuccess defines a callback to call on success
  77829. * @param onFailure defines a callback to call on failure
  77830. * @returns the new SceneOptimizer object
  77831. */
  77832. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  77833. }
  77834. }
  77835. declare module "babylonjs/Misc/sceneSerializer" {
  77836. import { Scene } from "babylonjs/scene";
  77837. /**
  77838. * Class used to serialize a scene into a string
  77839. */
  77840. export class SceneSerializer {
  77841. /**
  77842. * Clear cache used by a previous serialization
  77843. */
  77844. static ClearCache(): void;
  77845. /**
  77846. * Serialize a scene into a JSON compatible object
  77847. * @param scene defines the scene to serialize
  77848. * @returns a JSON compatible object
  77849. */
  77850. static Serialize(scene: Scene): any;
  77851. /**
  77852. * Serialize a mesh into a JSON compatible object
  77853. * @param toSerialize defines the mesh to serialize
  77854. * @param withParents defines if parents must be serialized as well
  77855. * @param withChildren defines if children must be serialized as well
  77856. * @returns a JSON compatible object
  77857. */
  77858. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  77859. }
  77860. }
  77861. declare module "babylonjs/Misc/textureTools" {
  77862. import { Texture } from "babylonjs/Materials/Textures/texture";
  77863. /**
  77864. * Class used to host texture specific utilities
  77865. */
  77866. export class TextureTools {
  77867. /**
  77868. * Uses the GPU to create a copy texture rescaled at a given size
  77869. * @param texture Texture to copy from
  77870. * @param width defines the desired width
  77871. * @param height defines the desired height
  77872. * @param useBilinearMode defines if bilinear mode has to be used
  77873. * @return the generated texture
  77874. */
  77875. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  77876. }
  77877. }
  77878. declare module "babylonjs/Misc/videoRecorder" {
  77879. import { Nullable } from "babylonjs/types";
  77880. import { Engine } from "babylonjs/Engines/engine";
  77881. /**
  77882. * This represents the different options available for the video capture.
  77883. */
  77884. export interface VideoRecorderOptions {
  77885. /** Defines the mime type of the video. */
  77886. mimeType: string;
  77887. /** Defines the FPS the video should be recorded at. */
  77888. fps: number;
  77889. /** Defines the chunk size for the recording data. */
  77890. recordChunckSize: number;
  77891. /** The audio tracks to attach to the recording. */
  77892. audioTracks?: MediaStreamTrack[];
  77893. }
  77894. /**
  77895. * This can help with recording videos from BabylonJS.
  77896. * This is based on the available WebRTC functionalities of the browser.
  77897. *
  77898. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  77899. */
  77900. export class VideoRecorder {
  77901. private static readonly _defaultOptions;
  77902. /**
  77903. * Returns whether or not the VideoRecorder is available in your browser.
  77904. * @param engine Defines the Babylon Engine.
  77905. * @returns true if supported otherwise false.
  77906. */
  77907. static IsSupported(engine: Engine): boolean;
  77908. private readonly _options;
  77909. private _canvas;
  77910. private _mediaRecorder;
  77911. private _recordedChunks;
  77912. private _fileName;
  77913. private _resolve;
  77914. private _reject;
  77915. /**
  77916. * True when a recording is already in progress.
  77917. */
  77918. get isRecording(): boolean;
  77919. /**
  77920. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  77921. * @param engine Defines the BabylonJS Engine you wish to record.
  77922. * @param options Defines options that can be used to customize the capture.
  77923. */
  77924. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  77925. /**
  77926. * Stops the current recording before the default capture timeout passed in the startRecording function.
  77927. */
  77928. stopRecording(): void;
  77929. /**
  77930. * Starts recording the canvas for a max duration specified in parameters.
  77931. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  77932. * If null no automatic download will start and you can rely on the promise to get the data back.
  77933. * @param maxDuration Defines the maximum recording time in seconds.
  77934. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  77935. * @return A promise callback at the end of the recording with the video data in Blob.
  77936. */
  77937. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  77938. /**
  77939. * Releases internal resources used during the recording.
  77940. */
  77941. dispose(): void;
  77942. private _handleDataAvailable;
  77943. private _handleError;
  77944. private _handleStop;
  77945. }
  77946. }
  77947. declare module "babylonjs/Misc/screenshotTools" {
  77948. import { Camera } from "babylonjs/Cameras/camera";
  77949. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  77950. import { Engine } from "babylonjs/Engines/engine";
  77951. /**
  77952. * Class containing a set of static utilities functions for screenshots
  77953. */
  77954. export class ScreenshotTools {
  77955. /**
  77956. * Captures a screenshot of the current rendering
  77957. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77958. * @param engine defines the rendering engine
  77959. * @param camera defines the source camera
  77960. * @param size This parameter can be set to a single number or to an object with the
  77961. * following (optional) properties: precision, width, height. If a single number is passed,
  77962. * it will be used for both width and height. If an object is passed, the screenshot size
  77963. * will be derived from the parameters. The precision property is a multiplier allowing
  77964. * rendering at a higher or lower resolution
  77965. * @param successCallback defines the callback receives a single parameter which contains the
  77966. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77967. * src parameter of an <img> to display it
  77968. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77969. * Check your browser for supported MIME types
  77970. */
  77971. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  77972. /**
  77973. * Captures a screenshot of the current rendering
  77974. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77975. * @param engine defines the rendering engine
  77976. * @param camera defines the source camera
  77977. * @param size This parameter can be set to a single number or to an object with the
  77978. * following (optional) properties: precision, width, height. If a single number is passed,
  77979. * it will be used for both width and height. If an object is passed, the screenshot size
  77980. * will be derived from the parameters. The precision property is a multiplier allowing
  77981. * rendering at a higher or lower resolution
  77982. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77983. * Check your browser for supported MIME types
  77984. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77985. * to the src parameter of an <img> to display it
  77986. */
  77987. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  77988. /**
  77989. * Generates an image screenshot from the specified camera.
  77990. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77991. * @param engine The engine to use for rendering
  77992. * @param camera The camera to use for rendering
  77993. * @param size This parameter can be set to a single number or to an object with the
  77994. * following (optional) properties: precision, width, height. If a single number is passed,
  77995. * it will be used for both width and height. If an object is passed, the screenshot size
  77996. * will be derived from the parameters. The precision property is a multiplier allowing
  77997. * rendering at a higher or lower resolution
  77998. * @param successCallback The callback receives a single parameter which contains the
  77999. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78000. * src parameter of an <img> to display it
  78001. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78002. * Check your browser for supported MIME types
  78003. * @param samples Texture samples (default: 1)
  78004. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78005. * @param fileName A name for for the downloaded file.
  78006. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78007. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78008. */
  78009. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  78010. /**
  78011. * Generates an image screenshot from the specified camera.
  78012. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78013. * @param engine The engine to use for rendering
  78014. * @param camera The camera to use for rendering
  78015. * @param size This parameter can be set to a single number or to an object with the
  78016. * following (optional) properties: precision, width, height. If a single number is passed,
  78017. * it will be used for both width and height. If an object is passed, the screenshot size
  78018. * will be derived from the parameters. The precision property is a multiplier allowing
  78019. * rendering at a higher or lower resolution
  78020. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78021. * Check your browser for supported MIME types
  78022. * @param samples Texture samples (default: 1)
  78023. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78024. * @param fileName A name for for the downloaded file.
  78025. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78026. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78027. * to the src parameter of an <img> to display it
  78028. */
  78029. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78030. /**
  78031. * Gets height and width for screenshot size
  78032. * @private
  78033. */
  78034. private static _getScreenshotSize;
  78035. }
  78036. }
  78037. declare module "babylonjs/Misc/dataReader" {
  78038. /**
  78039. * Interface for a data buffer
  78040. */
  78041. export interface IDataBuffer {
  78042. /**
  78043. * Reads bytes from the data buffer.
  78044. * @param byteOffset The byte offset to read
  78045. * @param byteLength The byte length to read
  78046. * @returns A promise that resolves when the bytes are read
  78047. */
  78048. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78049. /**
  78050. * The byte length of the buffer.
  78051. */
  78052. readonly byteLength: number;
  78053. }
  78054. /**
  78055. * Utility class for reading from a data buffer
  78056. */
  78057. export class DataReader {
  78058. /**
  78059. * The data buffer associated with this data reader.
  78060. */
  78061. readonly buffer: IDataBuffer;
  78062. /**
  78063. * The current byte offset from the beginning of the data buffer.
  78064. */
  78065. byteOffset: number;
  78066. private _dataView;
  78067. private _dataByteOffset;
  78068. /**
  78069. * Constructor
  78070. * @param buffer The buffer to read
  78071. */
  78072. constructor(buffer: IDataBuffer);
  78073. /**
  78074. * Loads the given byte length.
  78075. * @param byteLength The byte length to load
  78076. * @returns A promise that resolves when the load is complete
  78077. */
  78078. loadAsync(byteLength: number): Promise<void>;
  78079. /**
  78080. * Read a unsigned 32-bit integer from the currently loaded data range.
  78081. * @returns The 32-bit integer read
  78082. */
  78083. readUint32(): number;
  78084. /**
  78085. * Read a byte array from the currently loaded data range.
  78086. * @param byteLength The byte length to read
  78087. * @returns The byte array read
  78088. */
  78089. readUint8Array(byteLength: number): Uint8Array;
  78090. /**
  78091. * Read a string from the currently loaded data range.
  78092. * @param byteLength The byte length to read
  78093. * @returns The string read
  78094. */
  78095. readString(byteLength: number): string;
  78096. /**
  78097. * Skips the given byte length the currently loaded data range.
  78098. * @param byteLength The byte length to skip
  78099. */
  78100. skipBytes(byteLength: number): void;
  78101. }
  78102. }
  78103. declare module "babylonjs/Misc/dataStorage" {
  78104. /**
  78105. * Class for storing data to local storage if available or in-memory storage otherwise
  78106. */
  78107. export class DataStorage {
  78108. private static _Storage;
  78109. private static _GetStorage;
  78110. /**
  78111. * Reads a string from the data storage
  78112. * @param key The key to read
  78113. * @param defaultValue The value if the key doesn't exist
  78114. * @returns The string value
  78115. */
  78116. static ReadString(key: string, defaultValue: string): string;
  78117. /**
  78118. * Writes a string to the data storage
  78119. * @param key The key to write
  78120. * @param value The value to write
  78121. */
  78122. static WriteString(key: string, value: string): void;
  78123. /**
  78124. * Reads a boolean from the data storage
  78125. * @param key The key to read
  78126. * @param defaultValue The value if the key doesn't exist
  78127. * @returns The boolean value
  78128. */
  78129. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78130. /**
  78131. * Writes a boolean to the data storage
  78132. * @param key The key to write
  78133. * @param value The value to write
  78134. */
  78135. static WriteBoolean(key: string, value: boolean): void;
  78136. /**
  78137. * Reads a number from the data storage
  78138. * @param key The key to read
  78139. * @param defaultValue The value if the key doesn't exist
  78140. * @returns The number value
  78141. */
  78142. static ReadNumber(key: string, defaultValue: number): number;
  78143. /**
  78144. * Writes a number to the data storage
  78145. * @param key The key to write
  78146. * @param value The value to write
  78147. */
  78148. static WriteNumber(key: string, value: number): void;
  78149. }
  78150. }
  78151. declare module "babylonjs/Misc/sceneRecorder" {
  78152. import { Scene } from "babylonjs/scene";
  78153. /**
  78154. * Class used to record delta files between 2 scene states
  78155. */
  78156. export class SceneRecorder {
  78157. private _trackedScene;
  78158. private _savedJSON;
  78159. /**
  78160. * Track a given scene. This means the current scene state will be considered the original state
  78161. * @param scene defines the scene to track
  78162. */
  78163. track(scene: Scene): void;
  78164. /**
  78165. * Get the delta between current state and original state
  78166. * @returns a string containing the delta
  78167. */
  78168. getDelta(): any;
  78169. private _compareArray;
  78170. private _compareObjects;
  78171. private _compareCollections;
  78172. private static GetShadowGeneratorById;
  78173. /**
  78174. * Apply a given delta to a given scene
  78175. * @param deltaJSON defines the JSON containing the delta
  78176. * @param scene defines the scene to apply the delta to
  78177. */
  78178. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78179. private static _ApplyPropertiesToEntity;
  78180. private static _ApplyDeltaForEntity;
  78181. }
  78182. }
  78183. declare module "babylonjs/Misc/index" {
  78184. export * from "babylonjs/Misc/andOrNotEvaluator";
  78185. export * from "babylonjs/Misc/assetsManager";
  78186. export * from "babylonjs/Misc/basis";
  78187. export * from "babylonjs/Misc/dds";
  78188. export * from "babylonjs/Misc/decorators";
  78189. export * from "babylonjs/Misc/deferred";
  78190. export * from "babylonjs/Misc/environmentTextureTools";
  78191. export * from "babylonjs/Misc/meshExploder";
  78192. export * from "babylonjs/Misc/filesInput";
  78193. export * from "babylonjs/Misc/HighDynamicRange/index";
  78194. export * from "babylonjs/Misc/khronosTextureContainer";
  78195. export * from "babylonjs/Misc/observable";
  78196. export * from "babylonjs/Misc/performanceMonitor";
  78197. export * from "babylonjs/Misc/promise";
  78198. export * from "babylonjs/Misc/sceneOptimizer";
  78199. export * from "babylonjs/Misc/sceneSerializer";
  78200. export * from "babylonjs/Misc/smartArray";
  78201. export * from "babylonjs/Misc/stringDictionary";
  78202. export * from "babylonjs/Misc/tags";
  78203. export * from "babylonjs/Misc/textureTools";
  78204. export * from "babylonjs/Misc/tga";
  78205. export * from "babylonjs/Misc/tools";
  78206. export * from "babylonjs/Misc/videoRecorder";
  78207. export * from "babylonjs/Misc/virtualJoystick";
  78208. export * from "babylonjs/Misc/workerPool";
  78209. export * from "babylonjs/Misc/logger";
  78210. export * from "babylonjs/Misc/typeStore";
  78211. export * from "babylonjs/Misc/filesInputStore";
  78212. export * from "babylonjs/Misc/deepCopier";
  78213. export * from "babylonjs/Misc/pivotTools";
  78214. export * from "babylonjs/Misc/precisionDate";
  78215. export * from "babylonjs/Misc/screenshotTools";
  78216. export * from "babylonjs/Misc/typeStore";
  78217. export * from "babylonjs/Misc/webRequest";
  78218. export * from "babylonjs/Misc/iInspectable";
  78219. export * from "babylonjs/Misc/brdfTextureTools";
  78220. export * from "babylonjs/Misc/rgbdTextureTools";
  78221. export * from "babylonjs/Misc/gradients";
  78222. export * from "babylonjs/Misc/perfCounter";
  78223. export * from "babylonjs/Misc/fileRequest";
  78224. export * from "babylonjs/Misc/customAnimationFrameRequester";
  78225. export * from "babylonjs/Misc/retryStrategy";
  78226. export * from "babylonjs/Misc/interfaces/screenshotSize";
  78227. export * from "babylonjs/Misc/canvasGenerator";
  78228. export * from "babylonjs/Misc/fileTools";
  78229. export * from "babylonjs/Misc/stringTools";
  78230. export * from "babylonjs/Misc/dataReader";
  78231. export * from "babylonjs/Misc/minMaxReducer";
  78232. export * from "babylonjs/Misc/depthReducer";
  78233. export * from "babylonjs/Misc/dataStorage";
  78234. export * from "babylonjs/Misc/sceneRecorder";
  78235. }
  78236. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  78237. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  78238. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78239. import { Observable } from "babylonjs/Misc/observable";
  78240. import { Matrix } from "babylonjs/Maths/math.vector";
  78241. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78242. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78243. /**
  78244. * An interface for all Hit test features
  78245. */
  78246. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78247. /**
  78248. * Triggered when new babylon (transformed) hit test results are available
  78249. */
  78250. onHitTestResultObservable: Observable<T[]>;
  78251. }
  78252. /**
  78253. * Options used for hit testing
  78254. */
  78255. export interface IWebXRLegacyHitTestOptions {
  78256. /**
  78257. * Only test when user interacted with the scene. Default - hit test every frame
  78258. */
  78259. testOnPointerDownOnly?: boolean;
  78260. /**
  78261. * The node to use to transform the local results to world coordinates
  78262. */
  78263. worldParentNode?: TransformNode;
  78264. }
  78265. /**
  78266. * Interface defining the babylon result of raycasting/hit-test
  78267. */
  78268. export interface IWebXRLegacyHitResult {
  78269. /**
  78270. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78271. */
  78272. transformationMatrix: Matrix;
  78273. /**
  78274. * The native hit test result
  78275. */
  78276. xrHitResult: XRHitResult | XRHitTestResult;
  78277. }
  78278. /**
  78279. * The currently-working hit-test module.
  78280. * Hit test (or Ray-casting) is used to interact with the real world.
  78281. * For further information read here - https://github.com/immersive-web/hit-test
  78282. */
  78283. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78284. /**
  78285. * options to use when constructing this feature
  78286. */
  78287. readonly options: IWebXRLegacyHitTestOptions;
  78288. private _direction;
  78289. private _mat;
  78290. private _onSelectEnabled;
  78291. private _origin;
  78292. /**
  78293. * The module's name
  78294. */
  78295. static readonly Name: string;
  78296. /**
  78297. * The (Babylon) version of this module.
  78298. * This is an integer representing the implementation version.
  78299. * This number does not correspond to the WebXR specs version
  78300. */
  78301. static readonly Version: number;
  78302. /**
  78303. * Populated with the last native XR Hit Results
  78304. */
  78305. lastNativeXRHitResults: XRHitResult[];
  78306. /**
  78307. * Triggered when new babylon (transformed) hit test results are available
  78308. */
  78309. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78310. /**
  78311. * Creates a new instance of the (legacy version) hit test feature
  78312. * @param _xrSessionManager an instance of WebXRSessionManager
  78313. * @param options options to use when constructing this feature
  78314. */
  78315. constructor(_xrSessionManager: WebXRSessionManager,
  78316. /**
  78317. * options to use when constructing this feature
  78318. */
  78319. options?: IWebXRLegacyHitTestOptions);
  78320. /**
  78321. * execute a hit test with an XR Ray
  78322. *
  78323. * @param xrSession a native xrSession that will execute this hit test
  78324. * @param xrRay the ray (position and direction) to use for ray-casting
  78325. * @param referenceSpace native XR reference space to use for the hit-test
  78326. * @param filter filter function that will filter the results
  78327. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78328. */
  78329. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78330. /**
  78331. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78332. * @param event the (select) event to use to select with
  78333. * @param referenceSpace the reference space to use for this hit test
  78334. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78335. */
  78336. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78337. /**
  78338. * attach this feature
  78339. * Will usually be called by the features manager
  78340. *
  78341. * @returns true if successful.
  78342. */
  78343. attach(): boolean;
  78344. /**
  78345. * detach this feature.
  78346. * Will usually be called by the features manager
  78347. *
  78348. * @returns true if successful.
  78349. */
  78350. detach(): boolean;
  78351. /**
  78352. * Dispose this feature and all of the resources attached
  78353. */
  78354. dispose(): void;
  78355. protected _onXRFrame(frame: XRFrame): void;
  78356. private _onHitTestResults;
  78357. private _onSelect;
  78358. }
  78359. }
  78360. declare module "babylonjs/XR/features/WebXRHitTest" {
  78361. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78362. import { Observable } from "babylonjs/Misc/observable";
  78363. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78364. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78365. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  78366. /**
  78367. * Options used for hit testing (version 2)
  78368. */
  78369. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  78370. /**
  78371. * Do not create a permanent hit test. Will usually be used when only
  78372. * transient inputs are needed.
  78373. */
  78374. disablePermanentHitTest?: boolean;
  78375. /**
  78376. * Enable transient (for example touch-based) hit test inspections
  78377. */
  78378. enableTransientHitTest?: boolean;
  78379. /**
  78380. * Offset ray for the permanent hit test
  78381. */
  78382. offsetRay?: Vector3;
  78383. /**
  78384. * Offset ray for the transient hit test
  78385. */
  78386. transientOffsetRay?: Vector3;
  78387. /**
  78388. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  78389. */
  78390. useReferenceSpace?: boolean;
  78391. /**
  78392. * Override the default entity type(s) of the hit-test result
  78393. */
  78394. entityTypes?: XRHitTestTrackableType[];
  78395. }
  78396. /**
  78397. * Interface defining the babylon result of hit-test
  78398. */
  78399. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  78400. /**
  78401. * The input source that generated this hit test (if transient)
  78402. */
  78403. inputSource?: XRInputSource;
  78404. /**
  78405. * Is this a transient hit test
  78406. */
  78407. isTransient?: boolean;
  78408. /**
  78409. * Position of the hit test result
  78410. */
  78411. position: Vector3;
  78412. /**
  78413. * Rotation of the hit test result
  78414. */
  78415. rotationQuaternion: Quaternion;
  78416. /**
  78417. * The native hit test result
  78418. */
  78419. xrHitResult: XRHitTestResult;
  78420. }
  78421. /**
  78422. * The currently-working hit-test module.
  78423. * Hit test (or Ray-casting) is used to interact with the real world.
  78424. * For further information read here - https://github.com/immersive-web/hit-test
  78425. *
  78426. * Tested on chrome (mobile) 80.
  78427. */
  78428. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  78429. /**
  78430. * options to use when constructing this feature
  78431. */
  78432. readonly options: IWebXRHitTestOptions;
  78433. private _tmpMat;
  78434. private _tmpPos;
  78435. private _tmpQuat;
  78436. private _transientXrHitTestSource;
  78437. private _xrHitTestSource;
  78438. private initHitTestSource;
  78439. /**
  78440. * The module's name
  78441. */
  78442. static readonly Name: string;
  78443. /**
  78444. * The (Babylon) version of this module.
  78445. * This is an integer representing the implementation version.
  78446. * This number does not correspond to the WebXR specs version
  78447. */
  78448. static readonly Version: number;
  78449. /**
  78450. * When set to true, each hit test will have its own position/rotation objects
  78451. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  78452. * the developers will clone them or copy them as they see fit.
  78453. */
  78454. autoCloneTransformation: boolean;
  78455. /**
  78456. * Triggered when new babylon (transformed) hit test results are available
  78457. */
  78458. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  78459. /**
  78460. * Use this to temporarily pause hit test checks.
  78461. */
  78462. paused: boolean;
  78463. /**
  78464. * Creates a new instance of the hit test feature
  78465. * @param _xrSessionManager an instance of WebXRSessionManager
  78466. * @param options options to use when constructing this feature
  78467. */
  78468. constructor(_xrSessionManager: WebXRSessionManager,
  78469. /**
  78470. * options to use when constructing this feature
  78471. */
  78472. options?: IWebXRHitTestOptions);
  78473. /**
  78474. * attach this feature
  78475. * Will usually be called by the features manager
  78476. *
  78477. * @returns true if successful.
  78478. */
  78479. attach(): boolean;
  78480. /**
  78481. * detach this feature.
  78482. * Will usually be called by the features manager
  78483. *
  78484. * @returns true if successful.
  78485. */
  78486. detach(): boolean;
  78487. /**
  78488. * Dispose this feature and all of the resources attached
  78489. */
  78490. dispose(): void;
  78491. protected _onXRFrame(frame: XRFrame): void;
  78492. private _processWebXRHitTestResult;
  78493. }
  78494. }
  78495. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  78496. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78497. import { Observable } from "babylonjs/Misc/observable";
  78498. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78499. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78500. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78501. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  78502. /**
  78503. * Configuration options of the anchor system
  78504. */
  78505. export interface IWebXRAnchorSystemOptions {
  78506. /**
  78507. * a node that will be used to convert local to world coordinates
  78508. */
  78509. worldParentNode?: TransformNode;
  78510. /**
  78511. * If set to true a reference of the created anchors will be kept until the next session starts
  78512. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78513. */
  78514. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78515. }
  78516. /**
  78517. * A babylon container for an XR Anchor
  78518. */
  78519. export interface IWebXRAnchor {
  78520. /**
  78521. * A babylon-assigned ID for this anchor
  78522. */
  78523. id: number;
  78524. /**
  78525. * Transformation matrix to apply to an object attached to this anchor
  78526. */
  78527. transformationMatrix: Matrix;
  78528. /**
  78529. * The native anchor object
  78530. */
  78531. xrAnchor: XRAnchor;
  78532. /**
  78533. * if defined, this object will be constantly updated by the anchor's position and rotation
  78534. */
  78535. attachedNode?: TransformNode;
  78536. }
  78537. /**
  78538. * An implementation of the anchor system for WebXR.
  78539. * For further information see https://github.com/immersive-web/anchors/
  78540. */
  78541. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  78542. private _options;
  78543. private _lastFrameDetected;
  78544. private _trackedAnchors;
  78545. private _referenceSpaceForFrameAnchors;
  78546. private _futureAnchors;
  78547. /**
  78548. * The module's name
  78549. */
  78550. static readonly Name: string;
  78551. /**
  78552. * The (Babylon) version of this module.
  78553. * This is an integer representing the implementation version.
  78554. * This number does not correspond to the WebXR specs version
  78555. */
  78556. static readonly Version: number;
  78557. /**
  78558. * Observers registered here will be executed when a new anchor was added to the session
  78559. */
  78560. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  78561. /**
  78562. * Observers registered here will be executed when an anchor was removed from the session
  78563. */
  78564. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  78565. /**
  78566. * Observers registered here will be executed when an existing anchor updates
  78567. * This can execute N times every frame
  78568. */
  78569. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  78570. /**
  78571. * Set the reference space to use for anchor creation, when not using a hit test.
  78572. * Will default to the session's reference space if not defined
  78573. */
  78574. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  78575. /**
  78576. * constructs a new anchor system
  78577. * @param _xrSessionManager an instance of WebXRSessionManager
  78578. * @param _options configuration object for this feature
  78579. */
  78580. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  78581. private _tmpVector;
  78582. private _tmpQuaternion;
  78583. private _populateTmpTransformation;
  78584. /**
  78585. * Create a new anchor point using a hit test result at a specific point in the scene
  78586. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78587. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78588. *
  78589. * @param hitTestResult The hit test result to use for this anchor creation
  78590. * @param position an optional position offset for this anchor
  78591. * @param rotationQuaternion an optional rotation offset for this anchor
  78592. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78593. */
  78594. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  78595. /**
  78596. * Add a new anchor at a specific position and rotation
  78597. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  78598. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  78599. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78600. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78601. *
  78602. * @param position the position in which to add an anchor
  78603. * @param rotationQuaternion an optional rotation for the anchor transformation
  78604. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  78605. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78606. */
  78607. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  78608. /**
  78609. * detach this feature.
  78610. * Will usually be called by the features manager
  78611. *
  78612. * @returns true if successful.
  78613. */
  78614. detach(): boolean;
  78615. /**
  78616. * Dispose this feature and all of the resources attached
  78617. */
  78618. dispose(): void;
  78619. protected _onXRFrame(frame: XRFrame): void;
  78620. /**
  78621. * avoiding using Array.find for global support.
  78622. * @param xrAnchor the plane to find in the array
  78623. */
  78624. private _findIndexInAnchorArray;
  78625. private _updateAnchorWithXRFrame;
  78626. private _createAnchorAtTransformation;
  78627. }
  78628. }
  78629. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  78630. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78631. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78632. import { Observable } from "babylonjs/Misc/observable";
  78633. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  78634. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78635. /**
  78636. * Options used in the plane detector module
  78637. */
  78638. export interface IWebXRPlaneDetectorOptions {
  78639. /**
  78640. * The node to use to transform the local results to world coordinates
  78641. */
  78642. worldParentNode?: TransformNode;
  78643. /**
  78644. * If set to true a reference of the created planes will be kept until the next session starts
  78645. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  78646. */
  78647. doNotRemovePlanesOnSessionEnded?: boolean;
  78648. }
  78649. /**
  78650. * A babylon interface for a WebXR plane.
  78651. * A Plane is actually a polygon, built from N points in space
  78652. *
  78653. * Supported in chrome 79, not supported in canary 81 ATM
  78654. */
  78655. export interface IWebXRPlane {
  78656. /**
  78657. * a babylon-assigned ID for this polygon
  78658. */
  78659. id: number;
  78660. /**
  78661. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  78662. */
  78663. polygonDefinition: Array<Vector3>;
  78664. /**
  78665. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  78666. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  78667. */
  78668. transformationMatrix: Matrix;
  78669. /**
  78670. * the native xr-plane object
  78671. */
  78672. xrPlane: XRPlane;
  78673. }
  78674. /**
  78675. * The plane detector is used to detect planes in the real world when in AR
  78676. * For more information see https://github.com/immersive-web/real-world-geometry/
  78677. */
  78678. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  78679. private _options;
  78680. private _detectedPlanes;
  78681. private _enabled;
  78682. private _lastFrameDetected;
  78683. /**
  78684. * The module's name
  78685. */
  78686. static readonly Name: string;
  78687. /**
  78688. * The (Babylon) version of this module.
  78689. * This is an integer representing the implementation version.
  78690. * This number does not correspond to the WebXR specs version
  78691. */
  78692. static readonly Version: number;
  78693. /**
  78694. * Observers registered here will be executed when a new plane was added to the session
  78695. */
  78696. onPlaneAddedObservable: Observable<IWebXRPlane>;
  78697. /**
  78698. * Observers registered here will be executed when a plane is no longer detected in the session
  78699. */
  78700. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  78701. /**
  78702. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  78703. * This can execute N times every frame
  78704. */
  78705. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  78706. /**
  78707. * construct a new Plane Detector
  78708. * @param _xrSessionManager an instance of xr Session manager
  78709. * @param _options configuration to use when constructing this feature
  78710. */
  78711. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  78712. /**
  78713. * detach this feature.
  78714. * Will usually be called by the features manager
  78715. *
  78716. * @returns true if successful.
  78717. */
  78718. detach(): boolean;
  78719. /**
  78720. * Dispose this feature and all of the resources attached
  78721. */
  78722. dispose(): void;
  78723. protected _onXRFrame(frame: XRFrame): void;
  78724. private _init;
  78725. private _updatePlaneWithXRPlane;
  78726. /**
  78727. * avoiding using Array.find for global support.
  78728. * @param xrPlane the plane to find in the array
  78729. */
  78730. private findIndexInPlaneArray;
  78731. }
  78732. }
  78733. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  78734. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78736. import { Observable } from "babylonjs/Misc/observable";
  78737. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78738. /**
  78739. * Options interface for the background remover plugin
  78740. */
  78741. export interface IWebXRBackgroundRemoverOptions {
  78742. /**
  78743. * Further background meshes to disable when entering AR
  78744. */
  78745. backgroundMeshes?: AbstractMesh[];
  78746. /**
  78747. * flags to configure the removal of the environment helper.
  78748. * If not set, the entire background will be removed. If set, flags should be set as well.
  78749. */
  78750. environmentHelperRemovalFlags?: {
  78751. /**
  78752. * Should the skybox be removed (default false)
  78753. */
  78754. skyBox?: boolean;
  78755. /**
  78756. * Should the ground be removed (default false)
  78757. */
  78758. ground?: boolean;
  78759. };
  78760. /**
  78761. * don't disable the environment helper
  78762. */
  78763. ignoreEnvironmentHelper?: boolean;
  78764. }
  78765. /**
  78766. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  78767. */
  78768. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  78769. /**
  78770. * read-only options to be used in this module
  78771. */
  78772. readonly options: IWebXRBackgroundRemoverOptions;
  78773. /**
  78774. * The module's name
  78775. */
  78776. static readonly Name: string;
  78777. /**
  78778. * The (Babylon) version of this module.
  78779. * This is an integer representing the implementation version.
  78780. * This number does not correspond to the WebXR specs version
  78781. */
  78782. static readonly Version: number;
  78783. /**
  78784. * registered observers will be triggered when the background state changes
  78785. */
  78786. onBackgroundStateChangedObservable: Observable<boolean>;
  78787. /**
  78788. * constructs a new background remover module
  78789. * @param _xrSessionManager the session manager for this module
  78790. * @param options read-only options to be used in this module
  78791. */
  78792. constructor(_xrSessionManager: WebXRSessionManager,
  78793. /**
  78794. * read-only options to be used in this module
  78795. */
  78796. options?: IWebXRBackgroundRemoverOptions);
  78797. /**
  78798. * attach this feature
  78799. * Will usually be called by the features manager
  78800. *
  78801. * @returns true if successful.
  78802. */
  78803. attach(): boolean;
  78804. /**
  78805. * detach this feature.
  78806. * Will usually be called by the features manager
  78807. *
  78808. * @returns true if successful.
  78809. */
  78810. detach(): boolean;
  78811. /**
  78812. * Dispose this feature and all of the resources attached
  78813. */
  78814. dispose(): void;
  78815. protected _onXRFrame(_xrFrame: XRFrame): void;
  78816. private _setBackgroundState;
  78817. }
  78818. }
  78819. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  78820. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78821. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  78822. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  78823. import { WebXRInput } from "babylonjs/XR/webXRInput";
  78824. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78825. import { Nullable } from "babylonjs/types";
  78826. /**
  78827. * Options for the controller physics feature
  78828. */
  78829. export class IWebXRControllerPhysicsOptions {
  78830. /**
  78831. * Should the headset get its own impostor
  78832. */
  78833. enableHeadsetImpostor?: boolean;
  78834. /**
  78835. * Optional parameters for the headset impostor
  78836. */
  78837. headsetImpostorParams?: {
  78838. /**
  78839. * The type of impostor to create. Default is sphere
  78840. */
  78841. impostorType: number;
  78842. /**
  78843. * the size of the impostor. Defaults to 10cm
  78844. */
  78845. impostorSize?: number | {
  78846. width: number;
  78847. height: number;
  78848. depth: number;
  78849. };
  78850. /**
  78851. * Friction definitions
  78852. */
  78853. friction?: number;
  78854. /**
  78855. * Restitution
  78856. */
  78857. restitution?: number;
  78858. };
  78859. /**
  78860. * The physics properties of the future impostors
  78861. */
  78862. physicsProperties?: {
  78863. /**
  78864. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  78865. * Note that this requires a physics engine that supports mesh impostors!
  78866. */
  78867. useControllerMesh?: boolean;
  78868. /**
  78869. * The type of impostor to create. Default is sphere
  78870. */
  78871. impostorType?: number;
  78872. /**
  78873. * the size of the impostor. Defaults to 10cm
  78874. */
  78875. impostorSize?: number | {
  78876. width: number;
  78877. height: number;
  78878. depth: number;
  78879. };
  78880. /**
  78881. * Friction definitions
  78882. */
  78883. friction?: number;
  78884. /**
  78885. * Restitution
  78886. */
  78887. restitution?: number;
  78888. };
  78889. /**
  78890. * the xr input to use with this pointer selection
  78891. */
  78892. xrInput: WebXRInput;
  78893. }
  78894. /**
  78895. * Add physics impostor to your webxr controllers,
  78896. * including naive calculation of their linear and angular velocity
  78897. */
  78898. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  78899. private readonly _options;
  78900. private _attachController;
  78901. private _controllers;
  78902. private _debugMode;
  78903. private _delta;
  78904. private _headsetImpostor?;
  78905. private _headsetMesh?;
  78906. private _lastTimestamp;
  78907. private _tmpQuaternion;
  78908. private _tmpVector;
  78909. /**
  78910. * The module's name
  78911. */
  78912. static readonly Name: string;
  78913. /**
  78914. * The (Babylon) version of this module.
  78915. * This is an integer representing the implementation version.
  78916. * This number does not correspond to the webxr specs version
  78917. */
  78918. static readonly Version: number;
  78919. /**
  78920. * Construct a new Controller Physics Feature
  78921. * @param _xrSessionManager the corresponding xr session manager
  78922. * @param _options options to create this feature with
  78923. */
  78924. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  78925. /**
  78926. * @hidden
  78927. * enable debugging - will show console outputs and the impostor mesh
  78928. */
  78929. _enablePhysicsDebug(): void;
  78930. /**
  78931. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  78932. * @param xrController the controller to add
  78933. */
  78934. addController(xrController: WebXRInputSource): void;
  78935. /**
  78936. * attach this feature
  78937. * Will usually be called by the features manager
  78938. *
  78939. * @returns true if successful.
  78940. */
  78941. attach(): boolean;
  78942. /**
  78943. * detach this feature.
  78944. * Will usually be called by the features manager
  78945. *
  78946. * @returns true if successful.
  78947. */
  78948. detach(): boolean;
  78949. /**
  78950. * Get the headset impostor, if enabled
  78951. * @returns the impostor
  78952. */
  78953. getHeadsetImpostor(): PhysicsImpostor | undefined;
  78954. /**
  78955. * Get the physics impostor of a specific controller.
  78956. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  78957. * @param controller the controller or the controller id of which to get the impostor
  78958. * @returns the impostor or null
  78959. */
  78960. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  78961. /**
  78962. * Update the physics properties provided in the constructor
  78963. * @param newProperties the new properties object
  78964. */
  78965. setPhysicsProperties(newProperties: {
  78966. impostorType?: number;
  78967. impostorSize?: number | {
  78968. width: number;
  78969. height: number;
  78970. depth: number;
  78971. };
  78972. friction?: number;
  78973. restitution?: number;
  78974. }): void;
  78975. protected _onXRFrame(_xrFrame: any): void;
  78976. private _detachController;
  78977. }
  78978. }
  78979. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  78980. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78981. import { Observable } from "babylonjs/Misc/observable";
  78982. import { Vector3 } from "babylonjs/Maths/math.vector";
  78983. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78984. /**
  78985. * A babylon interface for a "WebXR" feature point.
  78986. * Represents the position and confidence value of a given feature point.
  78987. */
  78988. export interface IWebXRFeaturePoint {
  78989. /**
  78990. * Represents the position of the feature point in world space.
  78991. */
  78992. position: Vector3;
  78993. /**
  78994. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  78995. */
  78996. confidenceValue: number;
  78997. }
  78998. /**
  78999. * The feature point system is used to detect feature points from real world geometry.
  79000. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79001. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79002. */
  79003. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79004. private _enabled;
  79005. private _featurePointCloud;
  79006. /**
  79007. * The module's name
  79008. */
  79009. static readonly Name: string;
  79010. /**
  79011. * The (Babylon) version of this module.
  79012. * This is an integer representing the implementation version.
  79013. * This number does not correspond to the WebXR specs version
  79014. */
  79015. static readonly Version: number;
  79016. /**
  79017. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79018. * Will notify the observers about which feature points have been added.
  79019. */
  79020. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79021. /**
  79022. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79023. * Will notify the observers about which feature points have been updated.
  79024. */
  79025. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79026. /**
  79027. * The current feature point cloud maintained across frames.
  79028. */
  79029. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79030. /**
  79031. * construct the feature point system
  79032. * @param _xrSessionManager an instance of xr Session manager
  79033. */
  79034. constructor(_xrSessionManager: WebXRSessionManager);
  79035. /**
  79036. * Detach this feature.
  79037. * Will usually be called by the features manager
  79038. *
  79039. * @returns true if successful.
  79040. */
  79041. detach(): boolean;
  79042. /**
  79043. * Dispose this feature and all of the resources attached
  79044. */
  79045. dispose(): void;
  79046. /**
  79047. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79048. */
  79049. protected _onXRFrame(frame: XRFrame): void;
  79050. /**
  79051. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79052. */
  79053. private _init;
  79054. }
  79055. }
  79056. declare module "babylonjs/XR/features/WebXRHandTracking" {
  79057. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79058. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79060. import { Mesh } from "babylonjs/Meshes/mesh";
  79061. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79062. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79063. import { Nullable } from "babylonjs/types";
  79064. import { IDisposable } from "babylonjs/scene";
  79065. import { Observable } from "babylonjs/Misc/observable";
  79066. /**
  79067. * Configuration interface for the hand tracking feature
  79068. */
  79069. export interface IWebXRHandTrackingOptions {
  79070. /**
  79071. * The xrInput that will be used as source for new hands
  79072. */
  79073. xrInput: WebXRInput;
  79074. /**
  79075. * Configuration object for the joint meshes
  79076. */
  79077. jointMeshes?: {
  79078. /**
  79079. * Should the meshes created be invisible (defaults to false)
  79080. */
  79081. invisible?: boolean;
  79082. /**
  79083. * A source mesh to be used to create instances. Defaults to a sphere.
  79084. * This mesh will be the source for all other (25) meshes.
  79085. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79086. */
  79087. sourceMesh?: Mesh;
  79088. /**
  79089. * Should the source mesh stay visible. Defaults to false
  79090. */
  79091. keepOriginalVisible?: boolean;
  79092. /**
  79093. * Scale factor for all instances (defaults to 2)
  79094. */
  79095. scaleFactor?: number;
  79096. /**
  79097. * Should each instance have its own physics impostor
  79098. */
  79099. enablePhysics?: boolean;
  79100. /**
  79101. * If enabled, override default physics properties
  79102. */
  79103. physicsProps?: {
  79104. friction?: number;
  79105. restitution?: number;
  79106. impostorType?: number;
  79107. };
  79108. /**
  79109. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  79110. */
  79111. handMesh?: AbstractMesh;
  79112. };
  79113. }
  79114. /**
  79115. * Parts of the hands divided to writs and finger names
  79116. */
  79117. export const enum HandPart {
  79118. /**
  79119. * HandPart - Wrist
  79120. */
  79121. WRIST = "wrist",
  79122. /**
  79123. * HandPart - The THumb
  79124. */
  79125. THUMB = "thumb",
  79126. /**
  79127. * HandPart - Index finger
  79128. */
  79129. INDEX = "index",
  79130. /**
  79131. * HandPart - Middle finger
  79132. */
  79133. MIDDLE = "middle",
  79134. /**
  79135. * HandPart - Ring finger
  79136. */
  79137. RING = "ring",
  79138. /**
  79139. * HandPart - Little finger
  79140. */
  79141. LITTLE = "little"
  79142. }
  79143. /**
  79144. * Representing a single hand (with its corresponding native XRHand object)
  79145. */
  79146. export class WebXRHand implements IDisposable {
  79147. /** the controller to which the hand correlates */
  79148. readonly xrController: WebXRInputSource;
  79149. /** the meshes to be used to track the hand joints */
  79150. readonly trackedMeshes: AbstractMesh[];
  79151. /**
  79152. * Hand-parts definition (key is HandPart)
  79153. */
  79154. static HandPartsDefinition: {
  79155. [key: string]: number[];
  79156. };
  79157. /**
  79158. * Populate the HandPartsDefinition object.
  79159. * This is called as a side effect since certain browsers don't have XRHand defined.
  79160. */
  79161. static _PopulateHandPartsDefinition(): void;
  79162. /**
  79163. * Construct a new hand object
  79164. * @param xrController the controller to which the hand correlates
  79165. * @param trackedMeshes the meshes to be used to track the hand joints
  79166. */
  79167. constructor(
  79168. /** the controller to which the hand correlates */
  79169. xrController: WebXRInputSource,
  79170. /** the meshes to be used to track the hand joints */
  79171. trackedMeshes: AbstractMesh[]);
  79172. /**
  79173. * Update this hand from the latest xr frame
  79174. * @param xrFrame xrFrame to update from
  79175. * @param referenceSpace The current viewer reference space
  79176. * @param scaleFactor optional scale factor for the meshes
  79177. */
  79178. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79179. /**
  79180. * Get meshes of part of the hand
  79181. * @param part the part of hand to get
  79182. * @returns An array of meshes that correlate to the hand part requested
  79183. */
  79184. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79185. /**
  79186. * Dispose this Hand object
  79187. */
  79188. dispose(): void;
  79189. }
  79190. /**
  79191. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79192. */
  79193. export class WebXRHandTracking extends WebXRAbstractFeature {
  79194. /**
  79195. * options to use when constructing this feature
  79196. */
  79197. readonly options: IWebXRHandTrackingOptions;
  79198. private static _idCounter;
  79199. /**
  79200. * The module's name
  79201. */
  79202. static readonly Name: string;
  79203. /**
  79204. * The (Babylon) version of this module.
  79205. * This is an integer representing the implementation version.
  79206. * This number does not correspond to the WebXR specs version
  79207. */
  79208. static readonly Version: number;
  79209. /**
  79210. * This observable will notify registered observers when a new hand object was added and initialized
  79211. */
  79212. onHandAddedObservable: Observable<WebXRHand>;
  79213. /**
  79214. * This observable will notify its observers right before the hand object is disposed
  79215. */
  79216. onHandRemovedObservable: Observable<WebXRHand>;
  79217. private _hands;
  79218. /**
  79219. * Creates a new instance of the hit test feature
  79220. * @param _xrSessionManager an instance of WebXRSessionManager
  79221. * @param options options to use when constructing this feature
  79222. */
  79223. constructor(_xrSessionManager: WebXRSessionManager,
  79224. /**
  79225. * options to use when constructing this feature
  79226. */
  79227. options: IWebXRHandTrackingOptions);
  79228. /**
  79229. * Check if the needed objects are defined.
  79230. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79231. */
  79232. isCompatible(): boolean;
  79233. /**
  79234. * attach this feature
  79235. * Will usually be called by the features manager
  79236. *
  79237. * @returns true if successful.
  79238. */
  79239. attach(): boolean;
  79240. /**
  79241. * detach this feature.
  79242. * Will usually be called by the features manager
  79243. *
  79244. * @returns true if successful.
  79245. */
  79246. detach(): boolean;
  79247. /**
  79248. * Dispose this feature and all of the resources attached
  79249. */
  79250. dispose(): void;
  79251. /**
  79252. * Get the hand object according to the controller id
  79253. * @param controllerId the controller id to which we want to get the hand
  79254. * @returns null if not found or the WebXRHand object if found
  79255. */
  79256. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79257. /**
  79258. * Get a hand object according to the requested handedness
  79259. * @param handedness the handedness to request
  79260. * @returns null if not found or the WebXRHand object if found
  79261. */
  79262. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79263. protected _onXRFrame(_xrFrame: XRFrame): void;
  79264. private _attachHand;
  79265. private _detachHand;
  79266. }
  79267. }
  79268. declare module "babylonjs/XR/features/index" {
  79269. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  79270. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  79271. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  79272. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  79273. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  79274. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  79275. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  79276. export * from "babylonjs/XR/features/WebXRHitTest";
  79277. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  79278. export * from "babylonjs/XR/features/WebXRHandTracking";
  79279. }
  79280. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  79281. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79283. import { Scene } from "babylonjs/scene";
  79284. /**
  79285. * The motion controller class for all microsoft mixed reality controllers
  79286. */
  79287. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  79288. protected readonly _mapping: {
  79289. defaultButton: {
  79290. valueNodeName: string;
  79291. unpressedNodeName: string;
  79292. pressedNodeName: string;
  79293. };
  79294. defaultAxis: {
  79295. valueNodeName: string;
  79296. minNodeName: string;
  79297. maxNodeName: string;
  79298. };
  79299. buttons: {
  79300. "xr-standard-trigger": {
  79301. rootNodeName: string;
  79302. componentProperty: string;
  79303. states: string[];
  79304. };
  79305. "xr-standard-squeeze": {
  79306. rootNodeName: string;
  79307. componentProperty: string;
  79308. states: string[];
  79309. };
  79310. "xr-standard-touchpad": {
  79311. rootNodeName: string;
  79312. labelAnchorNodeName: string;
  79313. touchPointNodeName: string;
  79314. };
  79315. "xr-standard-thumbstick": {
  79316. rootNodeName: string;
  79317. componentProperty: string;
  79318. states: string[];
  79319. };
  79320. };
  79321. axes: {
  79322. "xr-standard-touchpad": {
  79323. "x-axis": {
  79324. rootNodeName: string;
  79325. };
  79326. "y-axis": {
  79327. rootNodeName: string;
  79328. };
  79329. };
  79330. "xr-standard-thumbstick": {
  79331. "x-axis": {
  79332. rootNodeName: string;
  79333. };
  79334. "y-axis": {
  79335. rootNodeName: string;
  79336. };
  79337. };
  79338. };
  79339. };
  79340. /**
  79341. * The base url used to load the left and right controller models
  79342. */
  79343. static MODEL_BASE_URL: string;
  79344. /**
  79345. * The name of the left controller model file
  79346. */
  79347. static MODEL_LEFT_FILENAME: string;
  79348. /**
  79349. * The name of the right controller model file
  79350. */
  79351. static MODEL_RIGHT_FILENAME: string;
  79352. profileId: string;
  79353. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79354. protected _getFilenameAndPath(): {
  79355. filename: string;
  79356. path: string;
  79357. };
  79358. protected _getModelLoadingConstraints(): boolean;
  79359. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79360. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79361. protected _updateModel(): void;
  79362. }
  79363. }
  79364. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  79365. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79367. import { Scene } from "babylonjs/scene";
  79368. /**
  79369. * The motion controller class for oculus touch (quest, rift).
  79370. * This class supports legacy mapping as well the standard xr mapping
  79371. */
  79372. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  79373. private _forceLegacyControllers;
  79374. private _modelRootNode;
  79375. /**
  79376. * The base url used to load the left and right controller models
  79377. */
  79378. static MODEL_BASE_URL: string;
  79379. /**
  79380. * The name of the left controller model file
  79381. */
  79382. static MODEL_LEFT_FILENAME: string;
  79383. /**
  79384. * The name of the right controller model file
  79385. */
  79386. static MODEL_RIGHT_FILENAME: string;
  79387. /**
  79388. * Base Url for the Quest controller model.
  79389. */
  79390. static QUEST_MODEL_BASE_URL: string;
  79391. profileId: string;
  79392. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  79393. protected _getFilenameAndPath(): {
  79394. filename: string;
  79395. path: string;
  79396. };
  79397. protected _getModelLoadingConstraints(): boolean;
  79398. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79399. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79400. protected _updateModel(): void;
  79401. /**
  79402. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  79403. * between the touch and touch 2.
  79404. */
  79405. private _isQuest;
  79406. }
  79407. }
  79408. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  79409. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79410. import { Scene } from "babylonjs/scene";
  79411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79412. /**
  79413. * The motion controller class for the standard HTC-Vive controllers
  79414. */
  79415. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  79416. private _modelRootNode;
  79417. /**
  79418. * The base url used to load the left and right controller models
  79419. */
  79420. static MODEL_BASE_URL: string;
  79421. /**
  79422. * File name for the controller model.
  79423. */
  79424. static MODEL_FILENAME: string;
  79425. profileId: string;
  79426. /**
  79427. * Create a new Vive motion controller object
  79428. * @param scene the scene to use to create this controller
  79429. * @param gamepadObject the corresponding gamepad object
  79430. * @param handedness the handedness of the controller
  79431. */
  79432. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79433. protected _getFilenameAndPath(): {
  79434. filename: string;
  79435. path: string;
  79436. };
  79437. protected _getModelLoadingConstraints(): boolean;
  79438. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79439. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79440. protected _updateModel(): void;
  79441. }
  79442. }
  79443. declare module "babylonjs/XR/motionController/index" {
  79444. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79445. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  79446. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  79447. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  79448. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  79449. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  79450. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  79451. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  79452. }
  79453. declare module "babylonjs/XR/index" {
  79454. export * from "babylonjs/XR/webXRCamera";
  79455. export * from "babylonjs/XR/webXREnterExitUI";
  79456. export * from "babylonjs/XR/webXRExperienceHelper";
  79457. export * from "babylonjs/XR/webXRInput";
  79458. export * from "babylonjs/XR/webXRInputSource";
  79459. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  79460. export * from "babylonjs/XR/webXRTypes";
  79461. export * from "babylonjs/XR/webXRSessionManager";
  79462. export * from "babylonjs/XR/webXRDefaultExperience";
  79463. export * from "babylonjs/XR/webXRFeaturesManager";
  79464. export * from "babylonjs/XR/features/index";
  79465. export * from "babylonjs/XR/motionController/index";
  79466. }
  79467. declare module "babylonjs/index" {
  79468. export * from "babylonjs/abstractScene";
  79469. export * from "babylonjs/Actions/index";
  79470. export * from "babylonjs/Animations/index";
  79471. export * from "babylonjs/assetContainer";
  79472. export * from "babylonjs/Audio/index";
  79473. export * from "babylonjs/Behaviors/index";
  79474. export * from "babylonjs/Bones/index";
  79475. export * from "babylonjs/Cameras/index";
  79476. export * from "babylonjs/Collisions/index";
  79477. export * from "babylonjs/Culling/index";
  79478. export * from "babylonjs/Debug/index";
  79479. export * from "babylonjs/DeviceInput/index";
  79480. export * from "babylonjs/Engines/index";
  79481. export * from "babylonjs/Events/index";
  79482. export * from "babylonjs/Gamepads/index";
  79483. export * from "babylonjs/Gizmos/index";
  79484. export * from "babylonjs/Helpers/index";
  79485. export * from "babylonjs/Instrumentation/index";
  79486. export * from "babylonjs/Layers/index";
  79487. export * from "babylonjs/LensFlares/index";
  79488. export * from "babylonjs/Lights/index";
  79489. export * from "babylonjs/Loading/index";
  79490. export * from "babylonjs/Materials/index";
  79491. export * from "babylonjs/Maths/index";
  79492. export * from "babylonjs/Meshes/index";
  79493. export * from "babylonjs/Morph/index";
  79494. export * from "babylonjs/Navigation/index";
  79495. export * from "babylonjs/node";
  79496. export * from "babylonjs/Offline/index";
  79497. export * from "babylonjs/Particles/index";
  79498. export * from "babylonjs/Physics/index";
  79499. export * from "babylonjs/PostProcesses/index";
  79500. export * from "babylonjs/Probes/index";
  79501. export * from "babylonjs/Rendering/index";
  79502. export * from "babylonjs/scene";
  79503. export * from "babylonjs/sceneComponent";
  79504. export * from "babylonjs/Sprites/index";
  79505. export * from "babylonjs/States/index";
  79506. export * from "babylonjs/Misc/index";
  79507. export * from "babylonjs/XR/index";
  79508. export * from "babylonjs/types";
  79509. }
  79510. declare module "babylonjs/Animations/pathCursor" {
  79511. import { Vector3 } from "babylonjs/Maths/math.vector";
  79512. import { Path2 } from "babylonjs/Maths/math.path";
  79513. /**
  79514. * A cursor which tracks a point on a path
  79515. */
  79516. export class PathCursor {
  79517. private path;
  79518. /**
  79519. * Stores path cursor callbacks for when an onchange event is triggered
  79520. */
  79521. private _onchange;
  79522. /**
  79523. * The value of the path cursor
  79524. */
  79525. value: number;
  79526. /**
  79527. * The animation array of the path cursor
  79528. */
  79529. animations: Animation[];
  79530. /**
  79531. * Initializes the path cursor
  79532. * @param path The path to track
  79533. */
  79534. constructor(path: Path2);
  79535. /**
  79536. * Gets the cursor point on the path
  79537. * @returns A point on the path cursor at the cursor location
  79538. */
  79539. getPoint(): Vector3;
  79540. /**
  79541. * Moves the cursor ahead by the step amount
  79542. * @param step The amount to move the cursor forward
  79543. * @returns This path cursor
  79544. */
  79545. moveAhead(step?: number): PathCursor;
  79546. /**
  79547. * Moves the cursor behind by the step amount
  79548. * @param step The amount to move the cursor back
  79549. * @returns This path cursor
  79550. */
  79551. moveBack(step?: number): PathCursor;
  79552. /**
  79553. * Moves the cursor by the step amount
  79554. * If the step amount is greater than one, an exception is thrown
  79555. * @param step The amount to move the cursor
  79556. * @returns This path cursor
  79557. */
  79558. move(step: number): PathCursor;
  79559. /**
  79560. * Ensures that the value is limited between zero and one
  79561. * @returns This path cursor
  79562. */
  79563. private ensureLimits;
  79564. /**
  79565. * Runs onchange callbacks on change (used by the animation engine)
  79566. * @returns This path cursor
  79567. */
  79568. private raiseOnChange;
  79569. /**
  79570. * Executes a function on change
  79571. * @param f A path cursor onchange callback
  79572. * @returns This path cursor
  79573. */
  79574. onchange(f: (cursor: PathCursor) => void): PathCursor;
  79575. }
  79576. }
  79577. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  79578. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  79579. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  79580. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  79581. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  79582. }
  79583. declare module "babylonjs/Engines/Processors/Expressions/index" {
  79584. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  79585. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  79586. }
  79587. declare module "babylonjs/Engines/Processors/index" {
  79588. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  79589. export * from "babylonjs/Engines/Processors/Expressions/index";
  79590. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  79591. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  79592. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  79593. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  79594. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  79595. export * from "babylonjs/Engines/Processors/shaderProcessor";
  79596. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  79597. }
  79598. declare module "babylonjs/Legacy/legacy" {
  79599. import * as Babylon from "babylonjs/index";
  79600. export * from "babylonjs/index";
  79601. }
  79602. declare module "babylonjs/Shaders/blur.fragment" {
  79603. /** @hidden */
  79604. export var blurPixelShader: {
  79605. name: string;
  79606. shader: string;
  79607. };
  79608. }
  79609. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  79610. /** @hidden */
  79611. export var pointCloudVertexDeclaration: {
  79612. name: string;
  79613. shader: string;
  79614. };
  79615. }
  79616. declare module "babylonjs" {
  79617. export * from "babylonjs/Legacy/legacy";
  79618. }
  79619. declare module BABYLON {
  79620. /** Alias type for value that can be null */
  79621. export type Nullable<T> = T | null;
  79622. /**
  79623. * Alias type for number that are floats
  79624. * @ignorenaming
  79625. */
  79626. export type float = number;
  79627. /**
  79628. * Alias type for number that are doubles.
  79629. * @ignorenaming
  79630. */
  79631. export type double = number;
  79632. /**
  79633. * Alias type for number that are integer
  79634. * @ignorenaming
  79635. */
  79636. export type int = number;
  79637. /** Alias type for number array or Float32Array */
  79638. export type FloatArray = number[] | Float32Array;
  79639. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  79640. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  79641. /**
  79642. * Alias for types that can be used by a Buffer or VertexBuffer.
  79643. */
  79644. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  79645. /**
  79646. * Alias type for primitive types
  79647. * @ignorenaming
  79648. */
  79649. type Primitive = undefined | null | boolean | string | number | Function;
  79650. /**
  79651. * Type modifier to make all the properties of an object Readonly
  79652. */
  79653. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  79654. /**
  79655. * Type modifier to make all the properties of an object Readonly recursively
  79656. */
  79657. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  79658. /**
  79659. * Type modifier to make object properties readonly.
  79660. */
  79661. export type DeepImmutableObject<T> = {
  79662. readonly [K in keyof T]: DeepImmutable<T[K]>;
  79663. };
  79664. /** @hidden */
  79665. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  79666. }
  79667. }
  79668. declare module BABYLON {
  79669. /**
  79670. * A class serves as a medium between the observable and its observers
  79671. */
  79672. export class EventState {
  79673. /**
  79674. * Create a new EventState
  79675. * @param mask defines the mask associated with this state
  79676. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79677. * @param target defines the original target of the state
  79678. * @param currentTarget defines the current target of the state
  79679. */
  79680. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  79681. /**
  79682. * Initialize the current event state
  79683. * @param mask defines the mask associated with this state
  79684. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79685. * @param target defines the original target of the state
  79686. * @param currentTarget defines the current target of the state
  79687. * @returns the current event state
  79688. */
  79689. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  79690. /**
  79691. * An Observer can set this property to true to prevent subsequent observers of being notified
  79692. */
  79693. skipNextObservers: boolean;
  79694. /**
  79695. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79696. */
  79697. mask: number;
  79698. /**
  79699. * The object that originally notified the event
  79700. */
  79701. target?: any;
  79702. /**
  79703. * The current object in the bubbling phase
  79704. */
  79705. currentTarget?: any;
  79706. /**
  79707. * This will be populated with the return value of the last function that was executed.
  79708. * If it is the first function in the callback chain it will be the event data.
  79709. */
  79710. lastReturnValue?: any;
  79711. }
  79712. /**
  79713. * Represent an Observer registered to a given Observable object.
  79714. */
  79715. export class Observer<T> {
  79716. /**
  79717. * Defines the callback to call when the observer is notified
  79718. */
  79719. callback: (eventData: T, eventState: EventState) => void;
  79720. /**
  79721. * Defines the mask of the observer (used to filter notifications)
  79722. */
  79723. mask: number;
  79724. /**
  79725. * Defines the current scope used to restore the JS context
  79726. */
  79727. scope: any;
  79728. /** @hidden */
  79729. _willBeUnregistered: boolean;
  79730. /**
  79731. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  79732. */
  79733. unregisterOnNextCall: boolean;
  79734. /**
  79735. * Creates a new observer
  79736. * @param callback defines the callback to call when the observer is notified
  79737. * @param mask defines the mask of the observer (used to filter notifications)
  79738. * @param scope defines the current scope used to restore the JS context
  79739. */
  79740. constructor(
  79741. /**
  79742. * Defines the callback to call when the observer is notified
  79743. */
  79744. callback: (eventData: T, eventState: EventState) => void,
  79745. /**
  79746. * Defines the mask of the observer (used to filter notifications)
  79747. */
  79748. mask: number,
  79749. /**
  79750. * Defines the current scope used to restore the JS context
  79751. */
  79752. scope?: any);
  79753. }
  79754. /**
  79755. * Represent a list of observers registered to multiple Observables object.
  79756. */
  79757. export class MultiObserver<T> {
  79758. private _observers;
  79759. private _observables;
  79760. /**
  79761. * Release associated resources
  79762. */
  79763. dispose(): void;
  79764. /**
  79765. * Raise a callback when one of the observable will notify
  79766. * @param observables defines a list of observables to watch
  79767. * @param callback defines the callback to call on notification
  79768. * @param mask defines the mask used to filter notifications
  79769. * @param scope defines the current scope used to restore the JS context
  79770. * @returns the new MultiObserver
  79771. */
  79772. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  79773. }
  79774. /**
  79775. * The Observable class is a simple implementation of the Observable pattern.
  79776. *
  79777. * 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.
  79778. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  79779. * 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).
  79780. * 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.
  79781. */
  79782. export class Observable<T> {
  79783. private _observers;
  79784. private _eventState;
  79785. private _onObserverAdded;
  79786. /**
  79787. * Gets the list of observers
  79788. */
  79789. get observers(): Array<Observer<T>>;
  79790. /**
  79791. * Creates a new observable
  79792. * @param onObserverAdded defines a callback to call when a new observer is added
  79793. */
  79794. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  79795. /**
  79796. * Create a new Observer with the specified callback
  79797. * @param callback the callback that will be executed for that Observer
  79798. * @param mask the mask used to filter observers
  79799. * @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.
  79800. * @param scope optional scope for the callback to be called from
  79801. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  79802. * @returns the new observer created for the callback
  79803. */
  79804. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  79805. /**
  79806. * Create a new Observer with the specified callback and unregisters after the next notification
  79807. * @param callback the callback that will be executed for that Observer
  79808. * @returns the new observer created for the callback
  79809. */
  79810. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  79811. /**
  79812. * Remove an Observer from the Observable object
  79813. * @param observer the instance of the Observer to remove
  79814. * @returns false if it doesn't belong to this Observable
  79815. */
  79816. remove(observer: Nullable<Observer<T>>): boolean;
  79817. /**
  79818. * Remove a callback from the Observable object
  79819. * @param callback the callback to remove
  79820. * @param scope optional scope. If used only the callbacks with this scope will be removed
  79821. * @returns false if it doesn't belong to this Observable
  79822. */
  79823. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  79824. private _deferUnregister;
  79825. private _remove;
  79826. /**
  79827. * Moves the observable to the top of the observer list making it get called first when notified
  79828. * @param observer the observer to move
  79829. */
  79830. makeObserverTopPriority(observer: Observer<T>): void;
  79831. /**
  79832. * Moves the observable to the bottom of the observer list making it get called last when notified
  79833. * @param observer the observer to move
  79834. */
  79835. makeObserverBottomPriority(observer: Observer<T>): void;
  79836. /**
  79837. * Notify all Observers by calling their respective callback with the given data
  79838. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  79839. * @param eventData defines the data to send to all observers
  79840. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  79841. * @param target defines the original target of the state
  79842. * @param currentTarget defines the current target of the state
  79843. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  79844. */
  79845. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  79846. /**
  79847. * Calling this will execute each callback, expecting it to be a promise or return a value.
  79848. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  79849. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  79850. * and it is crucial that all callbacks will be executed.
  79851. * The order of the callbacks is kept, callbacks are not executed parallel.
  79852. *
  79853. * @param eventData The data to be sent to each callback
  79854. * @param mask is used to filter observers defaults to -1
  79855. * @param target defines the callback target (see EventState)
  79856. * @param currentTarget defines he current object in the bubbling phase
  79857. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  79858. */
  79859. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  79860. /**
  79861. * Notify a specific observer
  79862. * @param observer defines the observer to notify
  79863. * @param eventData defines the data to be sent to each callback
  79864. * @param mask is used to filter observers defaults to -1
  79865. */
  79866. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  79867. /**
  79868. * Gets a boolean indicating if the observable has at least one observer
  79869. * @returns true is the Observable has at least one Observer registered
  79870. */
  79871. hasObservers(): boolean;
  79872. /**
  79873. * Clear the list of observers
  79874. */
  79875. clear(): void;
  79876. /**
  79877. * Clone the current observable
  79878. * @returns a new observable
  79879. */
  79880. clone(): Observable<T>;
  79881. /**
  79882. * Does this observable handles observer registered with a given mask
  79883. * @param mask defines the mask to be tested
  79884. * @return whether or not one observer registered with the given mask is handeled
  79885. **/
  79886. hasSpecificMask(mask?: number): boolean;
  79887. }
  79888. }
  79889. declare module BABYLON {
  79890. /**
  79891. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  79892. * Babylon.js
  79893. */
  79894. export class DomManagement {
  79895. /**
  79896. * Checks if the window object exists
  79897. * @returns true if the window object exists
  79898. */
  79899. static IsWindowObjectExist(): boolean;
  79900. /**
  79901. * Checks if the navigator object exists
  79902. * @returns true if the navigator object exists
  79903. */
  79904. static IsNavigatorAvailable(): boolean;
  79905. /**
  79906. * Check if the document object exists
  79907. * @returns true if the document object exists
  79908. */
  79909. static IsDocumentAvailable(): boolean;
  79910. /**
  79911. * Extracts text content from a DOM element hierarchy
  79912. * @param element defines the root element
  79913. * @returns a string
  79914. */
  79915. static GetDOMTextContent(element: HTMLElement): string;
  79916. }
  79917. }
  79918. declare module BABYLON {
  79919. /**
  79920. * Logger used througouht the application to allow configuration of
  79921. * the log level required for the messages.
  79922. */
  79923. export class Logger {
  79924. /**
  79925. * No log
  79926. */
  79927. static readonly NoneLogLevel: number;
  79928. /**
  79929. * Only message logs
  79930. */
  79931. static readonly MessageLogLevel: number;
  79932. /**
  79933. * Only warning logs
  79934. */
  79935. static readonly WarningLogLevel: number;
  79936. /**
  79937. * Only error logs
  79938. */
  79939. static readonly ErrorLogLevel: number;
  79940. /**
  79941. * All logs
  79942. */
  79943. static readonly AllLogLevel: number;
  79944. private static _LogCache;
  79945. /**
  79946. * Gets a value indicating the number of loading errors
  79947. * @ignorenaming
  79948. */
  79949. static errorsCount: number;
  79950. /**
  79951. * Callback called when a new log is added
  79952. */
  79953. static OnNewCacheEntry: (entry: string) => void;
  79954. private static _AddLogEntry;
  79955. private static _FormatMessage;
  79956. private static _LogDisabled;
  79957. private static _LogEnabled;
  79958. private static _WarnDisabled;
  79959. private static _WarnEnabled;
  79960. private static _ErrorDisabled;
  79961. private static _ErrorEnabled;
  79962. /**
  79963. * Log a message to the console
  79964. */
  79965. static Log: (message: string) => void;
  79966. /**
  79967. * Write a warning message to the console
  79968. */
  79969. static Warn: (message: string) => void;
  79970. /**
  79971. * Write an error message to the console
  79972. */
  79973. static Error: (message: string) => void;
  79974. /**
  79975. * Gets current log cache (list of logs)
  79976. */
  79977. static get LogCache(): string;
  79978. /**
  79979. * Clears the log cache
  79980. */
  79981. static ClearLogCache(): void;
  79982. /**
  79983. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  79984. */
  79985. static set LogLevels(level: number);
  79986. }
  79987. }
  79988. declare module BABYLON {
  79989. /** @hidden */
  79990. export class _TypeStore {
  79991. /** @hidden */
  79992. static RegisteredTypes: {
  79993. [key: string]: Object;
  79994. };
  79995. /** @hidden */
  79996. static GetClass(fqdn: string): any;
  79997. }
  79998. }
  79999. declare module BABYLON {
  80000. /**
  80001. * Helper to manipulate strings
  80002. */
  80003. export class StringTools {
  80004. /**
  80005. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  80006. * @param str Source string
  80007. * @param suffix Suffix to search for in the source string
  80008. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80009. */
  80010. static EndsWith(str: string, suffix: string): boolean;
  80011. /**
  80012. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  80013. * @param str Source string
  80014. * @param suffix Suffix to search for in the source string
  80015. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80016. */
  80017. static StartsWith(str: string, suffix: string): boolean;
  80018. /**
  80019. * Decodes a buffer into a string
  80020. * @param buffer The buffer to decode
  80021. * @returns The decoded string
  80022. */
  80023. static Decode(buffer: Uint8Array | Uint16Array): string;
  80024. /**
  80025. * Encode a buffer to a base64 string
  80026. * @param buffer defines the buffer to encode
  80027. * @returns the encoded string
  80028. */
  80029. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  80030. /**
  80031. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  80032. * @param num the number to convert and pad
  80033. * @param length the expected length of the string
  80034. * @returns the padded string
  80035. */
  80036. static PadNumber(num: number, length: number): string;
  80037. }
  80038. }
  80039. declare module BABYLON {
  80040. /**
  80041. * Class containing a set of static utilities functions for deep copy.
  80042. */
  80043. export class DeepCopier {
  80044. /**
  80045. * Tries to copy an object by duplicating every property
  80046. * @param source defines the source object
  80047. * @param destination defines the target object
  80048. * @param doNotCopyList defines a list of properties to avoid
  80049. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  80050. */
  80051. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  80052. }
  80053. }
  80054. declare module BABYLON {
  80055. /**
  80056. * Class containing a set of static utilities functions for precision date
  80057. */
  80058. export class PrecisionDate {
  80059. /**
  80060. * Gets either window.performance.now() if supported or Date.now() else
  80061. */
  80062. static get Now(): number;
  80063. }
  80064. }
  80065. declare module BABYLON {
  80066. /** @hidden */
  80067. export class _DevTools {
  80068. static WarnImport(name: string): string;
  80069. }
  80070. }
  80071. declare module BABYLON {
  80072. /**
  80073. * Interface used to define the mechanism to get data from the network
  80074. */
  80075. export interface IWebRequest {
  80076. /**
  80077. * Returns client's response url
  80078. */
  80079. responseURL: string;
  80080. /**
  80081. * Returns client's status
  80082. */
  80083. status: number;
  80084. /**
  80085. * Returns client's status as a text
  80086. */
  80087. statusText: string;
  80088. }
  80089. }
  80090. declare module BABYLON {
  80091. /**
  80092. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  80093. */
  80094. export class WebRequest implements IWebRequest {
  80095. private _xhr;
  80096. /**
  80097. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  80098. * i.e. when loading files, where the server/service expects an Authorization header
  80099. */
  80100. static CustomRequestHeaders: {
  80101. [key: string]: string;
  80102. };
  80103. /**
  80104. * Add callback functions in this array to update all the requests before they get sent to the network
  80105. */
  80106. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  80107. private _injectCustomRequestHeaders;
  80108. /**
  80109. * Gets or sets a function to be called when loading progress changes
  80110. */
  80111. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  80112. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  80113. /**
  80114. * Returns client's state
  80115. */
  80116. get readyState(): number;
  80117. /**
  80118. * Returns client's status
  80119. */
  80120. get status(): number;
  80121. /**
  80122. * Returns client's status as a text
  80123. */
  80124. get statusText(): string;
  80125. /**
  80126. * Returns client's response
  80127. */
  80128. get response(): any;
  80129. /**
  80130. * Returns client's response url
  80131. */
  80132. get responseURL(): string;
  80133. /**
  80134. * Returns client's response as text
  80135. */
  80136. get responseText(): string;
  80137. /**
  80138. * Gets or sets the expected response type
  80139. */
  80140. get responseType(): XMLHttpRequestResponseType;
  80141. set responseType(value: XMLHttpRequestResponseType);
  80142. /** @hidden */
  80143. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  80144. /** @hidden */
  80145. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  80146. /**
  80147. * Cancels any network activity
  80148. */
  80149. abort(): void;
  80150. /**
  80151. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  80152. * @param body defines an optional request body
  80153. */
  80154. send(body?: Document | BodyInit | null): void;
  80155. /**
  80156. * Sets the request method, request URL
  80157. * @param method defines the method to use (GET, POST, etc..)
  80158. * @param url defines the url to connect with
  80159. */
  80160. open(method: string, url: string): void;
  80161. /**
  80162. * Sets the value of a request header.
  80163. * @param name The name of the header whose value is to be set
  80164. * @param value The value to set as the body of the header
  80165. */
  80166. setRequestHeader(name: string, value: string): void;
  80167. /**
  80168. * Get the string containing the text of a particular header's value.
  80169. * @param name The name of the header
  80170. * @returns The string containing the text of the given header name
  80171. */
  80172. getResponseHeader(name: string): Nullable<string>;
  80173. }
  80174. }
  80175. declare module BABYLON {
  80176. /**
  80177. * File request interface
  80178. */
  80179. export interface IFileRequest {
  80180. /**
  80181. * Raised when the request is complete (success or error).
  80182. */
  80183. onCompleteObservable: Observable<IFileRequest>;
  80184. /**
  80185. * Aborts the request for a file.
  80186. */
  80187. abort: () => void;
  80188. }
  80189. }
  80190. declare module BABYLON {
  80191. /**
  80192. * Define options used to create a render target texture
  80193. */
  80194. export class RenderTargetCreationOptions {
  80195. /**
  80196. * Specifies is mipmaps must be generated
  80197. */
  80198. generateMipMaps?: boolean;
  80199. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  80200. generateDepthBuffer?: boolean;
  80201. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  80202. generateStencilBuffer?: boolean;
  80203. /** Defines texture type (int by default) */
  80204. type?: number;
  80205. /** Defines sampling mode (trilinear by default) */
  80206. samplingMode?: number;
  80207. /** Defines format (RGBA by default) */
  80208. format?: number;
  80209. }
  80210. }
  80211. declare module BABYLON {
  80212. /** Defines the cross module used constants to avoid circular dependncies */
  80213. export class Constants {
  80214. /** Defines that alpha blending is disabled */
  80215. static readonly ALPHA_DISABLE: number;
  80216. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  80217. static readonly ALPHA_ADD: number;
  80218. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  80219. static readonly ALPHA_COMBINE: number;
  80220. /** Defines that alpha blending is DEST - SRC * DEST */
  80221. static readonly ALPHA_SUBTRACT: number;
  80222. /** Defines that alpha blending is SRC * DEST */
  80223. static readonly ALPHA_MULTIPLY: number;
  80224. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  80225. static readonly ALPHA_MAXIMIZED: number;
  80226. /** Defines that alpha blending is SRC + DEST */
  80227. static readonly ALPHA_ONEONE: number;
  80228. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  80229. static readonly ALPHA_PREMULTIPLIED: number;
  80230. /**
  80231. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  80232. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  80233. */
  80234. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  80235. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  80236. static readonly ALPHA_INTERPOLATE: number;
  80237. /**
  80238. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  80239. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  80240. */
  80241. static readonly ALPHA_SCREENMODE: number;
  80242. /**
  80243. * Defines that alpha blending is SRC + DST
  80244. * Alpha will be set to SRC ALPHA + DST ALPHA
  80245. */
  80246. static readonly ALPHA_ONEONE_ONEONE: number;
  80247. /**
  80248. * Defines that alpha blending is SRC * DST ALPHA + DST
  80249. * Alpha will be set to 0
  80250. */
  80251. static readonly ALPHA_ALPHATOCOLOR: number;
  80252. /**
  80253. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80254. */
  80255. static readonly ALPHA_REVERSEONEMINUS: number;
  80256. /**
  80257. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  80258. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  80259. */
  80260. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  80261. /**
  80262. * Defines that alpha blending is SRC + DST
  80263. * Alpha will be set to SRC ALPHA
  80264. */
  80265. static readonly ALPHA_ONEONE_ONEZERO: number;
  80266. /**
  80267. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80268. * Alpha will be set to DST ALPHA
  80269. */
  80270. static readonly ALPHA_EXCLUSION: number;
  80271. /** Defines that alpha blending equation a SUM */
  80272. static readonly ALPHA_EQUATION_ADD: number;
  80273. /** Defines that alpha blending equation a SUBSTRACTION */
  80274. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  80275. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  80276. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  80277. /** Defines that alpha blending equation a MAX operation */
  80278. static readonly ALPHA_EQUATION_MAX: number;
  80279. /** Defines that alpha blending equation a MIN operation */
  80280. static readonly ALPHA_EQUATION_MIN: number;
  80281. /**
  80282. * Defines that alpha blending equation a DARKEN operation:
  80283. * It takes the min of the src and sums the alpha channels.
  80284. */
  80285. static readonly ALPHA_EQUATION_DARKEN: number;
  80286. /** Defines that the ressource is not delayed*/
  80287. static readonly DELAYLOADSTATE_NONE: number;
  80288. /** Defines that the ressource was successfully delay loaded */
  80289. static readonly DELAYLOADSTATE_LOADED: number;
  80290. /** Defines that the ressource is currently delay loading */
  80291. static readonly DELAYLOADSTATE_LOADING: number;
  80292. /** Defines that the ressource is delayed and has not started loading */
  80293. static readonly DELAYLOADSTATE_NOTLOADED: number;
  80294. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  80295. static readonly NEVER: number;
  80296. /** 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 */
  80297. static readonly ALWAYS: number;
  80298. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  80299. static readonly LESS: number;
  80300. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  80301. static readonly EQUAL: number;
  80302. /** 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 */
  80303. static readonly LEQUAL: number;
  80304. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  80305. static readonly GREATER: number;
  80306. /** 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 */
  80307. static readonly GEQUAL: number;
  80308. /** 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 */
  80309. static readonly NOTEQUAL: number;
  80310. /** Passed to stencilOperation to specify that stencil value must be kept */
  80311. static readonly KEEP: number;
  80312. /** Passed to stencilOperation to specify that stencil value must be replaced */
  80313. static readonly REPLACE: number;
  80314. /** Passed to stencilOperation to specify that stencil value must be incremented */
  80315. static readonly INCR: number;
  80316. /** Passed to stencilOperation to specify that stencil value must be decremented */
  80317. static readonly DECR: number;
  80318. /** Passed to stencilOperation to specify that stencil value must be inverted */
  80319. static readonly INVERT: number;
  80320. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  80321. static readonly INCR_WRAP: number;
  80322. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  80323. static readonly DECR_WRAP: number;
  80324. /** Texture is not repeating outside of 0..1 UVs */
  80325. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  80326. /** Texture is repeating outside of 0..1 UVs */
  80327. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  80328. /** Texture is repeating and mirrored */
  80329. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  80330. /** ALPHA */
  80331. static readonly TEXTUREFORMAT_ALPHA: number;
  80332. /** LUMINANCE */
  80333. static readonly TEXTUREFORMAT_LUMINANCE: number;
  80334. /** LUMINANCE_ALPHA */
  80335. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  80336. /** RGB */
  80337. static readonly TEXTUREFORMAT_RGB: number;
  80338. /** RGBA */
  80339. static readonly TEXTUREFORMAT_RGBA: number;
  80340. /** RED */
  80341. static readonly TEXTUREFORMAT_RED: number;
  80342. /** RED (2nd reference) */
  80343. static readonly TEXTUREFORMAT_R: number;
  80344. /** RG */
  80345. static readonly TEXTUREFORMAT_RG: number;
  80346. /** RED_INTEGER */
  80347. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  80348. /** RED_INTEGER (2nd reference) */
  80349. static readonly TEXTUREFORMAT_R_INTEGER: number;
  80350. /** RG_INTEGER */
  80351. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  80352. /** RGB_INTEGER */
  80353. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  80354. /** RGBA_INTEGER */
  80355. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  80356. /** UNSIGNED_BYTE */
  80357. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  80358. /** UNSIGNED_BYTE (2nd reference) */
  80359. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  80360. /** FLOAT */
  80361. static readonly TEXTURETYPE_FLOAT: number;
  80362. /** HALF_FLOAT */
  80363. static readonly TEXTURETYPE_HALF_FLOAT: number;
  80364. /** BYTE */
  80365. static readonly TEXTURETYPE_BYTE: number;
  80366. /** SHORT */
  80367. static readonly TEXTURETYPE_SHORT: number;
  80368. /** UNSIGNED_SHORT */
  80369. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  80370. /** INT */
  80371. static readonly TEXTURETYPE_INT: number;
  80372. /** UNSIGNED_INT */
  80373. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  80374. /** UNSIGNED_SHORT_4_4_4_4 */
  80375. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  80376. /** UNSIGNED_SHORT_5_5_5_1 */
  80377. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  80378. /** UNSIGNED_SHORT_5_6_5 */
  80379. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  80380. /** UNSIGNED_INT_2_10_10_10_REV */
  80381. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  80382. /** UNSIGNED_INT_24_8 */
  80383. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  80384. /** UNSIGNED_INT_10F_11F_11F_REV */
  80385. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  80386. /** UNSIGNED_INT_5_9_9_9_REV */
  80387. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  80388. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  80389. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80390. /** nearest is mag = nearest and min = nearest and no mip */
  80391. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  80392. /** mag = nearest and min = nearest and mip = none */
  80393. static readonly TEXTURE_NEAREST_NEAREST: number;
  80394. /** Bilinear is mag = linear and min = linear and no mip */
  80395. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  80396. /** mag = linear and min = linear and mip = none */
  80397. static readonly TEXTURE_LINEAR_LINEAR: number;
  80398. /** Trilinear is mag = linear and min = linear and mip = linear */
  80399. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  80400. /** Trilinear is mag = linear and min = linear and mip = linear */
  80401. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  80402. /** mag = nearest and min = nearest and mip = nearest */
  80403. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  80404. /** mag = nearest and min = linear and mip = nearest */
  80405. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  80406. /** mag = nearest and min = linear and mip = linear */
  80407. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  80408. /** mag = nearest and min = linear and mip = none */
  80409. static readonly TEXTURE_NEAREST_LINEAR: number;
  80410. /** nearest is mag = nearest and min = nearest and mip = linear */
  80411. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  80412. /** mag = linear and min = nearest and mip = nearest */
  80413. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  80414. /** mag = linear and min = nearest and mip = linear */
  80415. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  80416. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80417. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  80418. /** mag = linear and min = nearest and mip = none */
  80419. static readonly TEXTURE_LINEAR_NEAREST: number;
  80420. /** Explicit coordinates mode */
  80421. static readonly TEXTURE_EXPLICIT_MODE: number;
  80422. /** Spherical coordinates mode */
  80423. static readonly TEXTURE_SPHERICAL_MODE: number;
  80424. /** Planar coordinates mode */
  80425. static readonly TEXTURE_PLANAR_MODE: number;
  80426. /** Cubic coordinates mode */
  80427. static readonly TEXTURE_CUBIC_MODE: number;
  80428. /** Projection coordinates mode */
  80429. static readonly TEXTURE_PROJECTION_MODE: number;
  80430. /** Skybox coordinates mode */
  80431. static readonly TEXTURE_SKYBOX_MODE: number;
  80432. /** Inverse Cubic coordinates mode */
  80433. static readonly TEXTURE_INVCUBIC_MODE: number;
  80434. /** Equirectangular coordinates mode */
  80435. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  80436. /** Equirectangular Fixed coordinates mode */
  80437. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  80438. /** Equirectangular Fixed Mirrored coordinates mode */
  80439. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80440. /** Offline (baking) quality for texture filtering */
  80441. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  80442. /** High quality for texture filtering */
  80443. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  80444. /** Medium quality for texture filtering */
  80445. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  80446. /** Low quality for texture filtering */
  80447. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  80448. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  80449. static readonly SCALEMODE_FLOOR: number;
  80450. /** Defines that texture rescaling will look for the nearest power of 2 size */
  80451. static readonly SCALEMODE_NEAREST: number;
  80452. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  80453. static readonly SCALEMODE_CEILING: number;
  80454. /**
  80455. * The dirty texture flag value
  80456. */
  80457. static readonly MATERIAL_TextureDirtyFlag: number;
  80458. /**
  80459. * The dirty light flag value
  80460. */
  80461. static readonly MATERIAL_LightDirtyFlag: number;
  80462. /**
  80463. * The dirty fresnel flag value
  80464. */
  80465. static readonly MATERIAL_FresnelDirtyFlag: number;
  80466. /**
  80467. * The dirty attribute flag value
  80468. */
  80469. static readonly MATERIAL_AttributesDirtyFlag: number;
  80470. /**
  80471. * The dirty misc flag value
  80472. */
  80473. static readonly MATERIAL_MiscDirtyFlag: number;
  80474. /**
  80475. * The all dirty flag value
  80476. */
  80477. static readonly MATERIAL_AllDirtyFlag: number;
  80478. /**
  80479. * Returns the triangle fill mode
  80480. */
  80481. static readonly MATERIAL_TriangleFillMode: number;
  80482. /**
  80483. * Returns the wireframe mode
  80484. */
  80485. static readonly MATERIAL_WireFrameFillMode: number;
  80486. /**
  80487. * Returns the point fill mode
  80488. */
  80489. static readonly MATERIAL_PointFillMode: number;
  80490. /**
  80491. * Returns the point list draw mode
  80492. */
  80493. static readonly MATERIAL_PointListDrawMode: number;
  80494. /**
  80495. * Returns the line list draw mode
  80496. */
  80497. static readonly MATERIAL_LineListDrawMode: number;
  80498. /**
  80499. * Returns the line loop draw mode
  80500. */
  80501. static readonly MATERIAL_LineLoopDrawMode: number;
  80502. /**
  80503. * Returns the line strip draw mode
  80504. */
  80505. static readonly MATERIAL_LineStripDrawMode: number;
  80506. /**
  80507. * Returns the triangle strip draw mode
  80508. */
  80509. static readonly MATERIAL_TriangleStripDrawMode: number;
  80510. /**
  80511. * Returns the triangle fan draw mode
  80512. */
  80513. static readonly MATERIAL_TriangleFanDrawMode: number;
  80514. /**
  80515. * Stores the clock-wise side orientation
  80516. */
  80517. static readonly MATERIAL_ClockWiseSideOrientation: number;
  80518. /**
  80519. * Stores the counter clock-wise side orientation
  80520. */
  80521. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  80522. /**
  80523. * Nothing
  80524. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80525. */
  80526. static readonly ACTION_NothingTrigger: number;
  80527. /**
  80528. * On pick
  80529. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80530. */
  80531. static readonly ACTION_OnPickTrigger: number;
  80532. /**
  80533. * On left pick
  80534. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80535. */
  80536. static readonly ACTION_OnLeftPickTrigger: number;
  80537. /**
  80538. * On right pick
  80539. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80540. */
  80541. static readonly ACTION_OnRightPickTrigger: number;
  80542. /**
  80543. * On center pick
  80544. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80545. */
  80546. static readonly ACTION_OnCenterPickTrigger: number;
  80547. /**
  80548. * On pick down
  80549. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80550. */
  80551. static readonly ACTION_OnPickDownTrigger: number;
  80552. /**
  80553. * On double pick
  80554. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80555. */
  80556. static readonly ACTION_OnDoublePickTrigger: number;
  80557. /**
  80558. * On pick up
  80559. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80560. */
  80561. static readonly ACTION_OnPickUpTrigger: number;
  80562. /**
  80563. * On pick out.
  80564. * This trigger will only be raised if you also declared a OnPickDown
  80565. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80566. */
  80567. static readonly ACTION_OnPickOutTrigger: number;
  80568. /**
  80569. * On long press
  80570. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80571. */
  80572. static readonly ACTION_OnLongPressTrigger: number;
  80573. /**
  80574. * On pointer over
  80575. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80576. */
  80577. static readonly ACTION_OnPointerOverTrigger: number;
  80578. /**
  80579. * On pointer out
  80580. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80581. */
  80582. static readonly ACTION_OnPointerOutTrigger: number;
  80583. /**
  80584. * On every frame
  80585. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80586. */
  80587. static readonly ACTION_OnEveryFrameTrigger: number;
  80588. /**
  80589. * On intersection enter
  80590. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80591. */
  80592. static readonly ACTION_OnIntersectionEnterTrigger: number;
  80593. /**
  80594. * On intersection exit
  80595. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80596. */
  80597. static readonly ACTION_OnIntersectionExitTrigger: number;
  80598. /**
  80599. * On key down
  80600. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80601. */
  80602. static readonly ACTION_OnKeyDownTrigger: number;
  80603. /**
  80604. * On key up
  80605. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80606. */
  80607. static readonly ACTION_OnKeyUpTrigger: number;
  80608. /**
  80609. * Billboard mode will only apply to Y axis
  80610. */
  80611. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  80612. /**
  80613. * Billboard mode will apply to all axes
  80614. */
  80615. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  80616. /**
  80617. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  80618. */
  80619. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  80620. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80621. * Test order :
  80622. * Is the bounding sphere outside the frustum ?
  80623. * If not, are the bounding box vertices outside the frustum ?
  80624. * It not, then the cullable object is in the frustum.
  80625. */
  80626. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  80627. /** Culling strategy : Bounding Sphere Only.
  80628. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80629. * It's also less accurate than the standard because some not visible objects can still be selected.
  80630. * Test : is the bounding sphere outside the frustum ?
  80631. * If not, then the cullable object is in the frustum.
  80632. */
  80633. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80634. /** Culling strategy : Optimistic Inclusion.
  80635. * This in an inclusion test first, then the standard exclusion test.
  80636. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80637. * 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.
  80638. * Anyway, it's as accurate as the standard strategy.
  80639. * Test :
  80640. * Is the cullable object bounding sphere center in the frustum ?
  80641. * If not, apply the default culling strategy.
  80642. */
  80643. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80644. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80645. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80646. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80647. * 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.
  80648. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80649. * Test :
  80650. * Is the cullable object bounding sphere center in the frustum ?
  80651. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80652. */
  80653. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80654. /**
  80655. * No logging while loading
  80656. */
  80657. static readonly SCENELOADER_NO_LOGGING: number;
  80658. /**
  80659. * Minimal logging while loading
  80660. */
  80661. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  80662. /**
  80663. * Summary logging while loading
  80664. */
  80665. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  80666. /**
  80667. * Detailled logging while loading
  80668. */
  80669. static readonly SCENELOADER_DETAILED_LOGGING: number;
  80670. /**
  80671. * Prepass texture index for color
  80672. */
  80673. static readonly PREPASS_COLOR_INDEX: number;
  80674. /**
  80675. * Prepass texture index for irradiance
  80676. */
  80677. static readonly PREPASS_IRRADIANCE_INDEX: number;
  80678. /**
  80679. * Prepass texture index for depth + normal
  80680. */
  80681. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  80682. /**
  80683. * Prepass texture index for albedo
  80684. */
  80685. static readonly PREPASS_ALBEDO_INDEX: number;
  80686. }
  80687. }
  80688. declare module BABYLON {
  80689. /**
  80690. * This represents the required contract to create a new type of texture loader.
  80691. */
  80692. export interface IInternalTextureLoader {
  80693. /**
  80694. * Defines wether the loader supports cascade loading the different faces.
  80695. */
  80696. supportCascades: boolean;
  80697. /**
  80698. * This returns if the loader support the current file information.
  80699. * @param extension defines the file extension of the file being loaded
  80700. * @param mimeType defines the optional mime type of the file being loaded
  80701. * @returns true if the loader can load the specified file
  80702. */
  80703. canLoad(extension: string, mimeType?: string): boolean;
  80704. /**
  80705. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  80706. * @param data contains the texture data
  80707. * @param texture defines the BabylonJS internal texture
  80708. * @param createPolynomials will be true if polynomials have been requested
  80709. * @param onLoad defines the callback to trigger once the texture is ready
  80710. * @param onError defines the callback to trigger in case of error
  80711. */
  80712. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  80713. /**
  80714. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  80715. * @param data contains the texture data
  80716. * @param texture defines the BabylonJS internal texture
  80717. * @param callback defines the method to call once ready to upload
  80718. */
  80719. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  80720. }
  80721. }
  80722. declare module BABYLON {
  80723. /**
  80724. * Class used to store and describe the pipeline context associated with an effect
  80725. */
  80726. export interface IPipelineContext {
  80727. /**
  80728. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  80729. */
  80730. isAsync: boolean;
  80731. /**
  80732. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  80733. */
  80734. isReady: boolean;
  80735. /** @hidden */
  80736. _getVertexShaderCode(): string | null;
  80737. /** @hidden */
  80738. _getFragmentShaderCode(): string | null;
  80739. /** @hidden */
  80740. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  80741. }
  80742. }
  80743. declare module BABYLON {
  80744. /**
  80745. * Class used to store gfx data (like WebGLBuffer)
  80746. */
  80747. export class DataBuffer {
  80748. /**
  80749. * Gets or sets the number of objects referencing this buffer
  80750. */
  80751. references: number;
  80752. /** Gets or sets the size of the underlying buffer */
  80753. capacity: number;
  80754. /**
  80755. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  80756. */
  80757. is32Bits: boolean;
  80758. /**
  80759. * Gets the underlying buffer
  80760. */
  80761. get underlyingResource(): any;
  80762. }
  80763. }
  80764. declare module BABYLON {
  80765. /** @hidden */
  80766. export interface IShaderProcessor {
  80767. attributeProcessor?: (attribute: string) => string;
  80768. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  80769. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  80770. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  80771. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  80772. lineProcessor?: (line: string, isFragment: boolean) => string;
  80773. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80774. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80775. }
  80776. }
  80777. declare module BABYLON {
  80778. /** @hidden */
  80779. export interface ProcessingOptions {
  80780. defines: string[];
  80781. indexParameters: any;
  80782. isFragment: boolean;
  80783. shouldUseHighPrecisionShader: boolean;
  80784. supportsUniformBuffers: boolean;
  80785. shadersRepository: string;
  80786. includesShadersStore: {
  80787. [key: string]: string;
  80788. };
  80789. processor?: IShaderProcessor;
  80790. version: string;
  80791. platformName: string;
  80792. lookForClosingBracketForUniformBuffer?: boolean;
  80793. }
  80794. }
  80795. declare module BABYLON {
  80796. /** @hidden */
  80797. export class ShaderCodeNode {
  80798. line: string;
  80799. children: ShaderCodeNode[];
  80800. additionalDefineKey?: string;
  80801. additionalDefineValue?: string;
  80802. isValid(preprocessors: {
  80803. [key: string]: string;
  80804. }): boolean;
  80805. process(preprocessors: {
  80806. [key: string]: string;
  80807. }, options: ProcessingOptions): string;
  80808. }
  80809. }
  80810. declare module BABYLON {
  80811. /** @hidden */
  80812. export class ShaderCodeCursor {
  80813. private _lines;
  80814. lineIndex: number;
  80815. get currentLine(): string;
  80816. get canRead(): boolean;
  80817. set lines(value: string[]);
  80818. }
  80819. }
  80820. declare module BABYLON {
  80821. /** @hidden */
  80822. export class ShaderCodeConditionNode extends ShaderCodeNode {
  80823. process(preprocessors: {
  80824. [key: string]: string;
  80825. }, options: ProcessingOptions): string;
  80826. }
  80827. }
  80828. declare module BABYLON {
  80829. /** @hidden */
  80830. export class ShaderDefineExpression {
  80831. isTrue(preprocessors: {
  80832. [key: string]: string;
  80833. }): boolean;
  80834. private static _OperatorPriority;
  80835. private static _Stack;
  80836. static postfixToInfix(postfix: string[]): string;
  80837. static infixToPostfix(infix: string): string[];
  80838. }
  80839. }
  80840. declare module BABYLON {
  80841. /** @hidden */
  80842. export class ShaderCodeTestNode extends ShaderCodeNode {
  80843. testExpression: ShaderDefineExpression;
  80844. isValid(preprocessors: {
  80845. [key: string]: string;
  80846. }): boolean;
  80847. }
  80848. }
  80849. declare module BABYLON {
  80850. /** @hidden */
  80851. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  80852. define: string;
  80853. not: boolean;
  80854. constructor(define: string, not?: boolean);
  80855. isTrue(preprocessors: {
  80856. [key: string]: string;
  80857. }): boolean;
  80858. }
  80859. }
  80860. declare module BABYLON {
  80861. /** @hidden */
  80862. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  80863. leftOperand: ShaderDefineExpression;
  80864. rightOperand: ShaderDefineExpression;
  80865. isTrue(preprocessors: {
  80866. [key: string]: string;
  80867. }): boolean;
  80868. }
  80869. }
  80870. declare module BABYLON {
  80871. /** @hidden */
  80872. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  80873. leftOperand: ShaderDefineExpression;
  80874. rightOperand: ShaderDefineExpression;
  80875. isTrue(preprocessors: {
  80876. [key: string]: string;
  80877. }): boolean;
  80878. }
  80879. }
  80880. declare module BABYLON {
  80881. /** @hidden */
  80882. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  80883. define: string;
  80884. operand: string;
  80885. testValue: string;
  80886. constructor(define: string, operand: string, testValue: string);
  80887. isTrue(preprocessors: {
  80888. [key: string]: string;
  80889. }): boolean;
  80890. }
  80891. }
  80892. declare module BABYLON {
  80893. /**
  80894. * Class used to enable access to offline support
  80895. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  80896. */
  80897. export interface IOfflineProvider {
  80898. /**
  80899. * Gets a boolean indicating if scene must be saved in the database
  80900. */
  80901. enableSceneOffline: boolean;
  80902. /**
  80903. * Gets a boolean indicating if textures must be saved in the database
  80904. */
  80905. enableTexturesOffline: boolean;
  80906. /**
  80907. * Open the offline support and make it available
  80908. * @param successCallback defines the callback to call on success
  80909. * @param errorCallback defines the callback to call on error
  80910. */
  80911. open(successCallback: () => void, errorCallback: () => void): void;
  80912. /**
  80913. * Loads an image from the offline support
  80914. * @param url defines the url to load from
  80915. * @param image defines the target DOM image
  80916. */
  80917. loadImage(url: string, image: HTMLImageElement): void;
  80918. /**
  80919. * Loads a file from offline support
  80920. * @param url defines the URL to load from
  80921. * @param sceneLoaded defines a callback to call on success
  80922. * @param progressCallBack defines a callback to call when progress changed
  80923. * @param errorCallback defines a callback to call on error
  80924. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  80925. */
  80926. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  80927. }
  80928. }
  80929. declare module BABYLON {
  80930. /**
  80931. * Class used to help managing file picking and drag'n'drop
  80932. * File Storage
  80933. */
  80934. export class FilesInputStore {
  80935. /**
  80936. * List of files ready to be loaded
  80937. */
  80938. static FilesToLoad: {
  80939. [key: string]: File;
  80940. };
  80941. }
  80942. }
  80943. declare module BABYLON {
  80944. /**
  80945. * Class used to define a retry strategy when error happens while loading assets
  80946. */
  80947. export class RetryStrategy {
  80948. /**
  80949. * Function used to defines an exponential back off strategy
  80950. * @param maxRetries defines the maximum number of retries (3 by default)
  80951. * @param baseInterval defines the interval between retries
  80952. * @returns the strategy function to use
  80953. */
  80954. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  80955. }
  80956. }
  80957. declare module BABYLON {
  80958. /**
  80959. * @ignore
  80960. * Application error to support additional information when loading a file
  80961. */
  80962. export abstract class BaseError extends Error {
  80963. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  80964. }
  80965. }
  80966. declare module BABYLON {
  80967. /** @ignore */
  80968. export class LoadFileError extends BaseError {
  80969. request?: WebRequest;
  80970. file?: File;
  80971. /**
  80972. * Creates a new LoadFileError
  80973. * @param message defines the message of the error
  80974. * @param request defines the optional web request
  80975. * @param file defines the optional file
  80976. */
  80977. constructor(message: string, object?: WebRequest | File);
  80978. }
  80979. /** @ignore */
  80980. export class RequestFileError extends BaseError {
  80981. request: WebRequest;
  80982. /**
  80983. * Creates a new LoadFileError
  80984. * @param message defines the message of the error
  80985. * @param request defines the optional web request
  80986. */
  80987. constructor(message: string, request: WebRequest);
  80988. }
  80989. /** @ignore */
  80990. export class ReadFileError extends BaseError {
  80991. file: File;
  80992. /**
  80993. * Creates a new ReadFileError
  80994. * @param message defines the message of the error
  80995. * @param file defines the optional file
  80996. */
  80997. constructor(message: string, file: File);
  80998. }
  80999. /**
  81000. * @hidden
  81001. */
  81002. export class FileTools {
  81003. /**
  81004. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  81005. */
  81006. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  81007. /**
  81008. * Gets or sets the base URL to use to load assets
  81009. */
  81010. static BaseUrl: string;
  81011. /**
  81012. * Default behaviour for cors in the application.
  81013. * It can be a string if the expected behavior is identical in the entire app.
  81014. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  81015. */
  81016. static CorsBehavior: string | ((url: string | string[]) => string);
  81017. /**
  81018. * Gets or sets a function used to pre-process url before using them to load assets
  81019. */
  81020. static PreprocessUrl: (url: string) => string;
  81021. /**
  81022. * Removes unwanted characters from an url
  81023. * @param url defines the url to clean
  81024. * @returns the cleaned url
  81025. */
  81026. private static _CleanUrl;
  81027. /**
  81028. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  81029. * @param url define the url we are trying
  81030. * @param element define the dom element where to configure the cors policy
  81031. */
  81032. static SetCorsBehavior(url: string | string[], element: {
  81033. crossOrigin: string | null;
  81034. }): void;
  81035. /**
  81036. * Loads an image as an HTMLImageElement.
  81037. * @param input url string, ArrayBuffer, or Blob to load
  81038. * @param onLoad callback called when the image successfully loads
  81039. * @param onError callback called when the image fails to load
  81040. * @param offlineProvider offline provider for caching
  81041. * @param mimeType optional mime type
  81042. * @returns the HTMLImageElement of the loaded image
  81043. */
  81044. 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>;
  81045. /**
  81046. * Reads a file from a File object
  81047. * @param file defines the file to load
  81048. * @param onSuccess defines the callback to call when data is loaded
  81049. * @param onProgress defines the callback to call during loading process
  81050. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  81051. * @param onError defines the callback to call when an error occurs
  81052. * @returns a file request object
  81053. */
  81054. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  81055. /**
  81056. * Loads a file from a url
  81057. * @param url url to load
  81058. * @param onSuccess callback called when the file successfully loads
  81059. * @param onProgress callback called while file is loading (if the server supports this mode)
  81060. * @param offlineProvider defines the offline provider for caching
  81061. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81062. * @param onError callback called when the file fails to load
  81063. * @returns a file request object
  81064. */
  81065. 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;
  81066. /**
  81067. * Loads a file
  81068. * @param url url to load
  81069. * @param onSuccess callback called when the file successfully loads
  81070. * @param onProgress callback called while file is loading (if the server supports this mode)
  81071. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81072. * @param onError callback called when the file fails to load
  81073. * @param onOpened callback called when the web request is opened
  81074. * @returns a file request object
  81075. */
  81076. 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;
  81077. /**
  81078. * Checks if the loaded document was accessed via `file:`-Protocol.
  81079. * @returns boolean
  81080. */
  81081. static IsFileURL(): boolean;
  81082. }
  81083. }
  81084. declare module BABYLON {
  81085. /** @hidden */
  81086. export class ShaderProcessor {
  81087. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  81088. private static _ProcessPrecision;
  81089. private static _ExtractOperation;
  81090. private static _BuildSubExpression;
  81091. private static _BuildExpression;
  81092. private static _MoveCursorWithinIf;
  81093. private static _MoveCursor;
  81094. private static _EvaluatePreProcessors;
  81095. private static _PreparePreProcessors;
  81096. private static _ProcessShaderConversion;
  81097. private static _ProcessIncludes;
  81098. /**
  81099. * Loads a file from a url
  81100. * @param url url to load
  81101. * @param onSuccess callback called when the file successfully loads
  81102. * @param onProgress callback called while file is loading (if the server supports this mode)
  81103. * @param offlineProvider defines the offline provider for caching
  81104. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81105. * @param onError callback called when the file fails to load
  81106. * @returns a file request object
  81107. * @hidden
  81108. */
  81109. 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;
  81110. }
  81111. }
  81112. declare module BABYLON {
  81113. /**
  81114. * @hidden
  81115. */
  81116. export interface IColor4Like {
  81117. r: float;
  81118. g: float;
  81119. b: float;
  81120. a: float;
  81121. }
  81122. /**
  81123. * @hidden
  81124. */
  81125. export interface IColor3Like {
  81126. r: float;
  81127. g: float;
  81128. b: float;
  81129. }
  81130. /**
  81131. * @hidden
  81132. */
  81133. export interface IVector4Like {
  81134. x: float;
  81135. y: float;
  81136. z: float;
  81137. w: float;
  81138. }
  81139. /**
  81140. * @hidden
  81141. */
  81142. export interface IVector3Like {
  81143. x: float;
  81144. y: float;
  81145. z: float;
  81146. }
  81147. /**
  81148. * @hidden
  81149. */
  81150. export interface IVector2Like {
  81151. x: float;
  81152. y: float;
  81153. }
  81154. /**
  81155. * @hidden
  81156. */
  81157. export interface IMatrixLike {
  81158. toArray(): DeepImmutable<Float32Array | Array<number>>;
  81159. updateFlag: int;
  81160. }
  81161. /**
  81162. * @hidden
  81163. */
  81164. export interface IViewportLike {
  81165. x: float;
  81166. y: float;
  81167. width: float;
  81168. height: float;
  81169. }
  81170. /**
  81171. * @hidden
  81172. */
  81173. export interface IPlaneLike {
  81174. normal: IVector3Like;
  81175. d: float;
  81176. normalize(): void;
  81177. }
  81178. }
  81179. declare module BABYLON {
  81180. /**
  81181. * Interface used to define common properties for effect fallbacks
  81182. */
  81183. export interface IEffectFallbacks {
  81184. /**
  81185. * Removes the defines that should be removed when falling back.
  81186. * @param currentDefines defines the current define statements for the shader.
  81187. * @param effect defines the current effect we try to compile
  81188. * @returns The resulting defines with defines of the current rank removed.
  81189. */
  81190. reduce(currentDefines: string, effect: Effect): string;
  81191. /**
  81192. * Removes the fallback from the bound mesh.
  81193. */
  81194. unBindMesh(): void;
  81195. /**
  81196. * Checks to see if more fallbacks are still availible.
  81197. */
  81198. hasMoreFallbacks: boolean;
  81199. }
  81200. }
  81201. declare module BABYLON {
  81202. /**
  81203. * Class used to evalaute queries containing `and` and `or` operators
  81204. */
  81205. export class AndOrNotEvaluator {
  81206. /**
  81207. * Evaluate a query
  81208. * @param query defines the query to evaluate
  81209. * @param evaluateCallback defines the callback used to filter result
  81210. * @returns true if the query matches
  81211. */
  81212. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  81213. private static _HandleParenthesisContent;
  81214. private static _SimplifyNegation;
  81215. }
  81216. }
  81217. declare module BABYLON {
  81218. /**
  81219. * Class used to store custom tags
  81220. */
  81221. export class Tags {
  81222. /**
  81223. * Adds support for tags on the given object
  81224. * @param obj defines the object to use
  81225. */
  81226. static EnableFor(obj: any): void;
  81227. /**
  81228. * Removes tags support
  81229. * @param obj defines the object to use
  81230. */
  81231. static DisableFor(obj: any): void;
  81232. /**
  81233. * Gets a boolean indicating if the given object has tags
  81234. * @param obj defines the object to use
  81235. * @returns a boolean
  81236. */
  81237. static HasTags(obj: any): boolean;
  81238. /**
  81239. * Gets the tags available on a given object
  81240. * @param obj defines the object to use
  81241. * @param asString defines if the tags must be returned as a string instead of an array of strings
  81242. * @returns the tags
  81243. */
  81244. static GetTags(obj: any, asString?: boolean): any;
  81245. /**
  81246. * Adds tags to an object
  81247. * @param obj defines the object to use
  81248. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  81249. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  81250. */
  81251. static AddTagsTo(obj: any, tagsString: string): void;
  81252. /**
  81253. * @hidden
  81254. */
  81255. static _AddTagTo(obj: any, tag: string): void;
  81256. /**
  81257. * Removes specific tags from a specific object
  81258. * @param obj defines the object to use
  81259. * @param tagsString defines the tags to remove
  81260. */
  81261. static RemoveTagsFrom(obj: any, tagsString: string): void;
  81262. /**
  81263. * @hidden
  81264. */
  81265. static _RemoveTagFrom(obj: any, tag: string): void;
  81266. /**
  81267. * Defines if tags hosted on an object match a given query
  81268. * @param obj defines the object to use
  81269. * @param tagsQuery defines the tag query
  81270. * @returns a boolean
  81271. */
  81272. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  81273. }
  81274. }
  81275. declare module BABYLON {
  81276. /**
  81277. * Scalar computation library
  81278. */
  81279. export class Scalar {
  81280. /**
  81281. * Two pi constants convenient for computation.
  81282. */
  81283. static TwoPi: number;
  81284. /**
  81285. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81286. * @param a number
  81287. * @param b number
  81288. * @param epsilon (default = 1.401298E-45)
  81289. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81290. */
  81291. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  81292. /**
  81293. * Returns a string : the upper case translation of the number i to hexadecimal.
  81294. * @param i number
  81295. * @returns the upper case translation of the number i to hexadecimal.
  81296. */
  81297. static ToHex(i: number): string;
  81298. /**
  81299. * Returns -1 if value is negative and +1 is value is positive.
  81300. * @param value the value
  81301. * @returns the value itself if it's equal to zero.
  81302. */
  81303. static Sign(value: number): number;
  81304. /**
  81305. * Returns the value itself if it's between min and max.
  81306. * Returns min if the value is lower than min.
  81307. * Returns max if the value is greater than max.
  81308. * @param value the value to clmap
  81309. * @param min the min value to clamp to (default: 0)
  81310. * @param max the max value to clamp to (default: 1)
  81311. * @returns the clamped value
  81312. */
  81313. static Clamp(value: number, min?: number, max?: number): number;
  81314. /**
  81315. * the log2 of value.
  81316. * @param value the value to compute log2 of
  81317. * @returns the log2 of value.
  81318. */
  81319. static Log2(value: number): number;
  81320. /**
  81321. * Loops the value, so that it is never larger than length and never smaller than 0.
  81322. *
  81323. * This is similar to the modulo operator but it works with floating point numbers.
  81324. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  81325. * With t = 5 and length = 2.5, the result would be 0.0.
  81326. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  81327. * @param value the value
  81328. * @param length the length
  81329. * @returns the looped value
  81330. */
  81331. static Repeat(value: number, length: number): number;
  81332. /**
  81333. * Normalize the value between 0.0 and 1.0 using min and max values
  81334. * @param value value to normalize
  81335. * @param min max to normalize between
  81336. * @param max min to normalize between
  81337. * @returns the normalized value
  81338. */
  81339. static Normalize(value: number, min: number, max: number): number;
  81340. /**
  81341. * Denormalize the value from 0.0 and 1.0 using min and max values
  81342. * @param normalized value to denormalize
  81343. * @param min max to denormalize between
  81344. * @param max min to denormalize between
  81345. * @returns the denormalized value
  81346. */
  81347. static Denormalize(normalized: number, min: number, max: number): number;
  81348. /**
  81349. * Calculates the shortest difference between two given angles given in degrees.
  81350. * @param current current angle in degrees
  81351. * @param target target angle in degrees
  81352. * @returns the delta
  81353. */
  81354. static DeltaAngle(current: number, target: number): number;
  81355. /**
  81356. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  81357. * @param tx value
  81358. * @param length length
  81359. * @returns The returned value will move back and forth between 0 and length
  81360. */
  81361. static PingPong(tx: number, length: number): number;
  81362. /**
  81363. * Interpolates between min and max with smoothing at the limits.
  81364. *
  81365. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  81366. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  81367. * @param from from
  81368. * @param to to
  81369. * @param tx value
  81370. * @returns the smooth stepped value
  81371. */
  81372. static SmoothStep(from: number, to: number, tx: number): number;
  81373. /**
  81374. * Moves a value current towards target.
  81375. *
  81376. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  81377. * Negative values of maxDelta pushes the value away from target.
  81378. * @param current current value
  81379. * @param target target value
  81380. * @param maxDelta max distance to move
  81381. * @returns resulting value
  81382. */
  81383. static MoveTowards(current: number, target: number, maxDelta: number): number;
  81384. /**
  81385. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  81386. *
  81387. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  81388. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  81389. * @param current current value
  81390. * @param target target value
  81391. * @param maxDelta max distance to move
  81392. * @returns resulting angle
  81393. */
  81394. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  81395. /**
  81396. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  81397. * @param start start value
  81398. * @param end target value
  81399. * @param amount amount to lerp between
  81400. * @returns the lerped value
  81401. */
  81402. static Lerp(start: number, end: number, amount: number): number;
  81403. /**
  81404. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  81405. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  81406. * @param start start value
  81407. * @param end target value
  81408. * @param amount amount to lerp between
  81409. * @returns the lerped value
  81410. */
  81411. static LerpAngle(start: number, end: number, amount: number): number;
  81412. /**
  81413. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  81414. * @param a start value
  81415. * @param b target value
  81416. * @param value value between a and b
  81417. * @returns the inverseLerp value
  81418. */
  81419. static InverseLerp(a: number, b: number, value: number): number;
  81420. /**
  81421. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  81422. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  81423. * @param value1 spline value
  81424. * @param tangent1 spline value
  81425. * @param value2 spline value
  81426. * @param tangent2 spline value
  81427. * @param amount input value
  81428. * @returns hermite result
  81429. */
  81430. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  81431. /**
  81432. * Returns a random float number between and min and max values
  81433. * @param min min value of random
  81434. * @param max max value of random
  81435. * @returns random value
  81436. */
  81437. static RandomRange(min: number, max: number): number;
  81438. /**
  81439. * This function returns percentage of a number in a given range.
  81440. *
  81441. * RangeToPercent(40,20,60) will return 0.5 (50%)
  81442. * RangeToPercent(34,0,100) will return 0.34 (34%)
  81443. * @param number to convert to percentage
  81444. * @param min min range
  81445. * @param max max range
  81446. * @returns the percentage
  81447. */
  81448. static RangeToPercent(number: number, min: number, max: number): number;
  81449. /**
  81450. * This function returns number that corresponds to the percentage in a given range.
  81451. *
  81452. * PercentToRange(0.34,0,100) will return 34.
  81453. * @param percent to convert to number
  81454. * @param min min range
  81455. * @param max max range
  81456. * @returns the number
  81457. */
  81458. static PercentToRange(percent: number, min: number, max: number): number;
  81459. /**
  81460. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  81461. * @param angle The angle to normalize in radian.
  81462. * @return The converted angle.
  81463. */
  81464. static NormalizeRadians(angle: number): number;
  81465. }
  81466. }
  81467. declare module BABYLON {
  81468. /**
  81469. * Constant used to convert a value to gamma space
  81470. * @ignorenaming
  81471. */
  81472. export const ToGammaSpace: number;
  81473. /**
  81474. * Constant used to convert a value to linear space
  81475. * @ignorenaming
  81476. */
  81477. export const ToLinearSpace = 2.2;
  81478. /**
  81479. * Constant used to define the minimal number value in Babylon.js
  81480. * @ignorenaming
  81481. */
  81482. let Epsilon: number;
  81483. }
  81484. declare module BABYLON {
  81485. /**
  81486. * Class used to represent a viewport on screen
  81487. */
  81488. export class Viewport {
  81489. /** viewport left coordinate */
  81490. x: number;
  81491. /** viewport top coordinate */
  81492. y: number;
  81493. /**viewport width */
  81494. width: number;
  81495. /** viewport height */
  81496. height: number;
  81497. /**
  81498. * Creates a Viewport object located at (x, y) and sized (width, height)
  81499. * @param x defines viewport left coordinate
  81500. * @param y defines viewport top coordinate
  81501. * @param width defines the viewport width
  81502. * @param height defines the viewport height
  81503. */
  81504. constructor(
  81505. /** viewport left coordinate */
  81506. x: number,
  81507. /** viewport top coordinate */
  81508. y: number,
  81509. /**viewport width */
  81510. width: number,
  81511. /** viewport height */
  81512. height: number);
  81513. /**
  81514. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  81515. * @param renderWidth defines the rendering width
  81516. * @param renderHeight defines the rendering height
  81517. * @returns a new Viewport
  81518. */
  81519. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  81520. /**
  81521. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  81522. * @param renderWidth defines the rendering width
  81523. * @param renderHeight defines the rendering height
  81524. * @param ref defines the target viewport
  81525. * @returns the current viewport
  81526. */
  81527. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  81528. /**
  81529. * Returns a new Viewport copied from the current one
  81530. * @returns a new Viewport
  81531. */
  81532. clone(): Viewport;
  81533. }
  81534. }
  81535. declare module BABYLON {
  81536. /**
  81537. * Class containing a set of static utilities functions for arrays.
  81538. */
  81539. export class ArrayTools {
  81540. /**
  81541. * Returns an array of the given size filled with element built from the given constructor and the paramters
  81542. * @param size the number of element to construct and put in the array
  81543. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  81544. * @returns a new array filled with new objects
  81545. */
  81546. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  81547. }
  81548. }
  81549. declare module BABYLON {
  81550. /**
  81551. * Represents a plane by the equation ax + by + cz + d = 0
  81552. */
  81553. export class Plane {
  81554. private static _TmpMatrix;
  81555. /**
  81556. * Normal of the plane (a,b,c)
  81557. */
  81558. normal: Vector3;
  81559. /**
  81560. * d component of the plane
  81561. */
  81562. d: number;
  81563. /**
  81564. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  81565. * @param a a component of the plane
  81566. * @param b b component of the plane
  81567. * @param c c component of the plane
  81568. * @param d d component of the plane
  81569. */
  81570. constructor(a: number, b: number, c: number, d: number);
  81571. /**
  81572. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  81573. */
  81574. asArray(): number[];
  81575. /**
  81576. * @returns a new plane copied from the current Plane.
  81577. */
  81578. clone(): Plane;
  81579. /**
  81580. * @returns the string "Plane".
  81581. */
  81582. getClassName(): string;
  81583. /**
  81584. * @returns the Plane hash code.
  81585. */
  81586. getHashCode(): number;
  81587. /**
  81588. * Normalize the current Plane in place.
  81589. * @returns the updated Plane.
  81590. */
  81591. normalize(): Plane;
  81592. /**
  81593. * Applies a transformation the plane and returns the result
  81594. * @param transformation the transformation matrix to be applied to the plane
  81595. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  81596. */
  81597. transform(transformation: DeepImmutable<Matrix>): Plane;
  81598. /**
  81599. * Compute the dot product between the point and the plane normal
  81600. * @param point point to calculate the dot product with
  81601. * @returns the dot product (float) of the point coordinates and the plane normal.
  81602. */
  81603. dotCoordinate(point: DeepImmutable<Vector3>): number;
  81604. /**
  81605. * Updates the current Plane from the plane defined by the three given points.
  81606. * @param point1 one of the points used to contruct the plane
  81607. * @param point2 one of the points used to contruct the plane
  81608. * @param point3 one of the points used to contruct the plane
  81609. * @returns the updated Plane.
  81610. */
  81611. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81612. /**
  81613. * Checks if the plane is facing a given direction
  81614. * @param direction the direction to check if the plane is facing
  81615. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  81616. * @returns True is the vector "direction" is the same side than the plane normal.
  81617. */
  81618. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  81619. /**
  81620. * Calculates the distance to a point
  81621. * @param point point to calculate distance to
  81622. * @returns the signed distance (float) from the given point to the Plane.
  81623. */
  81624. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  81625. /**
  81626. * Creates a plane from an array
  81627. * @param array the array to create a plane from
  81628. * @returns a new Plane from the given array.
  81629. */
  81630. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  81631. /**
  81632. * Creates a plane from three points
  81633. * @param point1 point used to create the plane
  81634. * @param point2 point used to create the plane
  81635. * @param point3 point used to create the plane
  81636. * @returns a new Plane defined by the three given points.
  81637. */
  81638. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81639. /**
  81640. * Creates a plane from an origin point and a normal
  81641. * @param origin origin of the plane to be constructed
  81642. * @param normal normal of the plane to be constructed
  81643. * @returns a new Plane the normal vector to this plane at the given origin point.
  81644. * Note : the vector "normal" is updated because normalized.
  81645. */
  81646. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  81647. /**
  81648. * Calculates the distance from a plane and a point
  81649. * @param origin origin of the plane to be constructed
  81650. * @param normal normal of the plane to be constructed
  81651. * @param point point to calculate distance to
  81652. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  81653. */
  81654. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  81655. }
  81656. }
  81657. declare module BABYLON {
  81658. /** @hidden */
  81659. export class PerformanceConfigurator {
  81660. /** @hidden */
  81661. static MatrixUse64Bits: boolean;
  81662. /** @hidden */
  81663. static MatrixTrackPrecisionChange: boolean;
  81664. /** @hidden */
  81665. static MatrixCurrentType: any;
  81666. /** @hidden */
  81667. static MatrixTrackedMatrices: Array<any> | null;
  81668. /** @hidden */
  81669. static SetMatrixPrecision(use64bits: boolean): void;
  81670. }
  81671. }
  81672. declare module BABYLON {
  81673. /**
  81674. * Class representing a vector containing 2 coordinates
  81675. */
  81676. export class Vector2 {
  81677. /** defines the first coordinate */
  81678. x: number;
  81679. /** defines the second coordinate */
  81680. y: number;
  81681. /**
  81682. * Creates a new Vector2 from the given x and y coordinates
  81683. * @param x defines the first coordinate
  81684. * @param y defines the second coordinate
  81685. */
  81686. constructor(
  81687. /** defines the first coordinate */
  81688. x?: number,
  81689. /** defines the second coordinate */
  81690. y?: number);
  81691. /**
  81692. * Gets a string with the Vector2 coordinates
  81693. * @returns a string with the Vector2 coordinates
  81694. */
  81695. toString(): string;
  81696. /**
  81697. * Gets class name
  81698. * @returns the string "Vector2"
  81699. */
  81700. getClassName(): string;
  81701. /**
  81702. * Gets current vector hash code
  81703. * @returns the Vector2 hash code as a number
  81704. */
  81705. getHashCode(): number;
  81706. /**
  81707. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  81708. * @param array defines the source array
  81709. * @param index defines the offset in source array
  81710. * @returns the current Vector2
  81711. */
  81712. toArray(array: FloatArray, index?: number): Vector2;
  81713. /**
  81714. * Update the current vector from an array
  81715. * @param array defines the destination array
  81716. * @param index defines the offset in the destination array
  81717. * @returns the current Vector3
  81718. */
  81719. fromArray(array: FloatArray, index?: number): Vector2;
  81720. /**
  81721. * Copy the current vector to an array
  81722. * @returns a new array with 2 elements: the Vector2 coordinates.
  81723. */
  81724. asArray(): number[];
  81725. /**
  81726. * Sets the Vector2 coordinates with the given Vector2 coordinates
  81727. * @param source defines the source Vector2
  81728. * @returns the current updated Vector2
  81729. */
  81730. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  81731. /**
  81732. * Sets the Vector2 coordinates with the given floats
  81733. * @param x defines the first coordinate
  81734. * @param y defines the second coordinate
  81735. * @returns the current updated Vector2
  81736. */
  81737. copyFromFloats(x: number, y: number): Vector2;
  81738. /**
  81739. * Sets the Vector2 coordinates with the given floats
  81740. * @param x defines the first coordinate
  81741. * @param y defines the second coordinate
  81742. * @returns the current updated Vector2
  81743. */
  81744. set(x: number, y: number): Vector2;
  81745. /**
  81746. * Add another vector with the current one
  81747. * @param otherVector defines the other vector
  81748. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  81749. */
  81750. add(otherVector: DeepImmutable<Vector2>): Vector2;
  81751. /**
  81752. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  81753. * @param otherVector defines the other vector
  81754. * @param result defines the target vector
  81755. * @returns the unmodified current Vector2
  81756. */
  81757. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81758. /**
  81759. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  81760. * @param otherVector defines the other vector
  81761. * @returns the current updated Vector2
  81762. */
  81763. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81764. /**
  81765. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  81766. * @param otherVector defines the other vector
  81767. * @returns a new Vector2
  81768. */
  81769. addVector3(otherVector: Vector3): Vector2;
  81770. /**
  81771. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  81772. * @param otherVector defines the other vector
  81773. * @returns a new Vector2
  81774. */
  81775. subtract(otherVector: Vector2): Vector2;
  81776. /**
  81777. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  81778. * @param otherVector defines the other vector
  81779. * @param result defines the target vector
  81780. * @returns the unmodified current Vector2
  81781. */
  81782. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81783. /**
  81784. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  81785. * @param otherVector defines the other vector
  81786. * @returns the current updated Vector2
  81787. */
  81788. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81789. /**
  81790. * Multiplies in place the current Vector2 coordinates by the given ones
  81791. * @param otherVector defines the other vector
  81792. * @returns the current updated Vector2
  81793. */
  81794. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81795. /**
  81796. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  81797. * @param otherVector defines the other vector
  81798. * @returns a new Vector2
  81799. */
  81800. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  81801. /**
  81802. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  81803. * @param otherVector defines the other vector
  81804. * @param result defines the target vector
  81805. * @returns the unmodified current Vector2
  81806. */
  81807. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81808. /**
  81809. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  81810. * @param x defines the first coordinate
  81811. * @param y defines the second coordinate
  81812. * @returns a new Vector2
  81813. */
  81814. multiplyByFloats(x: number, y: number): Vector2;
  81815. /**
  81816. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  81817. * @param otherVector defines the other vector
  81818. * @returns a new Vector2
  81819. */
  81820. divide(otherVector: Vector2): Vector2;
  81821. /**
  81822. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  81823. * @param otherVector defines the other vector
  81824. * @param result defines the target vector
  81825. * @returns the unmodified current Vector2
  81826. */
  81827. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81828. /**
  81829. * Divides the current Vector2 coordinates by the given ones
  81830. * @param otherVector defines the other vector
  81831. * @returns the current updated Vector2
  81832. */
  81833. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81834. /**
  81835. * Gets a new Vector2 with current Vector2 negated coordinates
  81836. * @returns a new Vector2
  81837. */
  81838. negate(): Vector2;
  81839. /**
  81840. * Negate this vector in place
  81841. * @returns this
  81842. */
  81843. negateInPlace(): Vector2;
  81844. /**
  81845. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  81846. * @param result defines the Vector3 object where to store the result
  81847. * @returns the current Vector2
  81848. */
  81849. negateToRef(result: Vector2): Vector2;
  81850. /**
  81851. * Multiply the Vector2 coordinates by scale
  81852. * @param scale defines the scaling factor
  81853. * @returns the current updated Vector2
  81854. */
  81855. scaleInPlace(scale: number): Vector2;
  81856. /**
  81857. * Returns a new Vector2 scaled by "scale" from the current Vector2
  81858. * @param scale defines the scaling factor
  81859. * @returns a new Vector2
  81860. */
  81861. scale(scale: number): Vector2;
  81862. /**
  81863. * Scale the current Vector2 values by a factor to a given Vector2
  81864. * @param scale defines the scale factor
  81865. * @param result defines the Vector2 object where to store the result
  81866. * @returns the unmodified current Vector2
  81867. */
  81868. scaleToRef(scale: number, result: Vector2): Vector2;
  81869. /**
  81870. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  81871. * @param scale defines the scale factor
  81872. * @param result defines the Vector2 object where to store the result
  81873. * @returns the unmodified current Vector2
  81874. */
  81875. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  81876. /**
  81877. * Gets a boolean if two vectors are equals
  81878. * @param otherVector defines the other vector
  81879. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  81880. */
  81881. equals(otherVector: DeepImmutable<Vector2>): boolean;
  81882. /**
  81883. * Gets a boolean if two vectors are equals (using an epsilon value)
  81884. * @param otherVector defines the other vector
  81885. * @param epsilon defines the minimal distance to consider equality
  81886. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  81887. */
  81888. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  81889. /**
  81890. * Gets a new Vector2 from current Vector2 floored values
  81891. * @returns a new Vector2
  81892. */
  81893. floor(): Vector2;
  81894. /**
  81895. * Gets a new Vector2 from current Vector2 floored values
  81896. * @returns a new Vector2
  81897. */
  81898. fract(): Vector2;
  81899. /**
  81900. * Gets the length of the vector
  81901. * @returns the vector length (float)
  81902. */
  81903. length(): number;
  81904. /**
  81905. * Gets the vector squared length
  81906. * @returns the vector squared length (float)
  81907. */
  81908. lengthSquared(): number;
  81909. /**
  81910. * Normalize the vector
  81911. * @returns the current updated Vector2
  81912. */
  81913. normalize(): Vector2;
  81914. /**
  81915. * Gets a new Vector2 copied from the Vector2
  81916. * @returns a new Vector2
  81917. */
  81918. clone(): Vector2;
  81919. /**
  81920. * Gets a new Vector2(0, 0)
  81921. * @returns a new Vector2
  81922. */
  81923. static Zero(): Vector2;
  81924. /**
  81925. * Gets a new Vector2(1, 1)
  81926. * @returns a new Vector2
  81927. */
  81928. static One(): Vector2;
  81929. /**
  81930. * Gets a new Vector2 set from the given index element of the given array
  81931. * @param array defines the data source
  81932. * @param offset defines the offset in the data source
  81933. * @returns a new Vector2
  81934. */
  81935. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  81936. /**
  81937. * Sets "result" from the given index element of the given array
  81938. * @param array defines the data source
  81939. * @param offset defines the offset in the data source
  81940. * @param result defines the target vector
  81941. */
  81942. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  81943. /**
  81944. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  81945. * @param value1 defines 1st point of control
  81946. * @param value2 defines 2nd point of control
  81947. * @param value3 defines 3rd point of control
  81948. * @param value4 defines 4th point of control
  81949. * @param amount defines the interpolation factor
  81950. * @returns a new Vector2
  81951. */
  81952. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  81953. /**
  81954. * 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".
  81955. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  81956. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  81957. * @param value defines the value to clamp
  81958. * @param min defines the lower limit
  81959. * @param max defines the upper limit
  81960. * @returns a new Vector2
  81961. */
  81962. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  81963. /**
  81964. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  81965. * @param value1 defines the 1st control point
  81966. * @param tangent1 defines the outgoing tangent
  81967. * @param value2 defines the 2nd control point
  81968. * @param tangent2 defines the incoming tangent
  81969. * @param amount defines the interpolation factor
  81970. * @returns a new Vector2
  81971. */
  81972. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  81973. /**
  81974. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  81975. * @param start defines the start vector
  81976. * @param end defines the end vector
  81977. * @param amount defines the interpolation factor
  81978. * @returns a new Vector2
  81979. */
  81980. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  81981. /**
  81982. * Gets the dot product of the vector "left" and the vector "right"
  81983. * @param left defines first vector
  81984. * @param right defines second vector
  81985. * @returns the dot product (float)
  81986. */
  81987. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  81988. /**
  81989. * Returns a new Vector2 equal to the normalized given vector
  81990. * @param vector defines the vector to normalize
  81991. * @returns a new Vector2
  81992. */
  81993. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  81994. /**
  81995. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  81996. * @param left defines 1st vector
  81997. * @param right defines 2nd vector
  81998. * @returns a new Vector2
  81999. */
  82000. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82001. /**
  82002. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  82003. * @param left defines 1st vector
  82004. * @param right defines 2nd vector
  82005. * @returns a new Vector2
  82006. */
  82007. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82008. /**
  82009. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  82010. * @param vector defines the vector to transform
  82011. * @param transformation defines the matrix to apply
  82012. * @returns a new Vector2
  82013. */
  82014. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  82015. /**
  82016. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  82017. * @param vector defines the vector to transform
  82018. * @param transformation defines the matrix to apply
  82019. * @param result defines the target vector
  82020. */
  82021. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  82022. /**
  82023. * Determines if a given vector is included in a triangle
  82024. * @param p defines the vector to test
  82025. * @param p0 defines 1st triangle point
  82026. * @param p1 defines 2nd triangle point
  82027. * @param p2 defines 3rd triangle point
  82028. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  82029. */
  82030. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  82031. /**
  82032. * Gets the distance between the vectors "value1" and "value2"
  82033. * @param value1 defines first vector
  82034. * @param value2 defines second vector
  82035. * @returns the distance between vectors
  82036. */
  82037. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82038. /**
  82039. * Returns the squared distance between the vectors "value1" and "value2"
  82040. * @param value1 defines first vector
  82041. * @param value2 defines second vector
  82042. * @returns the squared distance between vectors
  82043. */
  82044. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82045. /**
  82046. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  82047. * @param value1 defines first vector
  82048. * @param value2 defines second vector
  82049. * @returns a new Vector2
  82050. */
  82051. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  82052. /**
  82053. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  82054. * @param p defines the middle point
  82055. * @param segA defines one point of the segment
  82056. * @param segB defines the other point of the segment
  82057. * @returns the shortest distance
  82058. */
  82059. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  82060. }
  82061. /**
  82062. * Class used to store (x,y,z) vector representation
  82063. * A Vector3 is the main object used in 3D geometry
  82064. * It can represent etiher the coordinates of a point the space, either a direction
  82065. * Reminder: js uses a left handed forward facing system
  82066. */
  82067. export class Vector3 {
  82068. private static _UpReadOnly;
  82069. private static _ZeroReadOnly;
  82070. /** @hidden */
  82071. _x: number;
  82072. /** @hidden */
  82073. _y: number;
  82074. /** @hidden */
  82075. _z: number;
  82076. /** @hidden */
  82077. _isDirty: boolean;
  82078. /** Gets or sets the x coordinate */
  82079. get x(): number;
  82080. set x(value: number);
  82081. /** Gets or sets the y coordinate */
  82082. get y(): number;
  82083. set y(value: number);
  82084. /** Gets or sets the z coordinate */
  82085. get z(): number;
  82086. set z(value: number);
  82087. /**
  82088. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  82089. * @param x defines the first coordinates (on X axis)
  82090. * @param y defines the second coordinates (on Y axis)
  82091. * @param z defines the third coordinates (on Z axis)
  82092. */
  82093. constructor(x?: number, y?: number, z?: number);
  82094. /**
  82095. * Creates a string representation of the Vector3
  82096. * @returns a string with the Vector3 coordinates.
  82097. */
  82098. toString(): string;
  82099. /**
  82100. * Gets the class name
  82101. * @returns the string "Vector3"
  82102. */
  82103. getClassName(): string;
  82104. /**
  82105. * Creates the Vector3 hash code
  82106. * @returns a number which tends to be unique between Vector3 instances
  82107. */
  82108. getHashCode(): number;
  82109. /**
  82110. * Creates an array containing three elements : the coordinates of the Vector3
  82111. * @returns a new array of numbers
  82112. */
  82113. asArray(): number[];
  82114. /**
  82115. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  82116. * @param array defines the destination array
  82117. * @param index defines the offset in the destination array
  82118. * @returns the current Vector3
  82119. */
  82120. toArray(array: FloatArray, index?: number): Vector3;
  82121. /**
  82122. * Update the current vector from an array
  82123. * @param array defines the destination array
  82124. * @param index defines the offset in the destination array
  82125. * @returns the current Vector3
  82126. */
  82127. fromArray(array: FloatArray, index?: number): Vector3;
  82128. /**
  82129. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  82130. * @returns a new Quaternion object, computed from the Vector3 coordinates
  82131. */
  82132. toQuaternion(): Quaternion;
  82133. /**
  82134. * Adds the given vector to the current Vector3
  82135. * @param otherVector defines the second operand
  82136. * @returns the current updated Vector3
  82137. */
  82138. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82139. /**
  82140. * Adds the given coordinates to the current Vector3
  82141. * @param x defines the x coordinate of the operand
  82142. * @param y defines the y coordinate of the operand
  82143. * @param z defines the z coordinate of the operand
  82144. * @returns the current updated Vector3
  82145. */
  82146. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82147. /**
  82148. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  82149. * @param otherVector defines the second operand
  82150. * @returns the resulting Vector3
  82151. */
  82152. add(otherVector: DeepImmutable<Vector3>): Vector3;
  82153. /**
  82154. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  82155. * @param otherVector defines the second operand
  82156. * @param result defines the Vector3 object where to store the result
  82157. * @returns the current Vector3
  82158. */
  82159. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82160. /**
  82161. * Subtract the given vector from the current Vector3
  82162. * @param otherVector defines the second operand
  82163. * @returns the current updated Vector3
  82164. */
  82165. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82166. /**
  82167. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  82168. * @param otherVector defines the second operand
  82169. * @returns the resulting Vector3
  82170. */
  82171. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  82172. /**
  82173. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  82174. * @param otherVector defines the second operand
  82175. * @param result defines the Vector3 object where to store the result
  82176. * @returns the current Vector3
  82177. */
  82178. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82179. /**
  82180. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  82181. * @param x defines the x coordinate of the operand
  82182. * @param y defines the y coordinate of the operand
  82183. * @param z defines the z coordinate of the operand
  82184. * @returns the resulting Vector3
  82185. */
  82186. subtractFromFloats(x: number, y: number, z: number): Vector3;
  82187. /**
  82188. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  82189. * @param x defines the x coordinate of the operand
  82190. * @param y defines the y coordinate of the operand
  82191. * @param z defines the z coordinate of the operand
  82192. * @param result defines the Vector3 object where to store the result
  82193. * @returns the current Vector3
  82194. */
  82195. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  82196. /**
  82197. * Gets a new Vector3 set with the current Vector3 negated coordinates
  82198. * @returns a new Vector3
  82199. */
  82200. negate(): Vector3;
  82201. /**
  82202. * Negate this vector in place
  82203. * @returns this
  82204. */
  82205. negateInPlace(): Vector3;
  82206. /**
  82207. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  82208. * @param result defines the Vector3 object where to store the result
  82209. * @returns the current Vector3
  82210. */
  82211. negateToRef(result: Vector3): Vector3;
  82212. /**
  82213. * Multiplies the Vector3 coordinates by the float "scale"
  82214. * @param scale defines the multiplier factor
  82215. * @returns the current updated Vector3
  82216. */
  82217. scaleInPlace(scale: number): Vector3;
  82218. /**
  82219. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  82220. * @param scale defines the multiplier factor
  82221. * @returns a new Vector3
  82222. */
  82223. scale(scale: number): Vector3;
  82224. /**
  82225. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  82226. * @param scale defines the multiplier factor
  82227. * @param result defines the Vector3 object where to store the result
  82228. * @returns the current Vector3
  82229. */
  82230. scaleToRef(scale: number, result: Vector3): Vector3;
  82231. /**
  82232. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  82233. * @param scale defines the scale factor
  82234. * @param result defines the Vector3 object where to store the result
  82235. * @returns the unmodified current Vector3
  82236. */
  82237. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  82238. /**
  82239. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82240. * @param origin defines the origin of the projection ray
  82241. * @param plane defines the plane to project to
  82242. * @returns the projected vector3
  82243. */
  82244. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  82245. /**
  82246. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82247. * @param origin defines the origin of the projection ray
  82248. * @param plane defines the plane to project to
  82249. * @param result defines the Vector3 where to store the result
  82250. */
  82251. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  82252. /**
  82253. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  82254. * @param otherVector defines the second operand
  82255. * @returns true if both vectors are equals
  82256. */
  82257. equals(otherVector: DeepImmutable<Vector3>): boolean;
  82258. /**
  82259. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  82260. * @param otherVector defines the second operand
  82261. * @param epsilon defines the minimal distance to define values as equals
  82262. * @returns true if both vectors are distant less than epsilon
  82263. */
  82264. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  82265. /**
  82266. * Returns true if the current Vector3 coordinates equals the given floats
  82267. * @param x defines the x coordinate of the operand
  82268. * @param y defines the y coordinate of the operand
  82269. * @param z defines the z coordinate of the operand
  82270. * @returns true if both vectors are equals
  82271. */
  82272. equalsToFloats(x: number, y: number, z: number): boolean;
  82273. /**
  82274. * Multiplies the current Vector3 coordinates by the given ones
  82275. * @param otherVector defines the second operand
  82276. * @returns the current updated Vector3
  82277. */
  82278. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82279. /**
  82280. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  82281. * @param otherVector defines the second operand
  82282. * @returns the new Vector3
  82283. */
  82284. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  82285. /**
  82286. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  82287. * @param otherVector defines the second operand
  82288. * @param result defines the Vector3 object where to store the result
  82289. * @returns the current Vector3
  82290. */
  82291. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82292. /**
  82293. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  82294. * @param x defines the x coordinate of the operand
  82295. * @param y defines the y coordinate of the operand
  82296. * @param z defines the z coordinate of the operand
  82297. * @returns the new Vector3
  82298. */
  82299. multiplyByFloats(x: number, y: number, z: number): Vector3;
  82300. /**
  82301. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  82302. * @param otherVector defines the second operand
  82303. * @returns the new Vector3
  82304. */
  82305. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  82306. /**
  82307. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  82308. * @param otherVector defines the second operand
  82309. * @param result defines the Vector3 object where to store the result
  82310. * @returns the current Vector3
  82311. */
  82312. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82313. /**
  82314. * Divides the current Vector3 coordinates by the given ones.
  82315. * @param otherVector defines the second operand
  82316. * @returns the current updated Vector3
  82317. */
  82318. divideInPlace(otherVector: Vector3): Vector3;
  82319. /**
  82320. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  82321. * @param other defines the second operand
  82322. * @returns the current updated Vector3
  82323. */
  82324. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  82325. /**
  82326. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  82327. * @param other defines the second operand
  82328. * @returns the current updated Vector3
  82329. */
  82330. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  82331. /**
  82332. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  82333. * @param x defines the x coordinate of the operand
  82334. * @param y defines the y coordinate of the operand
  82335. * @param z defines the z coordinate of the operand
  82336. * @returns the current updated Vector3
  82337. */
  82338. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82339. /**
  82340. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  82341. * @param x defines the x coordinate of the operand
  82342. * @param y defines the y coordinate of the operand
  82343. * @param z defines the z coordinate of the operand
  82344. * @returns the current updated Vector3
  82345. */
  82346. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82347. /**
  82348. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  82349. * Check if is non uniform within a certain amount of decimal places to account for this
  82350. * @param epsilon the amount the values can differ
  82351. * @returns if the the vector is non uniform to a certain number of decimal places
  82352. */
  82353. isNonUniformWithinEpsilon(epsilon: number): boolean;
  82354. /**
  82355. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  82356. */
  82357. get isNonUniform(): boolean;
  82358. /**
  82359. * Gets a new Vector3 from current Vector3 floored values
  82360. * @returns a new Vector3
  82361. */
  82362. floor(): Vector3;
  82363. /**
  82364. * Gets a new Vector3 from current Vector3 floored values
  82365. * @returns a new Vector3
  82366. */
  82367. fract(): Vector3;
  82368. /**
  82369. * Gets the length of the Vector3
  82370. * @returns the length of the Vector3
  82371. */
  82372. length(): number;
  82373. /**
  82374. * Gets the squared length of the Vector3
  82375. * @returns squared length of the Vector3
  82376. */
  82377. lengthSquared(): number;
  82378. /**
  82379. * Normalize the current Vector3.
  82380. * Please note that this is an in place operation.
  82381. * @returns the current updated Vector3
  82382. */
  82383. normalize(): Vector3;
  82384. /**
  82385. * Reorders the x y z properties of the vector in place
  82386. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  82387. * @returns the current updated vector
  82388. */
  82389. reorderInPlace(order: string): this;
  82390. /**
  82391. * Rotates the vector around 0,0,0 by a quaternion
  82392. * @param quaternion the rotation quaternion
  82393. * @param result vector to store the result
  82394. * @returns the resulting vector
  82395. */
  82396. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  82397. /**
  82398. * Rotates a vector around a given point
  82399. * @param quaternion the rotation quaternion
  82400. * @param point the point to rotate around
  82401. * @param result vector to store the result
  82402. * @returns the resulting vector
  82403. */
  82404. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  82405. /**
  82406. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  82407. * The cross product is then orthogonal to both current and "other"
  82408. * @param other defines the right operand
  82409. * @returns the cross product
  82410. */
  82411. cross(other: Vector3): Vector3;
  82412. /**
  82413. * Normalize the current Vector3 with the given input length.
  82414. * Please note that this is an in place operation.
  82415. * @param len the length of the vector
  82416. * @returns the current updated Vector3
  82417. */
  82418. normalizeFromLength(len: number): Vector3;
  82419. /**
  82420. * Normalize the current Vector3 to a new vector
  82421. * @returns the new Vector3
  82422. */
  82423. normalizeToNew(): Vector3;
  82424. /**
  82425. * Normalize the current Vector3 to the reference
  82426. * @param reference define the Vector3 to update
  82427. * @returns the updated Vector3
  82428. */
  82429. normalizeToRef(reference: Vector3): Vector3;
  82430. /**
  82431. * Creates a new Vector3 copied from the current Vector3
  82432. * @returns the new Vector3
  82433. */
  82434. clone(): Vector3;
  82435. /**
  82436. * Copies the given vector coordinates to the current Vector3 ones
  82437. * @param source defines the source Vector3
  82438. * @returns the current updated Vector3
  82439. */
  82440. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  82441. /**
  82442. * Copies the given floats to the current Vector3 coordinates
  82443. * @param x defines the x coordinate of the operand
  82444. * @param y defines the y coordinate of the operand
  82445. * @param z defines the z coordinate of the operand
  82446. * @returns the current updated Vector3
  82447. */
  82448. copyFromFloats(x: number, y: number, z: number): Vector3;
  82449. /**
  82450. * Copies the given floats to the current Vector3 coordinates
  82451. * @param x defines the x coordinate of the operand
  82452. * @param y defines the y coordinate of the operand
  82453. * @param z defines the z coordinate of the operand
  82454. * @returns the current updated Vector3
  82455. */
  82456. set(x: number, y: number, z: number): Vector3;
  82457. /**
  82458. * Copies the given float to the current Vector3 coordinates
  82459. * @param v defines the x, y and z coordinates of the operand
  82460. * @returns the current updated Vector3
  82461. */
  82462. setAll(v: number): Vector3;
  82463. /**
  82464. * Get the clip factor between two vectors
  82465. * @param vector0 defines the first operand
  82466. * @param vector1 defines the second operand
  82467. * @param axis defines the axis to use
  82468. * @param size defines the size along the axis
  82469. * @returns the clip factor
  82470. */
  82471. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  82472. /**
  82473. * Get angle between two vectors
  82474. * @param vector0 angle between vector0 and vector1
  82475. * @param vector1 angle between vector0 and vector1
  82476. * @param normal direction of the normal
  82477. * @return the angle between vector0 and vector1
  82478. */
  82479. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  82480. /**
  82481. * Returns a new Vector3 set from the index "offset" of the given array
  82482. * @param array defines the source array
  82483. * @param offset defines the offset in the source array
  82484. * @returns the new Vector3
  82485. */
  82486. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  82487. /**
  82488. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  82489. * @param array defines the source array
  82490. * @param offset defines the offset in the source array
  82491. * @returns the new Vector3
  82492. * @deprecated Please use FromArray instead.
  82493. */
  82494. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  82495. /**
  82496. * Sets the given vector "result" with the element values from the index "offset" of the given array
  82497. * @param array defines the source array
  82498. * @param offset defines the offset in the source array
  82499. * @param result defines the Vector3 where to store the result
  82500. */
  82501. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  82502. /**
  82503. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  82504. * @param array defines the source array
  82505. * @param offset defines the offset in the source array
  82506. * @param result defines the Vector3 where to store the result
  82507. * @deprecated Please use FromArrayToRef instead.
  82508. */
  82509. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  82510. /**
  82511. * Sets the given vector "result" with the given floats.
  82512. * @param x defines the x coordinate of the source
  82513. * @param y defines the y coordinate of the source
  82514. * @param z defines the z coordinate of the source
  82515. * @param result defines the Vector3 where to store the result
  82516. */
  82517. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  82518. /**
  82519. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  82520. * @returns a new empty Vector3
  82521. */
  82522. static Zero(): Vector3;
  82523. /**
  82524. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  82525. * @returns a new unit Vector3
  82526. */
  82527. static One(): Vector3;
  82528. /**
  82529. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  82530. * @returns a new up Vector3
  82531. */
  82532. static Up(): Vector3;
  82533. /**
  82534. * Gets a up Vector3 that must not be updated
  82535. */
  82536. static get UpReadOnly(): DeepImmutable<Vector3>;
  82537. /**
  82538. * Gets a zero Vector3 that must not be updated
  82539. */
  82540. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  82541. /**
  82542. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  82543. * @returns a new down Vector3
  82544. */
  82545. static Down(): Vector3;
  82546. /**
  82547. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  82548. * @param rightHandedSystem is the scene right-handed (negative z)
  82549. * @returns a new forward Vector3
  82550. */
  82551. static Forward(rightHandedSystem?: boolean): Vector3;
  82552. /**
  82553. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  82554. * @param rightHandedSystem is the scene right-handed (negative-z)
  82555. * @returns a new forward Vector3
  82556. */
  82557. static Backward(rightHandedSystem?: boolean): Vector3;
  82558. /**
  82559. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  82560. * @returns a new right Vector3
  82561. */
  82562. static Right(): Vector3;
  82563. /**
  82564. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  82565. * @returns a new left Vector3
  82566. */
  82567. static Left(): Vector3;
  82568. /**
  82569. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  82570. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82571. * @param vector defines the Vector3 to transform
  82572. * @param transformation defines the transformation matrix
  82573. * @returns the transformed Vector3
  82574. */
  82575. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82576. /**
  82577. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  82578. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82579. * @param vector defines the Vector3 to transform
  82580. * @param transformation defines the transformation matrix
  82581. * @param result defines the Vector3 where to store the result
  82582. */
  82583. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82584. /**
  82585. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  82586. * This method computes tranformed coordinates only, not transformed direction vectors
  82587. * @param x define the x coordinate of the source vector
  82588. * @param y define the y coordinate of the source vector
  82589. * @param z define the z coordinate of the source vector
  82590. * @param transformation defines the transformation matrix
  82591. * @param result defines the Vector3 where to store the result
  82592. */
  82593. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82594. /**
  82595. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  82596. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82597. * @param vector defines the Vector3 to transform
  82598. * @param transformation defines the transformation matrix
  82599. * @returns the new Vector3
  82600. */
  82601. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82602. /**
  82603. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  82604. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82605. * @param vector defines the Vector3 to transform
  82606. * @param transformation defines the transformation matrix
  82607. * @param result defines the Vector3 where to store the result
  82608. */
  82609. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82610. /**
  82611. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  82612. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82613. * @param x define the x coordinate of the source vector
  82614. * @param y define the y coordinate of the source vector
  82615. * @param z define the z coordinate of the source vector
  82616. * @param transformation defines the transformation matrix
  82617. * @param result defines the Vector3 where to store the result
  82618. */
  82619. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82620. /**
  82621. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  82622. * @param value1 defines the first control point
  82623. * @param value2 defines the second control point
  82624. * @param value3 defines the third control point
  82625. * @param value4 defines the fourth control point
  82626. * @param amount defines the amount on the spline to use
  82627. * @returns the new Vector3
  82628. */
  82629. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  82630. /**
  82631. * 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"
  82632. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82633. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82634. * @param value defines the current value
  82635. * @param min defines the lower range value
  82636. * @param max defines the upper range value
  82637. * @returns the new Vector3
  82638. */
  82639. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  82640. /**
  82641. * 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"
  82642. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82643. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82644. * @param value defines the current value
  82645. * @param min defines the lower range value
  82646. * @param max defines the upper range value
  82647. * @param result defines the Vector3 where to store the result
  82648. */
  82649. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  82650. /**
  82651. * Checks if a given vector is inside a specific range
  82652. * @param v defines the vector to test
  82653. * @param min defines the minimum range
  82654. * @param max defines the maximum range
  82655. */
  82656. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  82657. /**
  82658. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  82659. * @param value1 defines the first control point
  82660. * @param tangent1 defines the first tangent vector
  82661. * @param value2 defines the second control point
  82662. * @param tangent2 defines the second tangent vector
  82663. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  82664. * @returns the new Vector3
  82665. */
  82666. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  82667. /**
  82668. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  82669. * @param start defines the start value
  82670. * @param end defines the end value
  82671. * @param amount max defines amount between both (between 0 and 1)
  82672. * @returns the new Vector3
  82673. */
  82674. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  82675. /**
  82676. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  82677. * @param start defines the start value
  82678. * @param end defines the end value
  82679. * @param amount max defines amount between both (between 0 and 1)
  82680. * @param result defines the Vector3 where to store the result
  82681. */
  82682. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  82683. /**
  82684. * Returns the dot product (float) between the vectors "left" and "right"
  82685. * @param left defines the left operand
  82686. * @param right defines the right operand
  82687. * @returns the dot product
  82688. */
  82689. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  82690. /**
  82691. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  82692. * The cross product is then orthogonal to both "left" and "right"
  82693. * @param left defines the left operand
  82694. * @param right defines the right operand
  82695. * @returns the cross product
  82696. */
  82697. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82698. /**
  82699. * Sets the given vector "result" with the cross product of "left" and "right"
  82700. * The cross product is then orthogonal to both "left" and "right"
  82701. * @param left defines the left operand
  82702. * @param right defines the right operand
  82703. * @param result defines the Vector3 where to store the result
  82704. */
  82705. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  82706. /**
  82707. * Returns a new Vector3 as the normalization of the given vector
  82708. * @param vector defines the Vector3 to normalize
  82709. * @returns the new Vector3
  82710. */
  82711. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  82712. /**
  82713. * Sets the given vector "result" with the normalization of the given first vector
  82714. * @param vector defines the Vector3 to normalize
  82715. * @param result defines the Vector3 where to store the result
  82716. */
  82717. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  82718. /**
  82719. * Project a Vector3 onto screen space
  82720. * @param vector defines the Vector3 to project
  82721. * @param world defines the world matrix to use
  82722. * @param transform defines the transform (view x projection) matrix to use
  82723. * @param viewport defines the screen viewport to use
  82724. * @returns the new Vector3
  82725. */
  82726. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  82727. /** @hidden */
  82728. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  82729. /**
  82730. * Unproject from screen space to object space
  82731. * @param source defines the screen space Vector3 to use
  82732. * @param viewportWidth defines the current width of the viewport
  82733. * @param viewportHeight defines the current height of the viewport
  82734. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82735. * @param transform defines the transform (view x projection) matrix to use
  82736. * @returns the new Vector3
  82737. */
  82738. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  82739. /**
  82740. * Unproject from screen space to object space
  82741. * @param source defines the screen space Vector3 to use
  82742. * @param viewportWidth defines the current width of the viewport
  82743. * @param viewportHeight defines the current height of the viewport
  82744. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82745. * @param view defines the view matrix to use
  82746. * @param projection defines the projection matrix to use
  82747. * @returns the new Vector3
  82748. */
  82749. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  82750. /**
  82751. * Unproject from screen space to object space
  82752. * @param source defines the screen space Vector3 to use
  82753. * @param viewportWidth defines the current width of the viewport
  82754. * @param viewportHeight defines the current height of the viewport
  82755. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82756. * @param view defines the view matrix to use
  82757. * @param projection defines the projection matrix to use
  82758. * @param result defines the Vector3 where to store the result
  82759. */
  82760. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82761. /**
  82762. * Unproject from screen space to object space
  82763. * @param sourceX defines the screen space x coordinate to use
  82764. * @param sourceY defines the screen space y coordinate to use
  82765. * @param sourceZ defines the screen space z coordinate to use
  82766. * @param viewportWidth defines the current width of the viewport
  82767. * @param viewportHeight defines the current height of the viewport
  82768. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82769. * @param view defines the view matrix to use
  82770. * @param projection defines the projection matrix to use
  82771. * @param result defines the Vector3 where to store the result
  82772. */
  82773. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82774. /**
  82775. * Gets the minimal coordinate values between two Vector3
  82776. * @param left defines the first operand
  82777. * @param right defines the second operand
  82778. * @returns the new Vector3
  82779. */
  82780. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82781. /**
  82782. * Gets the maximal coordinate values between two Vector3
  82783. * @param left defines the first operand
  82784. * @param right defines the second operand
  82785. * @returns the new Vector3
  82786. */
  82787. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82788. /**
  82789. * Returns the distance between the vectors "value1" and "value2"
  82790. * @param value1 defines the first operand
  82791. * @param value2 defines the second operand
  82792. * @returns the distance
  82793. */
  82794. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82795. /**
  82796. * Returns the squared distance between the vectors "value1" and "value2"
  82797. * @param value1 defines the first operand
  82798. * @param value2 defines the second operand
  82799. * @returns the squared distance
  82800. */
  82801. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82802. /**
  82803. * Returns a new Vector3 located at the center between "value1" and "value2"
  82804. * @param value1 defines the first operand
  82805. * @param value2 defines the second operand
  82806. * @returns the new Vector3
  82807. */
  82808. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  82809. /**
  82810. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  82811. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  82812. * to something in order to rotate it from its local system to the given target system
  82813. * Note: axis1, axis2 and axis3 are normalized during this operation
  82814. * @param axis1 defines the first axis
  82815. * @param axis2 defines the second axis
  82816. * @param axis3 defines the third axis
  82817. * @returns a new Vector3
  82818. */
  82819. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  82820. /**
  82821. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  82822. * @param axis1 defines the first axis
  82823. * @param axis2 defines the second axis
  82824. * @param axis3 defines the third axis
  82825. * @param ref defines the Vector3 where to store the result
  82826. */
  82827. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  82828. }
  82829. /**
  82830. * Vector4 class created for EulerAngle class conversion to Quaternion
  82831. */
  82832. export class Vector4 {
  82833. /** x value of the vector */
  82834. x: number;
  82835. /** y value of the vector */
  82836. y: number;
  82837. /** z value of the vector */
  82838. z: number;
  82839. /** w value of the vector */
  82840. w: number;
  82841. /**
  82842. * Creates a Vector4 object from the given floats.
  82843. * @param x x value of the vector
  82844. * @param y y value of the vector
  82845. * @param z z value of the vector
  82846. * @param w w value of the vector
  82847. */
  82848. constructor(
  82849. /** x value of the vector */
  82850. x: number,
  82851. /** y value of the vector */
  82852. y: number,
  82853. /** z value of the vector */
  82854. z: number,
  82855. /** w value of the vector */
  82856. w: number);
  82857. /**
  82858. * Returns the string with the Vector4 coordinates.
  82859. * @returns a string containing all the vector values
  82860. */
  82861. toString(): string;
  82862. /**
  82863. * Returns the string "Vector4".
  82864. * @returns "Vector4"
  82865. */
  82866. getClassName(): string;
  82867. /**
  82868. * Returns the Vector4 hash code.
  82869. * @returns a unique hash code
  82870. */
  82871. getHashCode(): number;
  82872. /**
  82873. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  82874. * @returns the resulting array
  82875. */
  82876. asArray(): number[];
  82877. /**
  82878. * Populates the given array from the given index with the Vector4 coordinates.
  82879. * @param array array to populate
  82880. * @param index index of the array to start at (default: 0)
  82881. * @returns the Vector4.
  82882. */
  82883. toArray(array: FloatArray, index?: number): Vector4;
  82884. /**
  82885. * Update the current vector from an array
  82886. * @param array defines the destination array
  82887. * @param index defines the offset in the destination array
  82888. * @returns the current Vector3
  82889. */
  82890. fromArray(array: FloatArray, index?: number): Vector4;
  82891. /**
  82892. * Adds the given vector to the current Vector4.
  82893. * @param otherVector the vector to add
  82894. * @returns the updated Vector4.
  82895. */
  82896. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82897. /**
  82898. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  82899. * @param otherVector the vector to add
  82900. * @returns the resulting vector
  82901. */
  82902. add(otherVector: DeepImmutable<Vector4>): Vector4;
  82903. /**
  82904. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  82905. * @param otherVector the vector to add
  82906. * @param result the vector to store the result
  82907. * @returns the current Vector4.
  82908. */
  82909. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82910. /**
  82911. * Subtract in place the given vector from the current Vector4.
  82912. * @param otherVector the vector to subtract
  82913. * @returns the updated Vector4.
  82914. */
  82915. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82916. /**
  82917. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  82918. * @param otherVector the vector to add
  82919. * @returns the new vector with the result
  82920. */
  82921. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  82922. /**
  82923. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  82924. * @param otherVector the vector to subtract
  82925. * @param result the vector to store the result
  82926. * @returns the current Vector4.
  82927. */
  82928. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82929. /**
  82930. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82931. */
  82932. /**
  82933. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82934. * @param x value to subtract
  82935. * @param y value to subtract
  82936. * @param z value to subtract
  82937. * @param w value to subtract
  82938. * @returns new vector containing the result
  82939. */
  82940. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82941. /**
  82942. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82943. * @param x value to subtract
  82944. * @param y value to subtract
  82945. * @param z value to subtract
  82946. * @param w value to subtract
  82947. * @param result the vector to store the result in
  82948. * @returns the current Vector4.
  82949. */
  82950. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  82951. /**
  82952. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  82953. * @returns a new vector with the negated values
  82954. */
  82955. negate(): Vector4;
  82956. /**
  82957. * Negate this vector in place
  82958. * @returns this
  82959. */
  82960. negateInPlace(): Vector4;
  82961. /**
  82962. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  82963. * @param result defines the Vector3 object where to store the result
  82964. * @returns the current Vector4
  82965. */
  82966. negateToRef(result: Vector4): Vector4;
  82967. /**
  82968. * Multiplies the current Vector4 coordinates by scale (float).
  82969. * @param scale the number to scale with
  82970. * @returns the updated Vector4.
  82971. */
  82972. scaleInPlace(scale: number): Vector4;
  82973. /**
  82974. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  82975. * @param scale the number to scale with
  82976. * @returns a new vector with the result
  82977. */
  82978. scale(scale: number): Vector4;
  82979. /**
  82980. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  82981. * @param scale the number to scale with
  82982. * @param result a vector to store the result in
  82983. * @returns the current Vector4.
  82984. */
  82985. scaleToRef(scale: number, result: Vector4): Vector4;
  82986. /**
  82987. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  82988. * @param scale defines the scale factor
  82989. * @param result defines the Vector4 object where to store the result
  82990. * @returns the unmodified current Vector4
  82991. */
  82992. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  82993. /**
  82994. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  82995. * @param otherVector the vector to compare against
  82996. * @returns true if they are equal
  82997. */
  82998. equals(otherVector: DeepImmutable<Vector4>): boolean;
  82999. /**
  83000. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  83001. * @param otherVector vector to compare against
  83002. * @param epsilon (Default: very small number)
  83003. * @returns true if they are equal
  83004. */
  83005. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  83006. /**
  83007. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  83008. * @param x x value to compare against
  83009. * @param y y value to compare against
  83010. * @param z z value to compare against
  83011. * @param w w value to compare against
  83012. * @returns true if equal
  83013. */
  83014. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  83015. /**
  83016. * Multiplies in place the current Vector4 by the given one.
  83017. * @param otherVector vector to multiple with
  83018. * @returns the updated Vector4.
  83019. */
  83020. multiplyInPlace(otherVector: Vector4): Vector4;
  83021. /**
  83022. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  83023. * @param otherVector vector to multiple with
  83024. * @returns resulting new vector
  83025. */
  83026. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  83027. /**
  83028. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  83029. * @param otherVector vector to multiple with
  83030. * @param result vector to store the result
  83031. * @returns the current Vector4.
  83032. */
  83033. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83034. /**
  83035. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  83036. * @param x x value multiply with
  83037. * @param y y value multiply with
  83038. * @param z z value multiply with
  83039. * @param w w value multiply with
  83040. * @returns resulting new vector
  83041. */
  83042. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  83043. /**
  83044. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  83045. * @param otherVector vector to devide with
  83046. * @returns resulting new vector
  83047. */
  83048. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  83049. /**
  83050. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  83051. * @param otherVector vector to devide with
  83052. * @param result vector to store the result
  83053. * @returns the current Vector4.
  83054. */
  83055. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83056. /**
  83057. * Divides the current Vector3 coordinates by the given ones.
  83058. * @param otherVector vector to devide with
  83059. * @returns the updated Vector3.
  83060. */
  83061. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83062. /**
  83063. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  83064. * @param other defines the second operand
  83065. * @returns the current updated Vector4
  83066. */
  83067. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83068. /**
  83069. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  83070. * @param other defines the second operand
  83071. * @returns the current updated Vector4
  83072. */
  83073. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83074. /**
  83075. * Gets a new Vector4 from current Vector4 floored values
  83076. * @returns a new Vector4
  83077. */
  83078. floor(): Vector4;
  83079. /**
  83080. * Gets a new Vector4 from current Vector3 floored values
  83081. * @returns a new Vector4
  83082. */
  83083. fract(): Vector4;
  83084. /**
  83085. * Returns the Vector4 length (float).
  83086. * @returns the length
  83087. */
  83088. length(): number;
  83089. /**
  83090. * Returns the Vector4 squared length (float).
  83091. * @returns the length squared
  83092. */
  83093. lengthSquared(): number;
  83094. /**
  83095. * Normalizes in place the Vector4.
  83096. * @returns the updated Vector4.
  83097. */
  83098. normalize(): Vector4;
  83099. /**
  83100. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  83101. * @returns this converted to a new vector3
  83102. */
  83103. toVector3(): Vector3;
  83104. /**
  83105. * Returns a new Vector4 copied from the current one.
  83106. * @returns the new cloned vector
  83107. */
  83108. clone(): Vector4;
  83109. /**
  83110. * Updates the current Vector4 with the given one coordinates.
  83111. * @param source the source vector to copy from
  83112. * @returns the updated Vector4.
  83113. */
  83114. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  83115. /**
  83116. * Updates the current Vector4 coordinates with the given floats.
  83117. * @param x float to copy from
  83118. * @param y float to copy from
  83119. * @param z float to copy from
  83120. * @param w float to copy from
  83121. * @returns the updated Vector4.
  83122. */
  83123. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83124. /**
  83125. * Updates the current Vector4 coordinates with the given floats.
  83126. * @param x float to set from
  83127. * @param y float to set from
  83128. * @param z float to set from
  83129. * @param w float to set from
  83130. * @returns the updated Vector4.
  83131. */
  83132. set(x: number, y: number, z: number, w: number): Vector4;
  83133. /**
  83134. * Copies the given float to the current Vector3 coordinates
  83135. * @param v defines the x, y, z and w coordinates of the operand
  83136. * @returns the current updated Vector3
  83137. */
  83138. setAll(v: number): Vector4;
  83139. /**
  83140. * Returns a new Vector4 set from the starting index of the given array.
  83141. * @param array the array to pull values from
  83142. * @param offset the offset into the array to start at
  83143. * @returns the new vector
  83144. */
  83145. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  83146. /**
  83147. * Updates the given vector "result" from the starting index of the given array.
  83148. * @param array the array to pull values from
  83149. * @param offset the offset into the array to start at
  83150. * @param result the vector to store the result in
  83151. */
  83152. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  83153. /**
  83154. * Updates the given vector "result" from the starting index of the given Float32Array.
  83155. * @param array the array to pull values from
  83156. * @param offset the offset into the array to start at
  83157. * @param result the vector to store the result in
  83158. */
  83159. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  83160. /**
  83161. * Updates the given vector "result" coordinates from the given floats.
  83162. * @param x float to set from
  83163. * @param y float to set from
  83164. * @param z float to set from
  83165. * @param w float to set from
  83166. * @param result the vector to the floats in
  83167. */
  83168. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  83169. /**
  83170. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  83171. * @returns the new vector
  83172. */
  83173. static Zero(): Vector4;
  83174. /**
  83175. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  83176. * @returns the new vector
  83177. */
  83178. static One(): Vector4;
  83179. /**
  83180. * Returns a new normalized Vector4 from the given one.
  83181. * @param vector the vector to normalize
  83182. * @returns the vector
  83183. */
  83184. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  83185. /**
  83186. * Updates the given vector "result" from the normalization of the given one.
  83187. * @param vector the vector to normalize
  83188. * @param result the vector to store the result in
  83189. */
  83190. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  83191. /**
  83192. * Returns a vector with the minimum values from the left and right vectors
  83193. * @param left left vector to minimize
  83194. * @param right right vector to minimize
  83195. * @returns a new vector with the minimum of the left and right vector values
  83196. */
  83197. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83198. /**
  83199. * Returns a vector with the maximum values from the left and right vectors
  83200. * @param left left vector to maximize
  83201. * @param right right vector to maximize
  83202. * @returns a new vector with the maximum of the left and right vector values
  83203. */
  83204. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83205. /**
  83206. * Returns the distance (float) between the vectors "value1" and "value2".
  83207. * @param value1 value to calulate the distance between
  83208. * @param value2 value to calulate the distance between
  83209. * @return the distance between the two vectors
  83210. */
  83211. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83212. /**
  83213. * Returns the squared distance (float) between the vectors "value1" and "value2".
  83214. * @param value1 value to calulate the distance between
  83215. * @param value2 value to calulate the distance between
  83216. * @return the distance between the two vectors squared
  83217. */
  83218. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83219. /**
  83220. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  83221. * @param value1 value to calulate the center between
  83222. * @param value2 value to calulate the center between
  83223. * @return the center between the two vectors
  83224. */
  83225. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  83226. /**
  83227. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  83228. * This methods computes transformed normalized direction vectors only.
  83229. * @param vector the vector to transform
  83230. * @param transformation the transformation matrix to apply
  83231. * @returns the new vector
  83232. */
  83233. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  83234. /**
  83235. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  83236. * This methods computes transformed normalized direction vectors only.
  83237. * @param vector the vector to transform
  83238. * @param transformation the transformation matrix to apply
  83239. * @param result the vector to store the result in
  83240. */
  83241. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83242. /**
  83243. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  83244. * This methods computes transformed normalized direction vectors only.
  83245. * @param x value to transform
  83246. * @param y value to transform
  83247. * @param z value to transform
  83248. * @param w value to transform
  83249. * @param transformation the transformation matrix to apply
  83250. * @param result the vector to store the results in
  83251. */
  83252. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83253. /**
  83254. * Creates a new Vector4 from a Vector3
  83255. * @param source defines the source data
  83256. * @param w defines the 4th component (default is 0)
  83257. * @returns a new Vector4
  83258. */
  83259. static FromVector3(source: Vector3, w?: number): Vector4;
  83260. }
  83261. /**
  83262. * Class used to store quaternion data
  83263. * @see https://en.wikipedia.org/wiki/Quaternion
  83264. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  83265. */
  83266. export class Quaternion {
  83267. /** @hidden */
  83268. _x: number;
  83269. /** @hidden */
  83270. _y: number;
  83271. /** @hidden */
  83272. _z: number;
  83273. /** @hidden */
  83274. _w: number;
  83275. /** @hidden */
  83276. _isDirty: boolean;
  83277. /** Gets or sets the x coordinate */
  83278. get x(): number;
  83279. set x(value: number);
  83280. /** Gets or sets the y coordinate */
  83281. get y(): number;
  83282. set y(value: number);
  83283. /** Gets or sets the z coordinate */
  83284. get z(): number;
  83285. set z(value: number);
  83286. /** Gets or sets the w coordinate */
  83287. get w(): number;
  83288. set w(value: number);
  83289. /**
  83290. * Creates a new Quaternion from the given floats
  83291. * @param x defines the first component (0 by default)
  83292. * @param y defines the second component (0 by default)
  83293. * @param z defines the third component (0 by default)
  83294. * @param w defines the fourth component (1.0 by default)
  83295. */
  83296. constructor(x?: number, y?: number, z?: number, w?: number);
  83297. /**
  83298. * Gets a string representation for the current quaternion
  83299. * @returns a string with the Quaternion coordinates
  83300. */
  83301. toString(): string;
  83302. /**
  83303. * Gets the class name of the quaternion
  83304. * @returns the string "Quaternion"
  83305. */
  83306. getClassName(): string;
  83307. /**
  83308. * Gets a hash code for this quaternion
  83309. * @returns the quaternion hash code
  83310. */
  83311. getHashCode(): number;
  83312. /**
  83313. * Copy the quaternion to an array
  83314. * @returns a new array populated with 4 elements from the quaternion coordinates
  83315. */
  83316. asArray(): number[];
  83317. /**
  83318. * Check if two quaternions are equals
  83319. * @param otherQuaternion defines the second operand
  83320. * @return true if the current quaternion and the given one coordinates are strictly equals
  83321. */
  83322. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  83323. /**
  83324. * Gets a boolean if two quaternions are equals (using an epsilon value)
  83325. * @param otherQuaternion defines the other quaternion
  83326. * @param epsilon defines the minimal distance to consider equality
  83327. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  83328. */
  83329. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  83330. /**
  83331. * Clone the current quaternion
  83332. * @returns a new quaternion copied from the current one
  83333. */
  83334. clone(): Quaternion;
  83335. /**
  83336. * Copy a quaternion to the current one
  83337. * @param other defines the other quaternion
  83338. * @returns the updated current quaternion
  83339. */
  83340. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  83341. /**
  83342. * Updates the current quaternion with the given float coordinates
  83343. * @param x defines the x coordinate
  83344. * @param y defines the y coordinate
  83345. * @param z defines the z coordinate
  83346. * @param w defines the w coordinate
  83347. * @returns the updated current quaternion
  83348. */
  83349. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  83350. /**
  83351. * Updates the current quaternion from the given float coordinates
  83352. * @param x defines the x coordinate
  83353. * @param y defines the y coordinate
  83354. * @param z defines the z coordinate
  83355. * @param w defines the w coordinate
  83356. * @returns the updated current quaternion
  83357. */
  83358. set(x: number, y: number, z: number, w: number): Quaternion;
  83359. /**
  83360. * Adds two quaternions
  83361. * @param other defines the second operand
  83362. * @returns a new quaternion as the addition result of the given one and the current quaternion
  83363. */
  83364. add(other: DeepImmutable<Quaternion>): Quaternion;
  83365. /**
  83366. * Add a quaternion to the current one
  83367. * @param other defines the quaternion to add
  83368. * @returns the current quaternion
  83369. */
  83370. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  83371. /**
  83372. * Subtract two quaternions
  83373. * @param other defines the second operand
  83374. * @returns a new quaternion as the subtraction result of the given one from the current one
  83375. */
  83376. subtract(other: Quaternion): Quaternion;
  83377. /**
  83378. * Multiplies the current quaternion by a scale factor
  83379. * @param value defines the scale factor
  83380. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  83381. */
  83382. scale(value: number): Quaternion;
  83383. /**
  83384. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  83385. * @param scale defines the scale factor
  83386. * @param result defines the Quaternion object where to store the result
  83387. * @returns the unmodified current quaternion
  83388. */
  83389. scaleToRef(scale: number, result: Quaternion): Quaternion;
  83390. /**
  83391. * Multiplies in place the current quaternion by a scale factor
  83392. * @param value defines the scale factor
  83393. * @returns the current modified quaternion
  83394. */
  83395. scaleInPlace(value: number): Quaternion;
  83396. /**
  83397. * Scale the current quaternion values by a factor and add the result to a given quaternion
  83398. * @param scale defines the scale factor
  83399. * @param result defines the Quaternion object where to store the result
  83400. * @returns the unmodified current quaternion
  83401. */
  83402. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  83403. /**
  83404. * Multiplies two quaternions
  83405. * @param q1 defines the second operand
  83406. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  83407. */
  83408. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  83409. /**
  83410. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  83411. * @param q1 defines the second operand
  83412. * @param result defines the target quaternion
  83413. * @returns the current quaternion
  83414. */
  83415. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  83416. /**
  83417. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  83418. * @param q1 defines the second operand
  83419. * @returns the currentupdated quaternion
  83420. */
  83421. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  83422. /**
  83423. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  83424. * @param ref defines the target quaternion
  83425. * @returns the current quaternion
  83426. */
  83427. conjugateToRef(ref: Quaternion): Quaternion;
  83428. /**
  83429. * Conjugates in place (1-q) the current quaternion
  83430. * @returns the current updated quaternion
  83431. */
  83432. conjugateInPlace(): Quaternion;
  83433. /**
  83434. * Conjugates in place (1-q) the current quaternion
  83435. * @returns a new quaternion
  83436. */
  83437. conjugate(): Quaternion;
  83438. /**
  83439. * Gets length of current quaternion
  83440. * @returns the quaternion length (float)
  83441. */
  83442. length(): number;
  83443. /**
  83444. * Normalize in place the current quaternion
  83445. * @returns the current updated quaternion
  83446. */
  83447. normalize(): Quaternion;
  83448. /**
  83449. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  83450. * @param order is a reserved parameter and is ignore for now
  83451. * @returns a new Vector3 containing the Euler angles
  83452. */
  83453. toEulerAngles(order?: string): Vector3;
  83454. /**
  83455. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  83456. * @param result defines the vector which will be filled with the Euler angles
  83457. * @param order is a reserved parameter and is ignore for now
  83458. * @returns the current unchanged quaternion
  83459. */
  83460. toEulerAnglesToRef(result: Vector3): Quaternion;
  83461. /**
  83462. * Updates the given rotation matrix with the current quaternion values
  83463. * @param result defines the target matrix
  83464. * @returns the current unchanged quaternion
  83465. */
  83466. toRotationMatrix(result: Matrix): Quaternion;
  83467. /**
  83468. * Updates the current quaternion from the given rotation matrix values
  83469. * @param matrix defines the source matrix
  83470. * @returns the current updated quaternion
  83471. */
  83472. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  83473. /**
  83474. * Creates a new quaternion from a rotation matrix
  83475. * @param matrix defines the source matrix
  83476. * @returns a new quaternion created from the given rotation matrix values
  83477. */
  83478. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  83479. /**
  83480. * Updates the given quaternion with the given rotation matrix values
  83481. * @param matrix defines the source matrix
  83482. * @param result defines the target quaternion
  83483. */
  83484. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  83485. /**
  83486. * Returns the dot product (float) between the quaternions "left" and "right"
  83487. * @param left defines the left operand
  83488. * @param right defines the right operand
  83489. * @returns the dot product
  83490. */
  83491. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  83492. /**
  83493. * Checks if the two quaternions are close to each other
  83494. * @param quat0 defines the first quaternion to check
  83495. * @param quat1 defines the second quaternion to check
  83496. * @returns true if the two quaternions are close to each other
  83497. */
  83498. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  83499. /**
  83500. * Creates an empty quaternion
  83501. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  83502. */
  83503. static Zero(): Quaternion;
  83504. /**
  83505. * Inverse a given quaternion
  83506. * @param q defines the source quaternion
  83507. * @returns a new quaternion as the inverted current quaternion
  83508. */
  83509. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  83510. /**
  83511. * Inverse a given quaternion
  83512. * @param q defines the source quaternion
  83513. * @param result the quaternion the result will be stored in
  83514. * @returns the result quaternion
  83515. */
  83516. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  83517. /**
  83518. * Creates an identity quaternion
  83519. * @returns the identity quaternion
  83520. */
  83521. static Identity(): Quaternion;
  83522. /**
  83523. * Gets a boolean indicating if the given quaternion is identity
  83524. * @param quaternion defines the quaternion to check
  83525. * @returns true if the quaternion is identity
  83526. */
  83527. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  83528. /**
  83529. * Creates a quaternion from a rotation around an axis
  83530. * @param axis defines the axis to use
  83531. * @param angle defines the angle to use
  83532. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  83533. */
  83534. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  83535. /**
  83536. * Creates a rotation around an axis and stores it into the given quaternion
  83537. * @param axis defines the axis to use
  83538. * @param angle defines the angle to use
  83539. * @param result defines the target quaternion
  83540. * @returns the target quaternion
  83541. */
  83542. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  83543. /**
  83544. * Creates a new quaternion from data stored into an array
  83545. * @param array defines the data source
  83546. * @param offset defines the offset in the source array where the data starts
  83547. * @returns a new quaternion
  83548. */
  83549. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  83550. /**
  83551. * Updates the given quaternion "result" from the starting index of the given array.
  83552. * @param array the array to pull values from
  83553. * @param offset the offset into the array to start at
  83554. * @param result the quaternion to store the result in
  83555. */
  83556. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  83557. /**
  83558. * Create a quaternion from Euler rotation angles
  83559. * @param x Pitch
  83560. * @param y Yaw
  83561. * @param z Roll
  83562. * @returns the new Quaternion
  83563. */
  83564. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  83565. /**
  83566. * Updates a quaternion from Euler rotation angles
  83567. * @param x Pitch
  83568. * @param y Yaw
  83569. * @param z Roll
  83570. * @param result the quaternion to store the result
  83571. * @returns the updated quaternion
  83572. */
  83573. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  83574. /**
  83575. * Create a quaternion from Euler rotation vector
  83576. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83577. * @returns the new Quaternion
  83578. */
  83579. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  83580. /**
  83581. * Updates a quaternion from Euler rotation vector
  83582. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83583. * @param result the quaternion to store the result
  83584. * @returns the updated quaternion
  83585. */
  83586. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  83587. /**
  83588. * Creates a new quaternion from the given Euler float angles (y, x, z)
  83589. * @param yaw defines the rotation around Y axis
  83590. * @param pitch defines the rotation around X axis
  83591. * @param roll defines the rotation around Z axis
  83592. * @returns the new quaternion
  83593. */
  83594. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  83595. /**
  83596. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  83597. * @param yaw defines the rotation around Y axis
  83598. * @param pitch defines the rotation around X axis
  83599. * @param roll defines the rotation around Z axis
  83600. * @param result defines the target quaternion
  83601. */
  83602. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  83603. /**
  83604. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  83605. * @param alpha defines the rotation around first axis
  83606. * @param beta defines the rotation around second axis
  83607. * @param gamma defines the rotation around third axis
  83608. * @returns the new quaternion
  83609. */
  83610. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  83611. /**
  83612. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  83613. * @param alpha defines the rotation around first axis
  83614. * @param beta defines the rotation around second axis
  83615. * @param gamma defines the rotation around third axis
  83616. * @param result defines the target quaternion
  83617. */
  83618. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  83619. /**
  83620. * 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)
  83621. * @param axis1 defines the first axis
  83622. * @param axis2 defines the second axis
  83623. * @param axis3 defines the third axis
  83624. * @returns the new quaternion
  83625. */
  83626. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  83627. /**
  83628. * 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
  83629. * @param axis1 defines the first axis
  83630. * @param axis2 defines the second axis
  83631. * @param axis3 defines the third axis
  83632. * @param ref defines the target quaternion
  83633. */
  83634. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  83635. /**
  83636. * Interpolates between two quaternions
  83637. * @param left defines first quaternion
  83638. * @param right defines second quaternion
  83639. * @param amount defines the gradient to use
  83640. * @returns the new interpolated quaternion
  83641. */
  83642. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83643. /**
  83644. * Interpolates between two quaternions and stores it into a target quaternion
  83645. * @param left defines first quaternion
  83646. * @param right defines second quaternion
  83647. * @param amount defines the gradient to use
  83648. * @param result defines the target quaternion
  83649. */
  83650. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  83651. /**
  83652. * Interpolate between two quaternions using Hermite interpolation
  83653. * @param value1 defines first quaternion
  83654. * @param tangent1 defines the incoming tangent
  83655. * @param value2 defines second quaternion
  83656. * @param tangent2 defines the outgoing tangent
  83657. * @param amount defines the target quaternion
  83658. * @returns the new interpolated quaternion
  83659. */
  83660. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83661. }
  83662. /**
  83663. * Class used to store matrix data (4x4)
  83664. */
  83665. export class Matrix {
  83666. /**
  83667. * Gets the precision of matrix computations
  83668. */
  83669. static get Use64Bits(): boolean;
  83670. private static _updateFlagSeed;
  83671. private static _identityReadOnly;
  83672. private _isIdentity;
  83673. private _isIdentityDirty;
  83674. private _isIdentity3x2;
  83675. private _isIdentity3x2Dirty;
  83676. /**
  83677. * Gets the update flag of the matrix which is an unique number for the matrix.
  83678. * It will be incremented every time the matrix data change.
  83679. * You can use it to speed the comparison between two versions of the same matrix.
  83680. */
  83681. updateFlag: number;
  83682. private readonly _m;
  83683. /**
  83684. * Gets the internal data of the matrix
  83685. */
  83686. get m(): DeepImmutable<Float32Array | Array<number>>;
  83687. /** @hidden */
  83688. _markAsUpdated(): void;
  83689. /** @hidden */
  83690. private _updateIdentityStatus;
  83691. /**
  83692. * Creates an empty matrix (filled with zeros)
  83693. */
  83694. constructor();
  83695. /**
  83696. * Check if the current matrix is identity
  83697. * @returns true is the matrix is the identity matrix
  83698. */
  83699. isIdentity(): boolean;
  83700. /**
  83701. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  83702. * @returns true is the matrix is the identity matrix
  83703. */
  83704. isIdentityAs3x2(): boolean;
  83705. /**
  83706. * Gets the determinant of the matrix
  83707. * @returns the matrix determinant
  83708. */
  83709. determinant(): number;
  83710. /**
  83711. * Returns the matrix as a Float32Array or Array<number>
  83712. * @returns the matrix underlying array
  83713. */
  83714. toArray(): DeepImmutable<Float32Array | Array<number>>;
  83715. /**
  83716. * Returns the matrix as a Float32Array or Array<number>
  83717. * @returns the matrix underlying array.
  83718. */
  83719. asArray(): DeepImmutable<Float32Array | Array<number>>;
  83720. /**
  83721. * Inverts the current matrix in place
  83722. * @returns the current inverted matrix
  83723. */
  83724. invert(): Matrix;
  83725. /**
  83726. * Sets all the matrix elements to zero
  83727. * @returns the current matrix
  83728. */
  83729. reset(): Matrix;
  83730. /**
  83731. * Adds the current matrix with a second one
  83732. * @param other defines the matrix to add
  83733. * @returns a new matrix as the addition of the current matrix and the given one
  83734. */
  83735. add(other: DeepImmutable<Matrix>): Matrix;
  83736. /**
  83737. * Sets the given matrix "result" to the addition of the current matrix and the given one
  83738. * @param other defines the matrix to add
  83739. * @param result defines the target matrix
  83740. * @returns the current matrix
  83741. */
  83742. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83743. /**
  83744. * Adds in place the given matrix to the current matrix
  83745. * @param other defines the second operand
  83746. * @returns the current updated matrix
  83747. */
  83748. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  83749. /**
  83750. * Sets the given matrix to the current inverted Matrix
  83751. * @param other defines the target matrix
  83752. * @returns the unmodified current matrix
  83753. */
  83754. invertToRef(other: Matrix): Matrix;
  83755. /**
  83756. * add a value at the specified position in the current Matrix
  83757. * @param index the index of the value within the matrix. between 0 and 15.
  83758. * @param value the value to be added
  83759. * @returns the current updated matrix
  83760. */
  83761. addAtIndex(index: number, value: number): Matrix;
  83762. /**
  83763. * mutiply the specified position in the current Matrix by a value
  83764. * @param index the index of the value within the matrix. between 0 and 15.
  83765. * @param value the value to be added
  83766. * @returns the current updated matrix
  83767. */
  83768. multiplyAtIndex(index: number, value: number): Matrix;
  83769. /**
  83770. * Inserts the translation vector (using 3 floats) in the current matrix
  83771. * @param x defines the 1st component of the translation
  83772. * @param y defines the 2nd component of the translation
  83773. * @param z defines the 3rd component of the translation
  83774. * @returns the current updated matrix
  83775. */
  83776. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83777. /**
  83778. * Adds the translation vector (using 3 floats) in the current matrix
  83779. * @param x defines the 1st component of the translation
  83780. * @param y defines the 2nd component of the translation
  83781. * @param z defines the 3rd component of the translation
  83782. * @returns the current updated matrix
  83783. */
  83784. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83785. /**
  83786. * Inserts the translation vector in the current matrix
  83787. * @param vector3 defines the translation to insert
  83788. * @returns the current updated matrix
  83789. */
  83790. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  83791. /**
  83792. * Gets the translation value of the current matrix
  83793. * @returns a new Vector3 as the extracted translation from the matrix
  83794. */
  83795. getTranslation(): Vector3;
  83796. /**
  83797. * Fill a Vector3 with the extracted translation from the matrix
  83798. * @param result defines the Vector3 where to store the translation
  83799. * @returns the current matrix
  83800. */
  83801. getTranslationToRef(result: Vector3): Matrix;
  83802. /**
  83803. * Remove rotation and scaling part from the matrix
  83804. * @returns the updated matrix
  83805. */
  83806. removeRotationAndScaling(): Matrix;
  83807. /**
  83808. * Multiply two matrices
  83809. * @param other defines the second operand
  83810. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  83811. */
  83812. multiply(other: DeepImmutable<Matrix>): Matrix;
  83813. /**
  83814. * Copy the current matrix from the given one
  83815. * @param other defines the source matrix
  83816. * @returns the current updated matrix
  83817. */
  83818. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  83819. /**
  83820. * Populates the given array from the starting index with the current matrix values
  83821. * @param array defines the target array
  83822. * @param offset defines the offset in the target array where to start storing values
  83823. * @returns the current matrix
  83824. */
  83825. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  83826. /**
  83827. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  83828. * @param other defines the second operand
  83829. * @param result defines the matrix where to store the multiplication
  83830. * @returns the current matrix
  83831. */
  83832. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83833. /**
  83834. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  83835. * @param other defines the second operand
  83836. * @param result defines the array where to store the multiplication
  83837. * @param offset defines the offset in the target array where to start storing values
  83838. * @returns the current matrix
  83839. */
  83840. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  83841. /**
  83842. * Check equality between this matrix and a second one
  83843. * @param value defines the second matrix to compare
  83844. * @returns true is the current matrix and the given one values are strictly equal
  83845. */
  83846. equals(value: DeepImmutable<Matrix>): boolean;
  83847. /**
  83848. * Clone the current matrix
  83849. * @returns a new matrix from the current matrix
  83850. */
  83851. clone(): Matrix;
  83852. /**
  83853. * Returns the name of the current matrix class
  83854. * @returns the string "Matrix"
  83855. */
  83856. getClassName(): string;
  83857. /**
  83858. * Gets the hash code of the current matrix
  83859. * @returns the hash code
  83860. */
  83861. getHashCode(): number;
  83862. /**
  83863. * Decomposes the current Matrix into a translation, rotation and scaling components
  83864. * @param scale defines the scale vector3 given as a reference to update
  83865. * @param rotation defines the rotation quaternion given as a reference to update
  83866. * @param translation defines the translation vector3 given as a reference to update
  83867. * @returns true if operation was successful
  83868. */
  83869. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  83870. /**
  83871. * Gets specific row of the matrix
  83872. * @param index defines the number of the row to get
  83873. * @returns the index-th row of the current matrix as a new Vector4
  83874. */
  83875. getRow(index: number): Nullable<Vector4>;
  83876. /**
  83877. * Sets the index-th row of the current matrix to the vector4 values
  83878. * @param index defines the number of the row to set
  83879. * @param row defines the target vector4
  83880. * @returns the updated current matrix
  83881. */
  83882. setRow(index: number, row: Vector4): Matrix;
  83883. /**
  83884. * Compute the transpose of the matrix
  83885. * @returns the new transposed matrix
  83886. */
  83887. transpose(): Matrix;
  83888. /**
  83889. * Compute the transpose of the matrix and store it in a given matrix
  83890. * @param result defines the target matrix
  83891. * @returns the current matrix
  83892. */
  83893. transposeToRef(result: Matrix): Matrix;
  83894. /**
  83895. * Sets the index-th row of the current matrix with the given 4 x float values
  83896. * @param index defines the row index
  83897. * @param x defines the x component to set
  83898. * @param y defines the y component to set
  83899. * @param z defines the z component to set
  83900. * @param w defines the w component to set
  83901. * @returns the updated current matrix
  83902. */
  83903. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  83904. /**
  83905. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  83906. * @param scale defines the scale factor
  83907. * @returns a new matrix
  83908. */
  83909. scale(scale: number): Matrix;
  83910. /**
  83911. * Scale the current matrix values by a factor to a given result matrix
  83912. * @param scale defines the scale factor
  83913. * @param result defines the matrix to store the result
  83914. * @returns the current matrix
  83915. */
  83916. scaleToRef(scale: number, result: Matrix): Matrix;
  83917. /**
  83918. * Scale the current matrix values by a factor and add the result to a given matrix
  83919. * @param scale defines the scale factor
  83920. * @param result defines the Matrix to store the result
  83921. * @returns the current matrix
  83922. */
  83923. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  83924. /**
  83925. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  83926. * @param ref matrix to store the result
  83927. */
  83928. toNormalMatrix(ref: Matrix): void;
  83929. /**
  83930. * Gets only rotation part of the current matrix
  83931. * @returns a new matrix sets to the extracted rotation matrix from the current one
  83932. */
  83933. getRotationMatrix(): Matrix;
  83934. /**
  83935. * Extracts the rotation matrix from the current one and sets it as the given "result"
  83936. * @param result defines the target matrix to store data to
  83937. * @returns the current matrix
  83938. */
  83939. getRotationMatrixToRef(result: Matrix): Matrix;
  83940. /**
  83941. * Toggles model matrix from being right handed to left handed in place and vice versa
  83942. */
  83943. toggleModelMatrixHandInPlace(): void;
  83944. /**
  83945. * Toggles projection matrix from being right handed to left handed in place and vice versa
  83946. */
  83947. toggleProjectionMatrixHandInPlace(): void;
  83948. /**
  83949. * Creates a matrix from an array
  83950. * @param array defines the source array
  83951. * @param offset defines an offset in the source array
  83952. * @returns a new Matrix set from the starting index of the given array
  83953. */
  83954. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  83955. /**
  83956. * Copy the content of an array into a given matrix
  83957. * @param array defines the source array
  83958. * @param offset defines an offset in the source array
  83959. * @param result defines the target matrix
  83960. */
  83961. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  83962. /**
  83963. * Stores an array into a matrix after having multiplied each component by a given factor
  83964. * @param array defines the source array
  83965. * @param offset defines the offset in the source array
  83966. * @param scale defines the scaling factor
  83967. * @param result defines the target matrix
  83968. */
  83969. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  83970. /**
  83971. * Gets an identity matrix that must not be updated
  83972. */
  83973. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  83974. /**
  83975. * Stores a list of values (16) inside a given matrix
  83976. * @param initialM11 defines 1st value of 1st row
  83977. * @param initialM12 defines 2nd value of 1st row
  83978. * @param initialM13 defines 3rd value of 1st row
  83979. * @param initialM14 defines 4th value of 1st row
  83980. * @param initialM21 defines 1st value of 2nd row
  83981. * @param initialM22 defines 2nd value of 2nd row
  83982. * @param initialM23 defines 3rd value of 2nd row
  83983. * @param initialM24 defines 4th value of 2nd row
  83984. * @param initialM31 defines 1st value of 3rd row
  83985. * @param initialM32 defines 2nd value of 3rd row
  83986. * @param initialM33 defines 3rd value of 3rd row
  83987. * @param initialM34 defines 4th value of 3rd row
  83988. * @param initialM41 defines 1st value of 4th row
  83989. * @param initialM42 defines 2nd value of 4th row
  83990. * @param initialM43 defines 3rd value of 4th row
  83991. * @param initialM44 defines 4th value of 4th row
  83992. * @param result defines the target matrix
  83993. */
  83994. 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;
  83995. /**
  83996. * Creates new matrix from a list of values (16)
  83997. * @param initialM11 defines 1st value of 1st row
  83998. * @param initialM12 defines 2nd value of 1st row
  83999. * @param initialM13 defines 3rd value of 1st row
  84000. * @param initialM14 defines 4th value of 1st row
  84001. * @param initialM21 defines 1st value of 2nd row
  84002. * @param initialM22 defines 2nd value of 2nd row
  84003. * @param initialM23 defines 3rd value of 2nd row
  84004. * @param initialM24 defines 4th value of 2nd row
  84005. * @param initialM31 defines 1st value of 3rd row
  84006. * @param initialM32 defines 2nd value of 3rd row
  84007. * @param initialM33 defines 3rd value of 3rd row
  84008. * @param initialM34 defines 4th value of 3rd row
  84009. * @param initialM41 defines 1st value of 4th row
  84010. * @param initialM42 defines 2nd value of 4th row
  84011. * @param initialM43 defines 3rd value of 4th row
  84012. * @param initialM44 defines 4th value of 4th row
  84013. * @returns the new matrix
  84014. */
  84015. 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;
  84016. /**
  84017. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84018. * @param scale defines the scale vector3
  84019. * @param rotation defines the rotation quaternion
  84020. * @param translation defines the translation vector3
  84021. * @returns a new matrix
  84022. */
  84023. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  84024. /**
  84025. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84026. * @param scale defines the scale vector3
  84027. * @param rotation defines the rotation quaternion
  84028. * @param translation defines the translation vector3
  84029. * @param result defines the target matrix
  84030. */
  84031. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  84032. /**
  84033. * Creates a new identity matrix
  84034. * @returns a new identity matrix
  84035. */
  84036. static Identity(): Matrix;
  84037. /**
  84038. * Creates a new identity matrix and stores the result in a given matrix
  84039. * @param result defines the target matrix
  84040. */
  84041. static IdentityToRef(result: Matrix): void;
  84042. /**
  84043. * Creates a new zero matrix
  84044. * @returns a new zero matrix
  84045. */
  84046. static Zero(): Matrix;
  84047. /**
  84048. * Creates a new rotation matrix for "angle" radians around the X axis
  84049. * @param angle defines the angle (in radians) to use
  84050. * @return the new matrix
  84051. */
  84052. static RotationX(angle: number): Matrix;
  84053. /**
  84054. * Creates a new matrix as the invert of a given matrix
  84055. * @param source defines the source matrix
  84056. * @returns the new matrix
  84057. */
  84058. static Invert(source: DeepImmutable<Matrix>): Matrix;
  84059. /**
  84060. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  84061. * @param angle defines the angle (in radians) to use
  84062. * @param result defines the target matrix
  84063. */
  84064. static RotationXToRef(angle: number, result: Matrix): void;
  84065. /**
  84066. * Creates a new rotation matrix for "angle" radians around the Y axis
  84067. * @param angle defines the angle (in radians) to use
  84068. * @return the new matrix
  84069. */
  84070. static RotationY(angle: number): Matrix;
  84071. /**
  84072. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  84073. * @param angle defines the angle (in radians) to use
  84074. * @param result defines the target matrix
  84075. */
  84076. static RotationYToRef(angle: number, result: Matrix): void;
  84077. /**
  84078. * Creates a new rotation matrix for "angle" radians around the Z axis
  84079. * @param angle defines the angle (in radians) to use
  84080. * @return the new matrix
  84081. */
  84082. static RotationZ(angle: number): Matrix;
  84083. /**
  84084. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  84085. * @param angle defines the angle (in radians) to use
  84086. * @param result defines the target matrix
  84087. */
  84088. static RotationZToRef(angle: number, result: Matrix): void;
  84089. /**
  84090. * Creates a new rotation matrix for "angle" radians around the given axis
  84091. * @param axis defines the axis to use
  84092. * @param angle defines the angle (in radians) to use
  84093. * @return the new matrix
  84094. */
  84095. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  84096. /**
  84097. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  84098. * @param axis defines the axis to use
  84099. * @param angle defines the angle (in radians) to use
  84100. * @param result defines the target matrix
  84101. */
  84102. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  84103. /**
  84104. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  84105. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  84106. * @param from defines the vector to align
  84107. * @param to defines the vector to align to
  84108. * @param result defines the target matrix
  84109. */
  84110. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  84111. /**
  84112. * Creates a rotation matrix
  84113. * @param yaw defines the yaw angle in radians (Y axis)
  84114. * @param pitch defines the pitch angle in radians (X axis)
  84115. * @param roll defines the roll angle in radians (Z axis)
  84116. * @returns the new rotation matrix
  84117. */
  84118. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  84119. /**
  84120. * Creates a rotation matrix and stores it in a given matrix
  84121. * @param yaw defines the yaw angle in radians (Y axis)
  84122. * @param pitch defines the pitch angle in radians (X axis)
  84123. * @param roll defines the roll angle in radians (Z axis)
  84124. * @param result defines the target matrix
  84125. */
  84126. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  84127. /**
  84128. * Creates a scaling matrix
  84129. * @param x defines the scale factor on X axis
  84130. * @param y defines the scale factor on Y axis
  84131. * @param z defines the scale factor on Z axis
  84132. * @returns the new matrix
  84133. */
  84134. static Scaling(x: number, y: number, z: number): Matrix;
  84135. /**
  84136. * Creates a scaling matrix and stores it in a given matrix
  84137. * @param x defines the scale factor on X axis
  84138. * @param y defines the scale factor on Y axis
  84139. * @param z defines the scale factor on Z axis
  84140. * @param result defines the target matrix
  84141. */
  84142. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  84143. /**
  84144. * Creates a translation matrix
  84145. * @param x defines the translation on X axis
  84146. * @param y defines the translation on Y axis
  84147. * @param z defines the translationon Z axis
  84148. * @returns the new matrix
  84149. */
  84150. static Translation(x: number, y: number, z: number): Matrix;
  84151. /**
  84152. * Creates a translation matrix and stores it in a given matrix
  84153. * @param x defines the translation on X axis
  84154. * @param y defines the translation on Y axis
  84155. * @param z defines the translationon Z axis
  84156. * @param result defines the target matrix
  84157. */
  84158. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  84159. /**
  84160. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84161. * @param startValue defines the start value
  84162. * @param endValue defines the end value
  84163. * @param gradient defines the gradient factor
  84164. * @returns the new matrix
  84165. */
  84166. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84167. /**
  84168. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84169. * @param startValue defines the start value
  84170. * @param endValue defines the end value
  84171. * @param gradient defines the gradient factor
  84172. * @param result defines the Matrix object where to store data
  84173. */
  84174. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84175. /**
  84176. * Builds a new matrix whose values are computed by:
  84177. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84178. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84179. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84180. * @param startValue defines the first matrix
  84181. * @param endValue defines the second matrix
  84182. * @param gradient defines the gradient between the two matrices
  84183. * @returns the new matrix
  84184. */
  84185. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84186. /**
  84187. * Update a matrix to values which are computed by:
  84188. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84189. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84190. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84191. * @param startValue defines the first matrix
  84192. * @param endValue defines the second matrix
  84193. * @param gradient defines the gradient between the two matrices
  84194. * @param result defines the target matrix
  84195. */
  84196. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84197. /**
  84198. * 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"
  84199. * This function works in left handed mode
  84200. * @param eye defines the final position of the entity
  84201. * @param target defines where the entity should look at
  84202. * @param up defines the up vector for the entity
  84203. * @returns the new matrix
  84204. */
  84205. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84206. /**
  84207. * 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".
  84208. * This function works in left handed mode
  84209. * @param eye defines the final position of the entity
  84210. * @param target defines where the entity should look at
  84211. * @param up defines the up vector for the entity
  84212. * @param result defines the target matrix
  84213. */
  84214. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84215. /**
  84216. * 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"
  84217. * This function works in right handed mode
  84218. * @param eye defines the final position of the entity
  84219. * @param target defines where the entity should look at
  84220. * @param up defines the up vector for the entity
  84221. * @returns the new matrix
  84222. */
  84223. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84224. /**
  84225. * 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".
  84226. * This function works in right handed mode
  84227. * @param eye defines the final position of the entity
  84228. * @param target defines where the entity should look at
  84229. * @param up defines the up vector for the entity
  84230. * @param result defines the target matrix
  84231. */
  84232. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84233. /**
  84234. * Create a left-handed orthographic projection matrix
  84235. * @param width defines the viewport width
  84236. * @param height defines the viewport height
  84237. * @param znear defines the near clip plane
  84238. * @param zfar defines the far clip plane
  84239. * @returns a new matrix as a left-handed orthographic projection matrix
  84240. */
  84241. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84242. /**
  84243. * Store a left-handed orthographic projection to a given matrix
  84244. * @param width defines the viewport width
  84245. * @param height defines the viewport height
  84246. * @param znear defines the near clip plane
  84247. * @param zfar defines the far clip plane
  84248. * @param result defines the target matrix
  84249. */
  84250. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  84251. /**
  84252. * Create a left-handed orthographic projection matrix
  84253. * @param left defines the viewport left coordinate
  84254. * @param right defines the viewport right coordinate
  84255. * @param bottom defines the viewport bottom coordinate
  84256. * @param top defines the viewport top coordinate
  84257. * @param znear defines the near clip plane
  84258. * @param zfar defines the far clip plane
  84259. * @returns a new matrix as a left-handed orthographic projection matrix
  84260. */
  84261. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84262. /**
  84263. * Stores a left-handed orthographic projection into a given matrix
  84264. * @param left defines the viewport left coordinate
  84265. * @param right defines the viewport right coordinate
  84266. * @param bottom defines the viewport bottom coordinate
  84267. * @param top defines the viewport top coordinate
  84268. * @param znear defines the near clip plane
  84269. * @param zfar defines the far clip plane
  84270. * @param result defines the target matrix
  84271. */
  84272. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84273. /**
  84274. * Creates a right-handed orthographic projection matrix
  84275. * @param left defines the viewport left coordinate
  84276. * @param right defines the viewport right coordinate
  84277. * @param bottom defines the viewport bottom coordinate
  84278. * @param top defines the viewport top coordinate
  84279. * @param znear defines the near clip plane
  84280. * @param zfar defines the far clip plane
  84281. * @returns a new matrix as a right-handed orthographic projection matrix
  84282. */
  84283. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84284. /**
  84285. * Stores a right-handed orthographic projection into a given matrix
  84286. * @param left defines the viewport left coordinate
  84287. * @param right defines the viewport right coordinate
  84288. * @param bottom defines the viewport bottom coordinate
  84289. * @param top defines the viewport top coordinate
  84290. * @param znear defines the near clip plane
  84291. * @param zfar defines the far clip plane
  84292. * @param result defines the target matrix
  84293. */
  84294. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84295. /**
  84296. * Creates a left-handed perspective projection matrix
  84297. * @param width defines the viewport width
  84298. * @param height defines the viewport height
  84299. * @param znear defines the near clip plane
  84300. * @param zfar defines the far clip plane
  84301. * @returns a new matrix as a left-handed perspective projection matrix
  84302. */
  84303. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84304. /**
  84305. * Creates a left-handed perspective projection matrix
  84306. * @param fov defines the horizontal field of view
  84307. * @param aspect defines the aspect ratio
  84308. * @param znear defines the near clip plane
  84309. * @param zfar defines the far clip plane
  84310. * @returns a new matrix as a left-handed perspective projection matrix
  84311. */
  84312. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84313. /**
  84314. * Stores a left-handed perspective projection into a given matrix
  84315. * @param fov defines the horizontal field of view
  84316. * @param aspect defines the aspect ratio
  84317. * @param znear defines the near clip plane
  84318. * @param zfar defines the far clip plane
  84319. * @param result defines the target matrix
  84320. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84321. */
  84322. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84323. /**
  84324. * Stores a left-handed perspective projection into a given matrix with depth reversed
  84325. * @param fov defines the horizontal field of view
  84326. * @param aspect defines the aspect ratio
  84327. * @param znear defines the near clip plane
  84328. * @param zfar not used as infinity is used as far clip
  84329. * @param result defines the target matrix
  84330. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84331. */
  84332. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84333. /**
  84334. * Creates a right-handed perspective projection matrix
  84335. * @param fov defines the horizontal field of view
  84336. * @param aspect defines the aspect ratio
  84337. * @param znear defines the near clip plane
  84338. * @param zfar defines the far clip plane
  84339. * @returns a new matrix as a right-handed perspective projection matrix
  84340. */
  84341. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84342. /**
  84343. * Stores a right-handed perspective projection into a given matrix
  84344. * @param fov defines the horizontal field of view
  84345. * @param aspect defines the aspect ratio
  84346. * @param znear defines the near clip plane
  84347. * @param zfar defines the far clip plane
  84348. * @param result defines the target matrix
  84349. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84350. */
  84351. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84352. /**
  84353. * Stores a right-handed perspective projection into a given matrix
  84354. * @param fov defines the horizontal field of view
  84355. * @param aspect defines the aspect ratio
  84356. * @param znear defines the near clip plane
  84357. * @param zfar not used as infinity is used as far clip
  84358. * @param result defines the target matrix
  84359. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84360. */
  84361. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84362. /**
  84363. * Stores a perspective projection for WebVR info a given matrix
  84364. * @param fov defines the field of view
  84365. * @param znear defines the near clip plane
  84366. * @param zfar defines the far clip plane
  84367. * @param result defines the target matrix
  84368. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  84369. */
  84370. static PerspectiveFovWebVRToRef(fov: {
  84371. upDegrees: number;
  84372. downDegrees: number;
  84373. leftDegrees: number;
  84374. rightDegrees: number;
  84375. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  84376. /**
  84377. * Computes a complete transformation matrix
  84378. * @param viewport defines the viewport to use
  84379. * @param world defines the world matrix
  84380. * @param view defines the view matrix
  84381. * @param projection defines the projection matrix
  84382. * @param zmin defines the near clip plane
  84383. * @param zmax defines the far clip plane
  84384. * @returns the transformation matrix
  84385. */
  84386. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  84387. /**
  84388. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  84389. * @param matrix defines the matrix to use
  84390. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  84391. */
  84392. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  84393. /**
  84394. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  84395. * @param matrix defines the matrix to use
  84396. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  84397. */
  84398. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  84399. /**
  84400. * Compute the transpose of a given matrix
  84401. * @param matrix defines the matrix to transpose
  84402. * @returns the new matrix
  84403. */
  84404. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  84405. /**
  84406. * Compute the transpose of a matrix and store it in a target matrix
  84407. * @param matrix defines the matrix to transpose
  84408. * @param result defines the target matrix
  84409. */
  84410. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  84411. /**
  84412. * Computes a reflection matrix from a plane
  84413. * @param plane defines the reflection plane
  84414. * @returns a new matrix
  84415. */
  84416. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  84417. /**
  84418. * Computes a reflection matrix from a plane
  84419. * @param plane defines the reflection plane
  84420. * @param result defines the target matrix
  84421. */
  84422. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  84423. /**
  84424. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  84425. * @param xaxis defines the value of the 1st axis
  84426. * @param yaxis defines the value of the 2nd axis
  84427. * @param zaxis defines the value of the 3rd axis
  84428. * @param result defines the target matrix
  84429. */
  84430. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  84431. /**
  84432. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  84433. * @param quat defines the quaternion to use
  84434. * @param result defines the target matrix
  84435. */
  84436. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  84437. }
  84438. /**
  84439. * @hidden
  84440. */
  84441. export class TmpVectors {
  84442. static Vector2: Vector2[];
  84443. static Vector3: Vector3[];
  84444. static Vector4: Vector4[];
  84445. static Quaternion: Quaternion[];
  84446. static Matrix: Matrix[];
  84447. }
  84448. }
  84449. declare module BABYLON {
  84450. /**
  84451. * Defines potential orientation for back face culling
  84452. */
  84453. export enum Orientation {
  84454. /**
  84455. * Clockwise
  84456. */
  84457. CW = 0,
  84458. /** Counter clockwise */
  84459. CCW = 1
  84460. }
  84461. /** Class used to represent a Bezier curve */
  84462. export class BezierCurve {
  84463. /**
  84464. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  84465. * @param t defines the time
  84466. * @param x1 defines the left coordinate on X axis
  84467. * @param y1 defines the left coordinate on Y axis
  84468. * @param x2 defines the right coordinate on X axis
  84469. * @param y2 defines the right coordinate on Y axis
  84470. * @returns the interpolated value
  84471. */
  84472. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  84473. }
  84474. /**
  84475. * Defines angle representation
  84476. */
  84477. export class Angle {
  84478. private _radians;
  84479. /**
  84480. * Creates an Angle object of "radians" radians (float).
  84481. * @param radians the angle in radians
  84482. */
  84483. constructor(radians: number);
  84484. /**
  84485. * Get value in degrees
  84486. * @returns the Angle value in degrees (float)
  84487. */
  84488. degrees(): number;
  84489. /**
  84490. * Get value in radians
  84491. * @returns the Angle value in radians (float)
  84492. */
  84493. radians(): number;
  84494. /**
  84495. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  84496. * @param a defines first point as the origin
  84497. * @param b defines point
  84498. * @returns a new Angle
  84499. */
  84500. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  84501. /**
  84502. * Gets a new Angle object from the given float in radians
  84503. * @param radians defines the angle value in radians
  84504. * @returns a new Angle
  84505. */
  84506. static FromRadians(radians: number): Angle;
  84507. /**
  84508. * Gets a new Angle object from the given float in degrees
  84509. * @param degrees defines the angle value in degrees
  84510. * @returns a new Angle
  84511. */
  84512. static FromDegrees(degrees: number): Angle;
  84513. }
  84514. /**
  84515. * This represents an arc in a 2d space.
  84516. */
  84517. export class Arc2 {
  84518. /** Defines the start point of the arc */
  84519. startPoint: Vector2;
  84520. /** Defines the mid point of the arc */
  84521. midPoint: Vector2;
  84522. /** Defines the end point of the arc */
  84523. endPoint: Vector2;
  84524. /**
  84525. * Defines the center point of the arc.
  84526. */
  84527. centerPoint: Vector2;
  84528. /**
  84529. * Defines the radius of the arc.
  84530. */
  84531. radius: number;
  84532. /**
  84533. * Defines the angle of the arc (from mid point to end point).
  84534. */
  84535. angle: Angle;
  84536. /**
  84537. * Defines the start angle of the arc (from start point to middle point).
  84538. */
  84539. startAngle: Angle;
  84540. /**
  84541. * Defines the orientation of the arc (clock wise/counter clock wise).
  84542. */
  84543. orientation: Orientation;
  84544. /**
  84545. * Creates an Arc object from the three given points : start, middle and end.
  84546. * @param startPoint Defines the start point of the arc
  84547. * @param midPoint Defines the midlle point of the arc
  84548. * @param endPoint Defines the end point of the arc
  84549. */
  84550. constructor(
  84551. /** Defines the start point of the arc */
  84552. startPoint: Vector2,
  84553. /** Defines the mid point of the arc */
  84554. midPoint: Vector2,
  84555. /** Defines the end point of the arc */
  84556. endPoint: Vector2);
  84557. }
  84558. /**
  84559. * Represents a 2D path made up of multiple 2D points
  84560. */
  84561. export class Path2 {
  84562. private _points;
  84563. private _length;
  84564. /**
  84565. * If the path start and end point are the same
  84566. */
  84567. closed: boolean;
  84568. /**
  84569. * Creates a Path2 object from the starting 2D coordinates x and y.
  84570. * @param x the starting points x value
  84571. * @param y the starting points y value
  84572. */
  84573. constructor(x: number, y: number);
  84574. /**
  84575. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  84576. * @param x the added points x value
  84577. * @param y the added points y value
  84578. * @returns the updated Path2.
  84579. */
  84580. addLineTo(x: number, y: number): Path2;
  84581. /**
  84582. * 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.
  84583. * @param midX middle point x value
  84584. * @param midY middle point y value
  84585. * @param endX end point x value
  84586. * @param endY end point y value
  84587. * @param numberOfSegments (default: 36)
  84588. * @returns the updated Path2.
  84589. */
  84590. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  84591. /**
  84592. * Closes the Path2.
  84593. * @returns the Path2.
  84594. */
  84595. close(): Path2;
  84596. /**
  84597. * Gets the sum of the distance between each sequential point in the path
  84598. * @returns the Path2 total length (float).
  84599. */
  84600. length(): number;
  84601. /**
  84602. * Gets the points which construct the path
  84603. * @returns the Path2 internal array of points.
  84604. */
  84605. getPoints(): Vector2[];
  84606. /**
  84607. * Retreives the point at the distance aways from the starting point
  84608. * @param normalizedLengthPosition the length along the path to retreive the point from
  84609. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  84610. */
  84611. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  84612. /**
  84613. * Creates a new path starting from an x and y position
  84614. * @param x starting x value
  84615. * @param y starting y value
  84616. * @returns a new Path2 starting at the coordinates (x, y).
  84617. */
  84618. static StartingAt(x: number, y: number): Path2;
  84619. }
  84620. /**
  84621. * Represents a 3D path made up of multiple 3D points
  84622. */
  84623. export class Path3D {
  84624. /**
  84625. * an array of Vector3, the curve axis of the Path3D
  84626. */
  84627. path: Vector3[];
  84628. private _curve;
  84629. private _distances;
  84630. private _tangents;
  84631. private _normals;
  84632. private _binormals;
  84633. private _raw;
  84634. private _alignTangentsWithPath;
  84635. private readonly _pointAtData;
  84636. /**
  84637. * new Path3D(path, normal, raw)
  84638. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  84639. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  84640. * @param path an array of Vector3, the curve axis of the Path3D
  84641. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  84642. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  84643. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  84644. */
  84645. constructor(
  84646. /**
  84647. * an array of Vector3, the curve axis of the Path3D
  84648. */
  84649. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  84650. /**
  84651. * Returns the Path3D array of successive Vector3 designing its curve.
  84652. * @returns the Path3D array of successive Vector3 designing its curve.
  84653. */
  84654. getCurve(): Vector3[];
  84655. /**
  84656. * Returns the Path3D array of successive Vector3 designing its curve.
  84657. * @returns the Path3D array of successive Vector3 designing its curve.
  84658. */
  84659. getPoints(): Vector3[];
  84660. /**
  84661. * @returns the computed length (float) of the path.
  84662. */
  84663. length(): number;
  84664. /**
  84665. * Returns an array populated with tangent vectors on each Path3D curve point.
  84666. * @returns an array populated with tangent vectors on each Path3D curve point.
  84667. */
  84668. getTangents(): Vector3[];
  84669. /**
  84670. * Returns an array populated with normal vectors on each Path3D curve point.
  84671. * @returns an array populated with normal vectors on each Path3D curve point.
  84672. */
  84673. getNormals(): Vector3[];
  84674. /**
  84675. * Returns an array populated with binormal vectors on each Path3D curve point.
  84676. * @returns an array populated with binormal vectors on each Path3D curve point.
  84677. */
  84678. getBinormals(): Vector3[];
  84679. /**
  84680. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  84681. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  84682. */
  84683. getDistances(): number[];
  84684. /**
  84685. * Returns an interpolated point along this path
  84686. * @param position the position of the point along this path, from 0.0 to 1.0
  84687. * @returns a new Vector3 as the point
  84688. */
  84689. getPointAt(position: number): Vector3;
  84690. /**
  84691. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84692. * @param position the position of the point along this path, from 0.0 to 1.0
  84693. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  84694. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  84695. */
  84696. getTangentAt(position: number, interpolated?: boolean): Vector3;
  84697. /**
  84698. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84699. * @param position the position of the point along this path, from 0.0 to 1.0
  84700. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  84701. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  84702. */
  84703. getNormalAt(position: number, interpolated?: boolean): Vector3;
  84704. /**
  84705. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  84706. * @param position the position of the point along this path, from 0.0 to 1.0
  84707. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  84708. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  84709. */
  84710. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  84711. /**
  84712. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  84713. * @param position the position of the point along this path, from 0.0 to 1.0
  84714. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  84715. */
  84716. getDistanceAt(position: number): number;
  84717. /**
  84718. * Returns the array index of the previous point of an interpolated point along this path
  84719. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84720. * @returns the array index
  84721. */
  84722. getPreviousPointIndexAt(position: number): number;
  84723. /**
  84724. * 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)
  84725. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84726. * @returns the sub position
  84727. */
  84728. getSubPositionAt(position: number): number;
  84729. /**
  84730. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  84731. * @param target the vector of which to get the closest position to
  84732. * @returns the position of the closest virtual point on this path to the target vector
  84733. */
  84734. getClosestPositionTo(target: Vector3): number;
  84735. /**
  84736. * Returns a sub path (slice) of this path
  84737. * @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
  84738. * @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
  84739. * @returns a sub path (slice) of this path
  84740. */
  84741. slice(start?: number, end?: number): Path3D;
  84742. /**
  84743. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  84744. * @param path path which all values are copied into the curves points
  84745. * @param firstNormal which should be projected onto the curve
  84746. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  84747. * @returns the same object updated.
  84748. */
  84749. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  84750. private _compute;
  84751. private _getFirstNonNullVector;
  84752. private _getLastNonNullVector;
  84753. private _normalVector;
  84754. /**
  84755. * Updates the point at data for an interpolated point along this curve
  84756. * @param position the position of the point along this curve, from 0.0 to 1.0
  84757. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  84758. * @returns the (updated) point at data
  84759. */
  84760. private _updatePointAtData;
  84761. /**
  84762. * Updates the point at data from the specified parameters
  84763. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  84764. * @param point the interpolated point
  84765. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  84766. */
  84767. private _setPointAtData;
  84768. /**
  84769. * Updates the point at interpolation matrix for the tangents, normals and binormals
  84770. */
  84771. private _updateInterpolationMatrix;
  84772. }
  84773. /**
  84774. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84775. * A Curve3 is designed from a series of successive Vector3.
  84776. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  84777. */
  84778. export class Curve3 {
  84779. private _points;
  84780. private _length;
  84781. /**
  84782. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  84783. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  84784. * @param v1 (Vector3) the control point
  84785. * @param v2 (Vector3) the end point of the Quadratic Bezier
  84786. * @param nbPoints (integer) the wanted number of points in the curve
  84787. * @returns the created Curve3
  84788. */
  84789. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84790. /**
  84791. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  84792. * @param v0 (Vector3) the origin point of the Cubic Bezier
  84793. * @param v1 (Vector3) the first control point
  84794. * @param v2 (Vector3) the second control point
  84795. * @param v3 (Vector3) the end point of the Cubic Bezier
  84796. * @param nbPoints (integer) the wanted number of points in the curve
  84797. * @returns the created Curve3
  84798. */
  84799. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84800. /**
  84801. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  84802. * @param p1 (Vector3) the origin point of the Hermite Spline
  84803. * @param t1 (Vector3) the tangent vector at the origin point
  84804. * @param p2 (Vector3) the end point of the Hermite Spline
  84805. * @param t2 (Vector3) the tangent vector at the end point
  84806. * @param nbPoints (integer) the wanted number of points in the curve
  84807. * @returns the created Curve3
  84808. */
  84809. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84810. /**
  84811. * Returns a Curve3 object along a CatmullRom Spline curve :
  84812. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  84813. * @param nbPoints (integer) the wanted number of points between each curve control points
  84814. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  84815. * @returns the created Curve3
  84816. */
  84817. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  84818. /**
  84819. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84820. * A Curve3 is designed from a series of successive Vector3.
  84821. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  84822. * @param points points which make up the curve
  84823. */
  84824. constructor(points: Vector3[]);
  84825. /**
  84826. * @returns the Curve3 stored array of successive Vector3
  84827. */
  84828. getPoints(): Vector3[];
  84829. /**
  84830. * @returns the computed length (float) of the curve.
  84831. */
  84832. length(): number;
  84833. /**
  84834. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  84835. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  84836. * curveA and curveB keep unchanged.
  84837. * @param curve the curve to continue from this curve
  84838. * @returns the newly constructed curve
  84839. */
  84840. continue(curve: DeepImmutable<Curve3>): Curve3;
  84841. private _computeLength;
  84842. }
  84843. }
  84844. declare module BABYLON {
  84845. /**
  84846. * This represents the main contract an easing function should follow.
  84847. * Easing functions are used throughout the animation system.
  84848. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84849. */
  84850. export interface IEasingFunction {
  84851. /**
  84852. * Given an input gradient between 0 and 1, this returns the corrseponding value
  84853. * of the easing function.
  84854. * The link below provides some of the most common examples of easing functions.
  84855. * @see https://easings.net/
  84856. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84857. * @returns the corresponding value on the curve defined by the easing function
  84858. */
  84859. ease(gradient: number): number;
  84860. }
  84861. /**
  84862. * Base class used for every default easing function.
  84863. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84864. */
  84865. export class EasingFunction implements IEasingFunction {
  84866. /**
  84867. * Interpolation follows the mathematical formula associated with the easing function.
  84868. */
  84869. static readonly EASINGMODE_EASEIN: number;
  84870. /**
  84871. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  84872. */
  84873. static readonly EASINGMODE_EASEOUT: number;
  84874. /**
  84875. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  84876. */
  84877. static readonly EASINGMODE_EASEINOUT: number;
  84878. private _easingMode;
  84879. /**
  84880. * Sets the easing mode of the current function.
  84881. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  84882. */
  84883. setEasingMode(easingMode: number): void;
  84884. /**
  84885. * Gets the current easing mode.
  84886. * @returns the easing mode
  84887. */
  84888. getEasingMode(): number;
  84889. /**
  84890. * @hidden
  84891. */
  84892. easeInCore(gradient: number): number;
  84893. /**
  84894. * Given an input gradient between 0 and 1, this returns the corresponding value
  84895. * of the easing function.
  84896. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84897. * @returns the corresponding value on the curve defined by the easing function
  84898. */
  84899. ease(gradient: number): number;
  84900. }
  84901. /**
  84902. * Easing function with a circle shape (see link below).
  84903. * @see https://easings.net/#easeInCirc
  84904. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84905. */
  84906. export class CircleEase extends EasingFunction implements IEasingFunction {
  84907. /** @hidden */
  84908. easeInCore(gradient: number): number;
  84909. }
  84910. /**
  84911. * Easing function with a ease back shape (see link below).
  84912. * @see https://easings.net/#easeInBack
  84913. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84914. */
  84915. export class BackEase extends EasingFunction implements IEasingFunction {
  84916. /** Defines the amplitude of the function */
  84917. amplitude: number;
  84918. /**
  84919. * Instantiates a back ease easing
  84920. * @see https://easings.net/#easeInBack
  84921. * @param amplitude Defines the amplitude of the function
  84922. */
  84923. constructor(
  84924. /** Defines the amplitude of the function */
  84925. amplitude?: number);
  84926. /** @hidden */
  84927. easeInCore(gradient: number): number;
  84928. }
  84929. /**
  84930. * Easing function with a bouncing shape (see link below).
  84931. * @see https://easings.net/#easeInBounce
  84932. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84933. */
  84934. export class BounceEase extends EasingFunction implements IEasingFunction {
  84935. /** Defines the number of bounces */
  84936. bounces: number;
  84937. /** Defines the amplitude of the bounce */
  84938. bounciness: number;
  84939. /**
  84940. * Instantiates a bounce easing
  84941. * @see https://easings.net/#easeInBounce
  84942. * @param bounces Defines the number of bounces
  84943. * @param bounciness Defines the amplitude of the bounce
  84944. */
  84945. constructor(
  84946. /** Defines the number of bounces */
  84947. bounces?: number,
  84948. /** Defines the amplitude of the bounce */
  84949. bounciness?: number);
  84950. /** @hidden */
  84951. easeInCore(gradient: number): number;
  84952. }
  84953. /**
  84954. * Easing function with a power of 3 shape (see link below).
  84955. * @see https://easings.net/#easeInCubic
  84956. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84957. */
  84958. export class CubicEase extends EasingFunction implements IEasingFunction {
  84959. /** @hidden */
  84960. easeInCore(gradient: number): number;
  84961. }
  84962. /**
  84963. * Easing function with an elastic shape (see link below).
  84964. * @see https://easings.net/#easeInElastic
  84965. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84966. */
  84967. export class ElasticEase extends EasingFunction implements IEasingFunction {
  84968. /** Defines the number of oscillations*/
  84969. oscillations: number;
  84970. /** Defines the amplitude of the oscillations*/
  84971. springiness: number;
  84972. /**
  84973. * Instantiates an elastic easing function
  84974. * @see https://easings.net/#easeInElastic
  84975. * @param oscillations Defines the number of oscillations
  84976. * @param springiness Defines the amplitude of the oscillations
  84977. */
  84978. constructor(
  84979. /** Defines the number of oscillations*/
  84980. oscillations?: number,
  84981. /** Defines the amplitude of the oscillations*/
  84982. springiness?: number);
  84983. /** @hidden */
  84984. easeInCore(gradient: number): number;
  84985. }
  84986. /**
  84987. * Easing function with an exponential shape (see link below).
  84988. * @see https://easings.net/#easeInExpo
  84989. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84990. */
  84991. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  84992. /** Defines the exponent of the function */
  84993. exponent: number;
  84994. /**
  84995. * Instantiates an exponential easing function
  84996. * @see https://easings.net/#easeInExpo
  84997. * @param exponent Defines the exponent of the function
  84998. */
  84999. constructor(
  85000. /** Defines the exponent of the function */
  85001. exponent?: number);
  85002. /** @hidden */
  85003. easeInCore(gradient: number): number;
  85004. }
  85005. /**
  85006. * Easing function with a power shape (see link below).
  85007. * @see https://easings.net/#easeInQuad
  85008. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85009. */
  85010. export class PowerEase extends EasingFunction implements IEasingFunction {
  85011. /** Defines the power of the function */
  85012. power: number;
  85013. /**
  85014. * Instantiates an power base easing function
  85015. * @see https://easings.net/#easeInQuad
  85016. * @param power Defines the power of the function
  85017. */
  85018. constructor(
  85019. /** Defines the power of the function */
  85020. power?: number);
  85021. /** @hidden */
  85022. easeInCore(gradient: number): number;
  85023. }
  85024. /**
  85025. * Easing function with a power of 2 shape (see link below).
  85026. * @see https://easings.net/#easeInQuad
  85027. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85028. */
  85029. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  85030. /** @hidden */
  85031. easeInCore(gradient: number): number;
  85032. }
  85033. /**
  85034. * Easing function with a power of 4 shape (see link below).
  85035. * @see https://easings.net/#easeInQuart
  85036. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85037. */
  85038. export class QuarticEase extends EasingFunction implements IEasingFunction {
  85039. /** @hidden */
  85040. easeInCore(gradient: number): number;
  85041. }
  85042. /**
  85043. * Easing function with a power of 5 shape (see link below).
  85044. * @see https://easings.net/#easeInQuint
  85045. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85046. */
  85047. export class QuinticEase extends EasingFunction implements IEasingFunction {
  85048. /** @hidden */
  85049. easeInCore(gradient: number): number;
  85050. }
  85051. /**
  85052. * Easing function with a sin shape (see link below).
  85053. * @see https://easings.net/#easeInSine
  85054. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85055. */
  85056. export class SineEase extends EasingFunction implements IEasingFunction {
  85057. /** @hidden */
  85058. easeInCore(gradient: number): number;
  85059. }
  85060. /**
  85061. * Easing function with a bezier shape (see link below).
  85062. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85063. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85064. */
  85065. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  85066. /** Defines the x component of the start tangent in the bezier curve */
  85067. x1: number;
  85068. /** Defines the y component of the start tangent in the bezier curve */
  85069. y1: number;
  85070. /** Defines the x component of the end tangent in the bezier curve */
  85071. x2: number;
  85072. /** Defines the y component of the end tangent in the bezier curve */
  85073. y2: number;
  85074. /**
  85075. * Instantiates a bezier function
  85076. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85077. * @param x1 Defines the x component of the start tangent in the bezier curve
  85078. * @param y1 Defines the y component of the start tangent in the bezier curve
  85079. * @param x2 Defines the x component of the end tangent in the bezier curve
  85080. * @param y2 Defines the y component of the end tangent in the bezier curve
  85081. */
  85082. constructor(
  85083. /** Defines the x component of the start tangent in the bezier curve */
  85084. x1?: number,
  85085. /** Defines the y component of the start tangent in the bezier curve */
  85086. y1?: number,
  85087. /** Defines the x component of the end tangent in the bezier curve */
  85088. x2?: number,
  85089. /** Defines the y component of the end tangent in the bezier curve */
  85090. y2?: number);
  85091. /** @hidden */
  85092. easeInCore(gradient: number): number;
  85093. }
  85094. }
  85095. declare module BABYLON {
  85096. /**
  85097. * Class used to hold a RBG color
  85098. */
  85099. export class Color3 {
  85100. /**
  85101. * Defines the red component (between 0 and 1, default is 0)
  85102. */
  85103. r: number;
  85104. /**
  85105. * Defines the green component (between 0 and 1, default is 0)
  85106. */
  85107. g: number;
  85108. /**
  85109. * Defines the blue component (between 0 and 1, default is 0)
  85110. */
  85111. b: number;
  85112. /**
  85113. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  85114. * @param r defines the red component (between 0 and 1, default is 0)
  85115. * @param g defines the green component (between 0 and 1, default is 0)
  85116. * @param b defines the blue component (between 0 and 1, default is 0)
  85117. */
  85118. constructor(
  85119. /**
  85120. * Defines the red component (between 0 and 1, default is 0)
  85121. */
  85122. r?: number,
  85123. /**
  85124. * Defines the green component (between 0 and 1, default is 0)
  85125. */
  85126. g?: number,
  85127. /**
  85128. * Defines the blue component (between 0 and 1, default is 0)
  85129. */
  85130. b?: number);
  85131. /**
  85132. * Creates a string with the Color3 current values
  85133. * @returns the string representation of the Color3 object
  85134. */
  85135. toString(): string;
  85136. /**
  85137. * Returns the string "Color3"
  85138. * @returns "Color3"
  85139. */
  85140. getClassName(): string;
  85141. /**
  85142. * Compute the Color3 hash code
  85143. * @returns an unique number that can be used to hash Color3 objects
  85144. */
  85145. getHashCode(): number;
  85146. /**
  85147. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  85148. * @param array defines the array where to store the r,g,b components
  85149. * @param index defines an optional index in the target array to define where to start storing values
  85150. * @returns the current Color3 object
  85151. */
  85152. toArray(array: FloatArray, index?: number): Color3;
  85153. /**
  85154. * Update the current color with values stored in an array from the starting index of the given array
  85155. * @param array defines the source array
  85156. * @param offset defines an offset in the source array
  85157. * @returns the current Color3 object
  85158. */
  85159. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85160. /**
  85161. * Returns a new Color4 object from the current Color3 and the given alpha
  85162. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  85163. * @returns a new Color4 object
  85164. */
  85165. toColor4(alpha?: number): Color4;
  85166. /**
  85167. * Returns a new array populated with 3 numeric elements : red, green and blue values
  85168. * @returns the new array
  85169. */
  85170. asArray(): number[];
  85171. /**
  85172. * Returns the luminance value
  85173. * @returns a float value
  85174. */
  85175. toLuminance(): number;
  85176. /**
  85177. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  85178. * @param otherColor defines the second operand
  85179. * @returns the new Color3 object
  85180. */
  85181. multiply(otherColor: DeepImmutable<Color3>): Color3;
  85182. /**
  85183. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  85184. * @param otherColor defines the second operand
  85185. * @param result defines the Color3 object where to store the result
  85186. * @returns the current Color3
  85187. */
  85188. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85189. /**
  85190. * Determines equality between Color3 objects
  85191. * @param otherColor defines the second operand
  85192. * @returns true if the rgb values are equal to the given ones
  85193. */
  85194. equals(otherColor: DeepImmutable<Color3>): boolean;
  85195. /**
  85196. * Determines equality between the current Color3 object and a set of r,b,g values
  85197. * @param r defines the red component to check
  85198. * @param g defines the green component to check
  85199. * @param b defines the blue component to check
  85200. * @returns true if the rgb values are equal to the given ones
  85201. */
  85202. equalsFloats(r: number, g: number, b: number): boolean;
  85203. /**
  85204. * Multiplies in place each rgb value by scale
  85205. * @param scale defines the scaling factor
  85206. * @returns the updated Color3
  85207. */
  85208. scale(scale: number): Color3;
  85209. /**
  85210. * Multiplies the rgb values by scale and stores the result into "result"
  85211. * @param scale defines the scaling factor
  85212. * @param result defines the Color3 object where to store the result
  85213. * @returns the unmodified current Color3
  85214. */
  85215. scaleToRef(scale: number, result: Color3): Color3;
  85216. /**
  85217. * Scale the current Color3 values by a factor and add the result to a given Color3
  85218. * @param scale defines the scale factor
  85219. * @param result defines color to store the result into
  85220. * @returns the unmodified current Color3
  85221. */
  85222. scaleAndAddToRef(scale: number, result: Color3): Color3;
  85223. /**
  85224. * Clamps the rgb values by the min and max values and stores the result into "result"
  85225. * @param min defines minimum clamping value (default is 0)
  85226. * @param max defines maximum clamping value (default is 1)
  85227. * @param result defines color to store the result into
  85228. * @returns the original Color3
  85229. */
  85230. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  85231. /**
  85232. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  85233. * @param otherColor defines the second operand
  85234. * @returns the new Color3
  85235. */
  85236. add(otherColor: DeepImmutable<Color3>): Color3;
  85237. /**
  85238. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  85239. * @param otherColor defines the second operand
  85240. * @param result defines Color3 object to store the result into
  85241. * @returns the unmodified current Color3
  85242. */
  85243. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85244. /**
  85245. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  85246. * @param otherColor defines the second operand
  85247. * @returns the new Color3
  85248. */
  85249. subtract(otherColor: DeepImmutable<Color3>): Color3;
  85250. /**
  85251. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  85252. * @param otherColor defines the second operand
  85253. * @param result defines Color3 object to store the result into
  85254. * @returns the unmodified current Color3
  85255. */
  85256. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85257. /**
  85258. * Copy the current object
  85259. * @returns a new Color3 copied the current one
  85260. */
  85261. clone(): Color3;
  85262. /**
  85263. * Copies the rgb values from the source in the current Color3
  85264. * @param source defines the source Color3 object
  85265. * @returns the updated Color3 object
  85266. */
  85267. copyFrom(source: DeepImmutable<Color3>): Color3;
  85268. /**
  85269. * Updates the Color3 rgb values from the given floats
  85270. * @param r defines the red component to read from
  85271. * @param g defines the green component to read from
  85272. * @param b defines the blue component to read from
  85273. * @returns the current Color3 object
  85274. */
  85275. copyFromFloats(r: number, g: number, b: number): Color3;
  85276. /**
  85277. * Updates the Color3 rgb values from the given floats
  85278. * @param r defines the red component to read from
  85279. * @param g defines the green component to read from
  85280. * @param b defines the blue component to read from
  85281. * @returns the current Color3 object
  85282. */
  85283. set(r: number, g: number, b: number): Color3;
  85284. /**
  85285. * Compute the Color3 hexadecimal code as a string
  85286. * @returns a string containing the hexadecimal representation of the Color3 object
  85287. */
  85288. toHexString(): string;
  85289. /**
  85290. * Computes a new Color3 converted from the current one to linear space
  85291. * @returns a new Color3 object
  85292. */
  85293. toLinearSpace(): Color3;
  85294. /**
  85295. * Converts current color in rgb space to HSV values
  85296. * @returns a new color3 representing the HSV values
  85297. */
  85298. toHSV(): Color3;
  85299. /**
  85300. * Converts current color in rgb space to HSV values
  85301. * @param result defines the Color3 where to store the HSV values
  85302. */
  85303. toHSVToRef(result: Color3): void;
  85304. /**
  85305. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  85306. * @param convertedColor defines the Color3 object where to store the linear space version
  85307. * @returns the unmodified Color3
  85308. */
  85309. toLinearSpaceToRef(convertedColor: Color3): Color3;
  85310. /**
  85311. * Computes a new Color3 converted from the current one to gamma space
  85312. * @returns a new Color3 object
  85313. */
  85314. toGammaSpace(): Color3;
  85315. /**
  85316. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  85317. * @param convertedColor defines the Color3 object where to store the gamma space version
  85318. * @returns the unmodified Color3
  85319. */
  85320. toGammaSpaceToRef(convertedColor: Color3): Color3;
  85321. private static _BlackReadOnly;
  85322. /**
  85323. * Convert Hue, saturation and value to a Color3 (RGB)
  85324. * @param hue defines the hue
  85325. * @param saturation defines the saturation
  85326. * @param value defines the value
  85327. * @param result defines the Color3 where to store the RGB values
  85328. */
  85329. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  85330. /**
  85331. * Creates a new Color3 from the string containing valid hexadecimal values
  85332. * @param hex defines a string containing valid hexadecimal values
  85333. * @returns a new Color3 object
  85334. */
  85335. static FromHexString(hex: string): Color3;
  85336. /**
  85337. * Creates a new Color3 from the starting index of the given array
  85338. * @param array defines the source array
  85339. * @param offset defines an offset in the source array
  85340. * @returns a new Color3 object
  85341. */
  85342. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85343. /**
  85344. * Creates a new Color3 from the starting index element of the given array
  85345. * @param array defines the source array to read from
  85346. * @param offset defines the offset in the source array
  85347. * @param result defines the target Color3 object
  85348. */
  85349. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  85350. /**
  85351. * Creates a new Color3 from integer values (< 256)
  85352. * @param r defines the red component to read from (value between 0 and 255)
  85353. * @param g defines the green component to read from (value between 0 and 255)
  85354. * @param b defines the blue 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): Color3;
  85358. /**
  85359. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85360. * @param start defines the start Color3 value
  85361. * @param end defines the end Color3 value
  85362. * @param amount defines the gradient value between start and end
  85363. * @returns a new Color3 object
  85364. */
  85365. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  85366. /**
  85367. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85368. * @param left defines the start value
  85369. * @param right defines the end value
  85370. * @param amount defines the gradient factor
  85371. * @param result defines the Color3 object where to store the result
  85372. */
  85373. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  85374. /**
  85375. * Returns a Color3 value containing a red color
  85376. * @returns a new Color3 object
  85377. */
  85378. static Red(): Color3;
  85379. /**
  85380. * Returns a Color3 value containing a green color
  85381. * @returns a new Color3 object
  85382. */
  85383. static Green(): Color3;
  85384. /**
  85385. * Returns a Color3 value containing a blue color
  85386. * @returns a new Color3 object
  85387. */
  85388. static Blue(): Color3;
  85389. /**
  85390. * Returns a Color3 value containing a black color
  85391. * @returns a new Color3 object
  85392. */
  85393. static Black(): Color3;
  85394. /**
  85395. * Gets a Color3 value containing a black color that must not be updated
  85396. */
  85397. static get BlackReadOnly(): DeepImmutable<Color3>;
  85398. /**
  85399. * Returns a Color3 value containing a white color
  85400. * @returns a new Color3 object
  85401. */
  85402. static White(): Color3;
  85403. /**
  85404. * Returns a Color3 value containing a purple color
  85405. * @returns a new Color3 object
  85406. */
  85407. static Purple(): Color3;
  85408. /**
  85409. * Returns a Color3 value containing a magenta color
  85410. * @returns a new Color3 object
  85411. */
  85412. static Magenta(): Color3;
  85413. /**
  85414. * Returns a Color3 value containing a yellow color
  85415. * @returns a new Color3 object
  85416. */
  85417. static Yellow(): Color3;
  85418. /**
  85419. * Returns a Color3 value containing a gray color
  85420. * @returns a new Color3 object
  85421. */
  85422. static Gray(): Color3;
  85423. /**
  85424. * Returns a Color3 value containing a teal color
  85425. * @returns a new Color3 object
  85426. */
  85427. static Teal(): Color3;
  85428. /**
  85429. * Returns a Color3 value containing a random color
  85430. * @returns a new Color3 object
  85431. */
  85432. static Random(): Color3;
  85433. }
  85434. /**
  85435. * Class used to hold a RBGA color
  85436. */
  85437. export class Color4 {
  85438. /**
  85439. * Defines the red component (between 0 and 1, default is 0)
  85440. */
  85441. r: number;
  85442. /**
  85443. * Defines the green component (between 0 and 1, default is 0)
  85444. */
  85445. g: number;
  85446. /**
  85447. * Defines the blue component (between 0 and 1, default is 0)
  85448. */
  85449. b: number;
  85450. /**
  85451. * Defines the alpha component (between 0 and 1, default is 1)
  85452. */
  85453. a: number;
  85454. /**
  85455. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  85456. * @param r defines the red component (between 0 and 1, default is 0)
  85457. * @param g defines the green component (between 0 and 1, default is 0)
  85458. * @param b defines the blue component (between 0 and 1, default is 0)
  85459. * @param a defines the alpha component (between 0 and 1, default is 1)
  85460. */
  85461. constructor(
  85462. /**
  85463. * Defines the red component (between 0 and 1, default is 0)
  85464. */
  85465. r?: number,
  85466. /**
  85467. * Defines the green component (between 0 and 1, default is 0)
  85468. */
  85469. g?: number,
  85470. /**
  85471. * Defines the blue component (between 0 and 1, default is 0)
  85472. */
  85473. b?: number,
  85474. /**
  85475. * Defines the alpha component (between 0 and 1, default is 1)
  85476. */
  85477. a?: number);
  85478. /**
  85479. * Adds in place the given Color4 values to the current Color4 object
  85480. * @param right defines the second operand
  85481. * @returns the current updated Color4 object
  85482. */
  85483. addInPlace(right: DeepImmutable<Color4>): Color4;
  85484. /**
  85485. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  85486. * @returns the new array
  85487. */
  85488. asArray(): number[];
  85489. /**
  85490. * Stores from the starting index in the given array the Color4 successive values
  85491. * @param array defines the array where to store the r,g,b components
  85492. * @param index defines an optional index in the target array to define where to start storing values
  85493. * @returns the current Color4 object
  85494. */
  85495. toArray(array: number[], index?: number): Color4;
  85496. /**
  85497. * Update the current color with values stored in an array from the starting index of the given array
  85498. * @param array defines the source array
  85499. * @param offset defines an offset in the source array
  85500. * @returns the current Color4 object
  85501. */
  85502. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85503. /**
  85504. * Determines equality between Color4 objects
  85505. * @param otherColor defines the second operand
  85506. * @returns true if the rgba values are equal to the given ones
  85507. */
  85508. equals(otherColor: DeepImmutable<Color4>): boolean;
  85509. /**
  85510. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  85511. * @param right defines the second operand
  85512. * @returns a new Color4 object
  85513. */
  85514. add(right: DeepImmutable<Color4>): Color4;
  85515. /**
  85516. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  85517. * @param right defines the second operand
  85518. * @returns a new Color4 object
  85519. */
  85520. subtract(right: DeepImmutable<Color4>): Color4;
  85521. /**
  85522. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  85523. * @param right defines the second operand
  85524. * @param result defines the Color4 object where to store the result
  85525. * @returns the current Color4 object
  85526. */
  85527. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  85528. /**
  85529. * Creates a new Color4 with the current Color4 values multiplied by scale
  85530. * @param scale defines the scaling factor to apply
  85531. * @returns a new Color4 object
  85532. */
  85533. scale(scale: number): Color4;
  85534. /**
  85535. * Multiplies the current Color4 values by scale and stores the result in "result"
  85536. * @param scale defines the scaling factor to apply
  85537. * @param result defines the Color4 object where to store the result
  85538. * @returns the current unmodified Color4
  85539. */
  85540. scaleToRef(scale: number, result: Color4): Color4;
  85541. /**
  85542. * Scale the current Color4 values by a factor and add the result to a given Color4
  85543. * @param scale defines the scale factor
  85544. * @param result defines the Color4 object where to store the result
  85545. * @returns the unmodified current Color4
  85546. */
  85547. scaleAndAddToRef(scale: number, result: Color4): Color4;
  85548. /**
  85549. * Clamps the rgb values by the min and max values and stores the result into "result"
  85550. * @param min defines minimum clamping value (default is 0)
  85551. * @param max defines maximum clamping value (default is 1)
  85552. * @param result defines color to store the result into.
  85553. * @returns the cuurent Color4
  85554. */
  85555. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  85556. /**
  85557. * Multipy an Color4 value by another and return a new Color4 object
  85558. * @param color defines the Color4 value to multiply by
  85559. * @returns a new Color4 object
  85560. */
  85561. multiply(color: Color4): Color4;
  85562. /**
  85563. * Multipy a Color4 value by another and push the result in a reference value
  85564. * @param color defines the Color4 value to multiply by
  85565. * @param result defines the Color4 to fill the result in
  85566. * @returns the result Color4
  85567. */
  85568. multiplyToRef(color: Color4, result: Color4): Color4;
  85569. /**
  85570. * Creates a string with the Color4 current values
  85571. * @returns the string representation of the Color4 object
  85572. */
  85573. toString(): string;
  85574. /**
  85575. * Returns the string "Color4"
  85576. * @returns "Color4"
  85577. */
  85578. getClassName(): string;
  85579. /**
  85580. * Compute the Color4 hash code
  85581. * @returns an unique number that can be used to hash Color4 objects
  85582. */
  85583. getHashCode(): number;
  85584. /**
  85585. * Creates a new Color4 copied from the current one
  85586. * @returns a new Color4 object
  85587. */
  85588. clone(): Color4;
  85589. /**
  85590. * Copies the given Color4 values into the current one
  85591. * @param source defines the source Color4 object
  85592. * @returns the current updated Color4 object
  85593. */
  85594. copyFrom(source: Color4): Color4;
  85595. /**
  85596. * Copies the given float values into the current one
  85597. * @param r defines the red component to read from
  85598. * @param g defines the green component to read from
  85599. * @param b defines the blue component to read from
  85600. * @param a defines the alpha component to read from
  85601. * @returns the current updated Color4 object
  85602. */
  85603. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  85604. /**
  85605. * Copies the given float values into the current one
  85606. * @param r defines the red component to read from
  85607. * @param g defines the green component to read from
  85608. * @param b defines the blue component to read from
  85609. * @param a defines the alpha component to read from
  85610. * @returns the current updated Color4 object
  85611. */
  85612. set(r: number, g: number, b: number, a: number): Color4;
  85613. /**
  85614. * Compute the Color4 hexadecimal code as a string
  85615. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  85616. * @returns a string containing the hexadecimal representation of the Color4 object
  85617. */
  85618. toHexString(returnAsColor3?: boolean): string;
  85619. /**
  85620. * Computes a new Color4 converted from the current one to linear space
  85621. * @returns a new Color4 object
  85622. */
  85623. toLinearSpace(): Color4;
  85624. /**
  85625. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  85626. * @param convertedColor defines the Color4 object where to store the linear space version
  85627. * @returns the unmodified Color4
  85628. */
  85629. toLinearSpaceToRef(convertedColor: Color4): Color4;
  85630. /**
  85631. * Computes a new Color4 converted from the current one to gamma space
  85632. * @returns a new Color4 object
  85633. */
  85634. toGammaSpace(): Color4;
  85635. /**
  85636. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  85637. * @param convertedColor defines the Color4 object where to store the gamma space version
  85638. * @returns the unmodified Color4
  85639. */
  85640. toGammaSpaceToRef(convertedColor: Color4): Color4;
  85641. /**
  85642. * Creates a new Color4 from the string containing valid hexadecimal values
  85643. * @param hex defines a string containing valid hexadecimal values
  85644. * @returns a new Color4 object
  85645. */
  85646. static FromHexString(hex: string): Color4;
  85647. /**
  85648. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85649. * @param left defines the start value
  85650. * @param right defines the end value
  85651. * @param amount defines the gradient factor
  85652. * @returns a new Color4 object
  85653. */
  85654. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  85655. /**
  85656. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85657. * @param left defines the start value
  85658. * @param right defines the end value
  85659. * @param amount defines the gradient factor
  85660. * @param result defines the Color4 object where to store data
  85661. */
  85662. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  85663. /**
  85664. * Creates a new Color4 from a Color3 and an alpha value
  85665. * @param color3 defines the source Color3 to read from
  85666. * @param alpha defines the alpha component (1.0 by default)
  85667. * @returns a new Color4 object
  85668. */
  85669. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  85670. /**
  85671. * Creates a new Color4 from the starting index element of the given array
  85672. * @param array defines the source array to read from
  85673. * @param offset defines the offset in the source array
  85674. * @returns a new Color4 object
  85675. */
  85676. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85677. /**
  85678. * Creates a new Color4 from the starting index element of the given array
  85679. * @param array defines the source array to read from
  85680. * @param offset defines the offset in the source array
  85681. * @param result defines the target Color4 object
  85682. */
  85683. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  85684. /**
  85685. * Creates a new Color3 from integer values (< 256)
  85686. * @param r defines the red component to read from (value between 0 and 255)
  85687. * @param g defines the green component to read from (value between 0 and 255)
  85688. * @param b defines the blue component to read from (value between 0 and 255)
  85689. * @param a defines the alpha component to read from (value between 0 and 255)
  85690. * @returns a new Color3 object
  85691. */
  85692. static FromInts(r: number, g: number, b: number, a: number): Color4;
  85693. /**
  85694. * Check the content of a given array and convert it to an array containing RGBA data
  85695. * If the original array was already containing count * 4 values then it is returned directly
  85696. * @param colors defines the array to check
  85697. * @param count defines the number of RGBA data to expect
  85698. * @returns an array containing count * 4 values (RGBA)
  85699. */
  85700. static CheckColors4(colors: number[], count: number): number[];
  85701. }
  85702. /**
  85703. * @hidden
  85704. */
  85705. export class TmpColors {
  85706. static Color3: Color3[];
  85707. static Color4: Color4[];
  85708. }
  85709. }
  85710. declare module BABYLON {
  85711. /**
  85712. * Defines an interface which represents an animation key frame
  85713. */
  85714. export interface IAnimationKey {
  85715. /**
  85716. * Frame of the key frame
  85717. */
  85718. frame: number;
  85719. /**
  85720. * Value at the specifies key frame
  85721. */
  85722. value: any;
  85723. /**
  85724. * The input tangent for the cubic hermite spline
  85725. */
  85726. inTangent?: any;
  85727. /**
  85728. * The output tangent for the cubic hermite spline
  85729. */
  85730. outTangent?: any;
  85731. /**
  85732. * The animation interpolation type
  85733. */
  85734. interpolation?: AnimationKeyInterpolation;
  85735. }
  85736. /**
  85737. * Enum for the animation key frame interpolation type
  85738. */
  85739. export enum AnimationKeyInterpolation {
  85740. /**
  85741. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  85742. */
  85743. STEP = 1
  85744. }
  85745. }
  85746. declare module BABYLON {
  85747. /**
  85748. * Represents the range of an animation
  85749. */
  85750. export class AnimationRange {
  85751. /**The name of the animation range**/
  85752. name: string;
  85753. /**The starting frame of the animation */
  85754. from: number;
  85755. /**The ending frame of the animation*/
  85756. to: number;
  85757. /**
  85758. * Initializes the range of an animation
  85759. * @param name The name of the animation range
  85760. * @param from The starting frame of the animation
  85761. * @param to The ending frame of the animation
  85762. */
  85763. constructor(
  85764. /**The name of the animation range**/
  85765. name: string,
  85766. /**The starting frame of the animation */
  85767. from: number,
  85768. /**The ending frame of the animation*/
  85769. to: number);
  85770. /**
  85771. * Makes a copy of the animation range
  85772. * @returns A copy of the animation range
  85773. */
  85774. clone(): AnimationRange;
  85775. }
  85776. }
  85777. declare module BABYLON {
  85778. /**
  85779. * Composed of a frame, and an action function
  85780. */
  85781. export class AnimationEvent {
  85782. /** The frame for which the event is triggered **/
  85783. frame: number;
  85784. /** The event to perform when triggered **/
  85785. action: (currentFrame: number) => void;
  85786. /** Specifies if the event should be triggered only once**/
  85787. onlyOnce?: boolean | undefined;
  85788. /**
  85789. * Specifies if the animation event is done
  85790. */
  85791. isDone: boolean;
  85792. /**
  85793. * Initializes the animation event
  85794. * @param frame The frame for which the event is triggered
  85795. * @param action The event to perform when triggered
  85796. * @param onlyOnce Specifies if the event should be triggered only once
  85797. */
  85798. constructor(
  85799. /** The frame for which the event is triggered **/
  85800. frame: number,
  85801. /** The event to perform when triggered **/
  85802. action: (currentFrame: number) => void,
  85803. /** Specifies if the event should be triggered only once**/
  85804. onlyOnce?: boolean | undefined);
  85805. /** @hidden */
  85806. _clone(): AnimationEvent;
  85807. }
  85808. }
  85809. declare module BABYLON {
  85810. /**
  85811. * Interface used to define a behavior
  85812. */
  85813. export interface Behavior<T> {
  85814. /** gets or sets behavior's name */
  85815. name: string;
  85816. /**
  85817. * Function called when the behavior needs to be initialized (after attaching it to a target)
  85818. */
  85819. init(): void;
  85820. /**
  85821. * Called when the behavior is attached to a target
  85822. * @param target defines the target where the behavior is attached to
  85823. */
  85824. attach(target: T): void;
  85825. /**
  85826. * Called when the behavior is detached from its target
  85827. */
  85828. detach(): void;
  85829. }
  85830. /**
  85831. * Interface implemented by classes supporting behaviors
  85832. */
  85833. export interface IBehaviorAware<T> {
  85834. /**
  85835. * Attach a behavior
  85836. * @param behavior defines the behavior to attach
  85837. * @returns the current host
  85838. */
  85839. addBehavior(behavior: Behavior<T>): T;
  85840. /**
  85841. * Remove a behavior from the current object
  85842. * @param behavior defines the behavior to detach
  85843. * @returns the current host
  85844. */
  85845. removeBehavior(behavior: Behavior<T>): T;
  85846. /**
  85847. * Gets a behavior using its name to search
  85848. * @param name defines the name to search
  85849. * @returns the behavior or null if not found
  85850. */
  85851. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  85852. }
  85853. }
  85854. declare module BABYLON {
  85855. /**
  85856. * Defines an array and its length.
  85857. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  85858. */
  85859. export interface ISmartArrayLike<T> {
  85860. /**
  85861. * The data of the array.
  85862. */
  85863. data: Array<T>;
  85864. /**
  85865. * The active length of the array.
  85866. */
  85867. length: number;
  85868. }
  85869. /**
  85870. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85871. */
  85872. export class SmartArray<T> implements ISmartArrayLike<T> {
  85873. /**
  85874. * The full set of data from the array.
  85875. */
  85876. data: Array<T>;
  85877. /**
  85878. * The active length of the array.
  85879. */
  85880. length: number;
  85881. protected _id: number;
  85882. /**
  85883. * Instantiates a Smart Array.
  85884. * @param capacity defines the default capacity of the array.
  85885. */
  85886. constructor(capacity: number);
  85887. /**
  85888. * Pushes a value at the end of the active data.
  85889. * @param value defines the object to push in the array.
  85890. */
  85891. push(value: T): void;
  85892. /**
  85893. * Iterates over the active data and apply the lambda to them.
  85894. * @param func defines the action to apply on each value.
  85895. */
  85896. forEach(func: (content: T) => void): void;
  85897. /**
  85898. * Sorts the full sets of data.
  85899. * @param compareFn defines the comparison function to apply.
  85900. */
  85901. sort(compareFn: (a: T, b: T) => number): void;
  85902. /**
  85903. * Resets the active data to an empty array.
  85904. */
  85905. reset(): void;
  85906. /**
  85907. * Releases all the data from the array as well as the array.
  85908. */
  85909. dispose(): void;
  85910. /**
  85911. * Concats the active data with a given array.
  85912. * @param array defines the data to concatenate with.
  85913. */
  85914. concat(array: any): void;
  85915. /**
  85916. * Returns the position of a value in the active data.
  85917. * @param value defines the value to find the index for
  85918. * @returns the index if found in the active data otherwise -1
  85919. */
  85920. indexOf(value: T): number;
  85921. /**
  85922. * Returns whether an element is part of the active data.
  85923. * @param value defines the value to look for
  85924. * @returns true if found in the active data otherwise false
  85925. */
  85926. contains(value: T): boolean;
  85927. private static _GlobalId;
  85928. }
  85929. /**
  85930. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85931. * The data in this array can only be present once
  85932. */
  85933. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  85934. private _duplicateId;
  85935. /**
  85936. * Pushes a value at the end of the active data.
  85937. * THIS DOES NOT PREVENT DUPPLICATE DATA
  85938. * @param value defines the object to push in the array.
  85939. */
  85940. push(value: T): void;
  85941. /**
  85942. * Pushes a value at the end of the active data.
  85943. * If the data is already present, it won t be added again
  85944. * @param value defines the object to push in the array.
  85945. * @returns true if added false if it was already present
  85946. */
  85947. pushNoDuplicate(value: T): boolean;
  85948. /**
  85949. * Resets the active data to an empty array.
  85950. */
  85951. reset(): void;
  85952. /**
  85953. * Concats the active data with a given array.
  85954. * This ensures no dupplicate will be present in the result.
  85955. * @param array defines the data to concatenate with.
  85956. */
  85957. concatWithNoDuplicate(array: any): void;
  85958. }
  85959. }
  85960. declare module BABYLON {
  85961. /**
  85962. * @ignore
  85963. * This is a list of all the different input types that are available in the application.
  85964. * Fo instance: ArcRotateCameraGamepadInput...
  85965. */
  85966. export var CameraInputTypes: {};
  85967. /**
  85968. * This is the contract to implement in order to create a new input class.
  85969. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  85970. */
  85971. export interface ICameraInput<TCamera extends Camera> {
  85972. /**
  85973. * Defines the camera the input is attached to.
  85974. */
  85975. camera: Nullable<TCamera>;
  85976. /**
  85977. * Gets the class name of the current intput.
  85978. * @returns the class name
  85979. */
  85980. getClassName(): string;
  85981. /**
  85982. * Get the friendly name associated with the input class.
  85983. * @returns the input friendly name
  85984. */
  85985. getSimpleName(): string;
  85986. /**
  85987. * Attach the input controls to a specific dom element to get the input from.
  85988. * @param element Defines the element the controls should be listened from
  85989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85990. */
  85991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85992. /**
  85993. * Detach the current controls from the specified dom element.
  85994. * @param element Defines the element to stop listening the inputs from
  85995. */
  85996. detachControl(element: Nullable<HTMLElement>): void;
  85997. /**
  85998. * Update the current camera state depending on the inputs that have been used this frame.
  85999. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86000. */
  86001. checkInputs?: () => void;
  86002. }
  86003. /**
  86004. * Represents a map of input types to input instance or input index to input instance.
  86005. */
  86006. export interface CameraInputsMap<TCamera extends Camera> {
  86007. /**
  86008. * Accessor to the input by input type.
  86009. */
  86010. [name: string]: ICameraInput<TCamera>;
  86011. /**
  86012. * Accessor to the input by input index.
  86013. */
  86014. [idx: number]: ICameraInput<TCamera>;
  86015. }
  86016. /**
  86017. * This represents the input manager used within a camera.
  86018. * It helps dealing with all the different kind of input attached to a camera.
  86019. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86020. */
  86021. export class CameraInputsManager<TCamera extends Camera> {
  86022. /**
  86023. * Defines the list of inputs attahed to the camera.
  86024. */
  86025. attached: CameraInputsMap<TCamera>;
  86026. /**
  86027. * Defines the dom element the camera is collecting inputs from.
  86028. * This is null if the controls have not been attached.
  86029. */
  86030. attachedElement: Nullable<HTMLElement>;
  86031. /**
  86032. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86033. */
  86034. noPreventDefault: boolean;
  86035. /**
  86036. * Defined the camera the input manager belongs to.
  86037. */
  86038. camera: TCamera;
  86039. /**
  86040. * Update the current camera state depending on the inputs that have been used this frame.
  86041. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86042. */
  86043. checkInputs: () => void;
  86044. /**
  86045. * Instantiate a new Camera Input Manager.
  86046. * @param camera Defines the camera the input manager blongs to
  86047. */
  86048. constructor(camera: TCamera);
  86049. /**
  86050. * Add an input method to a camera
  86051. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86052. * @param input camera input method
  86053. */
  86054. add(input: ICameraInput<TCamera>): void;
  86055. /**
  86056. * Remove a specific input method from a camera
  86057. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  86058. * @param inputToRemove camera input method
  86059. */
  86060. remove(inputToRemove: ICameraInput<TCamera>): void;
  86061. /**
  86062. * Remove a specific input type from a camera
  86063. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  86064. * @param inputType the type of the input to remove
  86065. */
  86066. removeByType(inputType: string): void;
  86067. private _addCheckInputs;
  86068. /**
  86069. * Attach the input controls to the currently attached dom element to listen the events from.
  86070. * @param input Defines the input to attach
  86071. */
  86072. attachInput(input: ICameraInput<TCamera>): void;
  86073. /**
  86074. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  86075. * @param element Defines the dom element to collect the events from
  86076. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86077. */
  86078. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  86079. /**
  86080. * Detach the current manager inputs controls from a specific dom element.
  86081. * @param element Defines the dom element to collect the events from
  86082. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  86083. */
  86084. detachElement(element: HTMLElement, disconnect?: boolean): void;
  86085. /**
  86086. * Rebuild the dynamic inputCheck function from the current list of
  86087. * defined inputs in the manager.
  86088. */
  86089. rebuildInputCheck(): void;
  86090. /**
  86091. * Remove all attached input methods from a camera
  86092. */
  86093. clear(): void;
  86094. /**
  86095. * Serialize the current input manager attached to a camera.
  86096. * This ensures than once parsed,
  86097. * the input associated to the camera will be identical to the current ones
  86098. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  86099. */
  86100. serialize(serializedCamera: any): void;
  86101. /**
  86102. * Parses an input manager serialized JSON to restore the previous list of inputs
  86103. * and states associated to a camera.
  86104. * @param parsedCamera Defines the JSON to parse
  86105. */
  86106. parse(parsedCamera: any): void;
  86107. }
  86108. }
  86109. declare module BABYLON {
  86110. /**
  86111. * Class used to store data that will be store in GPU memory
  86112. */
  86113. export class Buffer {
  86114. private _engine;
  86115. private _buffer;
  86116. /** @hidden */
  86117. _data: Nullable<DataArray>;
  86118. private _updatable;
  86119. private _instanced;
  86120. private _divisor;
  86121. /**
  86122. * Gets the byte stride.
  86123. */
  86124. readonly byteStride: number;
  86125. /**
  86126. * Constructor
  86127. * @param engine the engine
  86128. * @param data the data to use for this buffer
  86129. * @param updatable whether the data is updatable
  86130. * @param stride the stride (optional)
  86131. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86132. * @param instanced whether the buffer is instanced (optional)
  86133. * @param useBytes set to true if the stride in in bytes (optional)
  86134. * @param divisor sets an optional divisor for instances (1 by default)
  86135. */
  86136. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  86137. /**
  86138. * Create a new VertexBuffer based on the current buffer
  86139. * @param kind defines the vertex buffer kind (position, normal, etc.)
  86140. * @param offset defines offset in the buffer (0 by default)
  86141. * @param size defines the size in floats of attributes (position is 3 for instance)
  86142. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  86143. * @param instanced defines if the vertex buffer contains indexed data
  86144. * @param useBytes defines if the offset and stride are in bytes *
  86145. * @param divisor sets an optional divisor for instances (1 by default)
  86146. * @returns the new vertex buffer
  86147. */
  86148. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  86149. /**
  86150. * Gets a boolean indicating if the Buffer is updatable?
  86151. * @returns true if the buffer is updatable
  86152. */
  86153. isUpdatable(): boolean;
  86154. /**
  86155. * Gets current buffer's data
  86156. * @returns a DataArray or null
  86157. */
  86158. getData(): Nullable<DataArray>;
  86159. /**
  86160. * Gets underlying native buffer
  86161. * @returns underlying native buffer
  86162. */
  86163. getBuffer(): Nullable<DataBuffer>;
  86164. /**
  86165. * Gets the stride in float32 units (i.e. byte stride / 4).
  86166. * May not be an integer if the byte stride is not divisible by 4.
  86167. * @returns the stride in float32 units
  86168. * @deprecated Please use byteStride instead.
  86169. */
  86170. getStrideSize(): number;
  86171. /**
  86172. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86173. * @param data defines the data to store
  86174. */
  86175. create(data?: Nullable<DataArray>): void;
  86176. /** @hidden */
  86177. _rebuild(): void;
  86178. /**
  86179. * Update current buffer data
  86180. * @param data defines the data to store
  86181. */
  86182. update(data: DataArray): void;
  86183. /**
  86184. * Updates the data directly.
  86185. * @param data the new data
  86186. * @param offset the new offset
  86187. * @param vertexCount the vertex count (optional)
  86188. * @param useBytes set to true if the offset is in bytes
  86189. */
  86190. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  86191. /**
  86192. * Release all resources
  86193. */
  86194. dispose(): void;
  86195. }
  86196. /**
  86197. * Specialized buffer used to store vertex data
  86198. */
  86199. export class VertexBuffer {
  86200. /** @hidden */
  86201. _buffer: Buffer;
  86202. private _kind;
  86203. private _size;
  86204. private _ownsBuffer;
  86205. private _instanced;
  86206. private _instanceDivisor;
  86207. /**
  86208. * The byte type.
  86209. */
  86210. static readonly BYTE: number;
  86211. /**
  86212. * The unsigned byte type.
  86213. */
  86214. static readonly UNSIGNED_BYTE: number;
  86215. /**
  86216. * The short type.
  86217. */
  86218. static readonly SHORT: number;
  86219. /**
  86220. * The unsigned short type.
  86221. */
  86222. static readonly UNSIGNED_SHORT: number;
  86223. /**
  86224. * The integer type.
  86225. */
  86226. static readonly INT: number;
  86227. /**
  86228. * The unsigned integer type.
  86229. */
  86230. static readonly UNSIGNED_INT: number;
  86231. /**
  86232. * The float type.
  86233. */
  86234. static readonly FLOAT: number;
  86235. /**
  86236. * Gets or sets the instance divisor when in instanced mode
  86237. */
  86238. get instanceDivisor(): number;
  86239. set instanceDivisor(value: number);
  86240. /**
  86241. * Gets the byte stride.
  86242. */
  86243. readonly byteStride: number;
  86244. /**
  86245. * Gets the byte offset.
  86246. */
  86247. readonly byteOffset: number;
  86248. /**
  86249. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  86250. */
  86251. readonly normalized: boolean;
  86252. /**
  86253. * Gets the data type of each component in the array.
  86254. */
  86255. readonly type: number;
  86256. /**
  86257. * Constructor
  86258. * @param engine the engine
  86259. * @param data the data to use for this vertex buffer
  86260. * @param kind the vertex buffer kind
  86261. * @param updatable whether the data is updatable
  86262. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86263. * @param stride the stride (optional)
  86264. * @param instanced whether the buffer is instanced (optional)
  86265. * @param offset the offset of the data (optional)
  86266. * @param size the number of components (optional)
  86267. * @param type the type of the component (optional)
  86268. * @param normalized whether the data contains normalized data (optional)
  86269. * @param useBytes set to true if stride and offset are in bytes (optional)
  86270. * @param divisor defines the instance divisor to use (1 by default)
  86271. */
  86272. 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);
  86273. /** @hidden */
  86274. _rebuild(): void;
  86275. /**
  86276. * Returns the kind of the VertexBuffer (string)
  86277. * @returns a string
  86278. */
  86279. getKind(): string;
  86280. /**
  86281. * Gets a boolean indicating if the VertexBuffer is updatable?
  86282. * @returns true if the buffer is updatable
  86283. */
  86284. isUpdatable(): boolean;
  86285. /**
  86286. * Gets current buffer's data
  86287. * @returns a DataArray or null
  86288. */
  86289. getData(): Nullable<DataArray>;
  86290. /**
  86291. * Gets underlying native buffer
  86292. * @returns underlying native buffer
  86293. */
  86294. getBuffer(): Nullable<DataBuffer>;
  86295. /**
  86296. * Gets the stride in float32 units (i.e. byte stride / 4).
  86297. * May not be an integer if the byte stride is not divisible by 4.
  86298. * @returns the stride in float32 units
  86299. * @deprecated Please use byteStride instead.
  86300. */
  86301. getStrideSize(): number;
  86302. /**
  86303. * Returns the offset as a multiple of the type byte length.
  86304. * @returns the offset in bytes
  86305. * @deprecated Please use byteOffset instead.
  86306. */
  86307. getOffset(): number;
  86308. /**
  86309. * Returns the number of components per vertex attribute (integer)
  86310. * @returns the size in float
  86311. */
  86312. getSize(): number;
  86313. /**
  86314. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  86315. * @returns true if this buffer is instanced
  86316. */
  86317. getIsInstanced(): boolean;
  86318. /**
  86319. * Returns the instancing divisor, zero for non-instanced (integer).
  86320. * @returns a number
  86321. */
  86322. getInstanceDivisor(): number;
  86323. /**
  86324. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86325. * @param data defines the data to store
  86326. */
  86327. create(data?: DataArray): void;
  86328. /**
  86329. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  86330. * This function will create a new buffer if the current one is not updatable
  86331. * @param data defines the data to store
  86332. */
  86333. update(data: DataArray): void;
  86334. /**
  86335. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  86336. * Returns the directly updated WebGLBuffer.
  86337. * @param data the new data
  86338. * @param offset the new offset
  86339. * @param useBytes set to true if the offset is in bytes
  86340. */
  86341. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  86342. /**
  86343. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  86344. */
  86345. dispose(): void;
  86346. /**
  86347. * Enumerates each value of this vertex buffer as numbers.
  86348. * @param count the number of values to enumerate
  86349. * @param callback the callback function called for each value
  86350. */
  86351. forEach(count: number, callback: (value: number, index: number) => void): void;
  86352. /**
  86353. * Positions
  86354. */
  86355. static readonly PositionKind: string;
  86356. /**
  86357. * Normals
  86358. */
  86359. static readonly NormalKind: string;
  86360. /**
  86361. * Tangents
  86362. */
  86363. static readonly TangentKind: string;
  86364. /**
  86365. * Texture coordinates
  86366. */
  86367. static readonly UVKind: string;
  86368. /**
  86369. * Texture coordinates 2
  86370. */
  86371. static readonly UV2Kind: string;
  86372. /**
  86373. * Texture coordinates 3
  86374. */
  86375. static readonly UV3Kind: string;
  86376. /**
  86377. * Texture coordinates 4
  86378. */
  86379. static readonly UV4Kind: string;
  86380. /**
  86381. * Texture coordinates 5
  86382. */
  86383. static readonly UV5Kind: string;
  86384. /**
  86385. * Texture coordinates 6
  86386. */
  86387. static readonly UV6Kind: string;
  86388. /**
  86389. * Colors
  86390. */
  86391. static readonly ColorKind: string;
  86392. /**
  86393. * Matrix indices (for bones)
  86394. */
  86395. static readonly MatricesIndicesKind: string;
  86396. /**
  86397. * Matrix weights (for bones)
  86398. */
  86399. static readonly MatricesWeightsKind: string;
  86400. /**
  86401. * Additional matrix indices (for bones)
  86402. */
  86403. static readonly MatricesIndicesExtraKind: string;
  86404. /**
  86405. * Additional matrix weights (for bones)
  86406. */
  86407. static readonly MatricesWeightsExtraKind: string;
  86408. /**
  86409. * Deduces the stride given a kind.
  86410. * @param kind The kind string to deduce
  86411. * @returns The deduced stride
  86412. */
  86413. static DeduceStride(kind: string): number;
  86414. /**
  86415. * Gets the byte length of the given type.
  86416. * @param type the type
  86417. * @returns the number of bytes
  86418. */
  86419. static GetTypeByteLength(type: number): number;
  86420. /**
  86421. * Enumerates each value of the given parameters as numbers.
  86422. * @param data the data to enumerate
  86423. * @param byteOffset the byte offset of the data
  86424. * @param byteStride the byte stride of the data
  86425. * @param componentCount the number of components per element
  86426. * @param componentType the type of the component
  86427. * @param count the number of values to enumerate
  86428. * @param normalized whether the data is normalized
  86429. * @param callback the callback function called for each value
  86430. */
  86431. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  86432. private static _GetFloatValue;
  86433. }
  86434. }
  86435. declare module BABYLON {
  86436. /**
  86437. * @hidden
  86438. */
  86439. export class IntersectionInfo {
  86440. bu: Nullable<number>;
  86441. bv: Nullable<number>;
  86442. distance: number;
  86443. faceId: number;
  86444. subMeshId: number;
  86445. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  86446. }
  86447. }
  86448. declare module BABYLON {
  86449. /**
  86450. * Class used to store bounding sphere information
  86451. */
  86452. export class BoundingSphere {
  86453. /**
  86454. * Gets the center of the bounding sphere in local space
  86455. */
  86456. readonly center: Vector3;
  86457. /**
  86458. * Radius of the bounding sphere in local space
  86459. */
  86460. radius: number;
  86461. /**
  86462. * Gets the center of the bounding sphere in world space
  86463. */
  86464. readonly centerWorld: Vector3;
  86465. /**
  86466. * Radius of the bounding sphere in world space
  86467. */
  86468. radiusWorld: number;
  86469. /**
  86470. * Gets the minimum vector in local space
  86471. */
  86472. readonly minimum: Vector3;
  86473. /**
  86474. * Gets the maximum vector in local space
  86475. */
  86476. readonly maximum: Vector3;
  86477. private _worldMatrix;
  86478. private static readonly TmpVector3;
  86479. /**
  86480. * Creates a new bounding sphere
  86481. * @param min defines the minimum vector (in local space)
  86482. * @param max defines the maximum vector (in local space)
  86483. * @param worldMatrix defines the new world matrix
  86484. */
  86485. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86486. /**
  86487. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  86488. * @param min defines the new minimum vector (in local space)
  86489. * @param max defines the new maximum vector (in local space)
  86490. * @param worldMatrix defines the new world matrix
  86491. */
  86492. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86493. /**
  86494. * Scale the current bounding sphere by applying a scale factor
  86495. * @param factor defines the scale factor to apply
  86496. * @returns the current bounding box
  86497. */
  86498. scale(factor: number): BoundingSphere;
  86499. /**
  86500. * Gets the world matrix of the bounding box
  86501. * @returns a matrix
  86502. */
  86503. getWorldMatrix(): DeepImmutable<Matrix>;
  86504. /** @hidden */
  86505. _update(worldMatrix: DeepImmutable<Matrix>): void;
  86506. /**
  86507. * Tests if the bounding sphere is intersecting the frustum planes
  86508. * @param frustumPlanes defines the frustum planes to test
  86509. * @returns true if there is an intersection
  86510. */
  86511. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86512. /**
  86513. * Tests if the bounding sphere center is in between the frustum planes.
  86514. * Used for optimistic fast inclusion.
  86515. * @param frustumPlanes defines the frustum planes to test
  86516. * @returns true if the sphere center is in between the frustum planes
  86517. */
  86518. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86519. /**
  86520. * Tests if a point is inside the bounding sphere
  86521. * @param point defines the point to test
  86522. * @returns true if the point is inside the bounding sphere
  86523. */
  86524. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86525. /**
  86526. * Checks if two sphere intersct
  86527. * @param sphere0 sphere 0
  86528. * @param sphere1 sphere 1
  86529. * @returns true if the speres intersect
  86530. */
  86531. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  86532. }
  86533. }
  86534. declare module BABYLON {
  86535. /**
  86536. * Class used to store bounding box information
  86537. */
  86538. export class BoundingBox implements ICullable {
  86539. /**
  86540. * Gets the 8 vectors representing the bounding box in local space
  86541. */
  86542. readonly vectors: Vector3[];
  86543. /**
  86544. * Gets the center of the bounding box in local space
  86545. */
  86546. readonly center: Vector3;
  86547. /**
  86548. * Gets the center of the bounding box in world space
  86549. */
  86550. readonly centerWorld: Vector3;
  86551. /**
  86552. * Gets the extend size in local space
  86553. */
  86554. readonly extendSize: Vector3;
  86555. /**
  86556. * Gets the extend size in world space
  86557. */
  86558. readonly extendSizeWorld: Vector3;
  86559. /**
  86560. * Gets the OBB (object bounding box) directions
  86561. */
  86562. readonly directions: Vector3[];
  86563. /**
  86564. * Gets the 8 vectors representing the bounding box in world space
  86565. */
  86566. readonly vectorsWorld: Vector3[];
  86567. /**
  86568. * Gets the minimum vector in world space
  86569. */
  86570. readonly minimumWorld: Vector3;
  86571. /**
  86572. * Gets the maximum vector in world space
  86573. */
  86574. readonly maximumWorld: Vector3;
  86575. /**
  86576. * Gets the minimum vector in local space
  86577. */
  86578. readonly minimum: Vector3;
  86579. /**
  86580. * Gets the maximum vector in local space
  86581. */
  86582. readonly maximum: Vector3;
  86583. private _worldMatrix;
  86584. private static readonly TmpVector3;
  86585. /**
  86586. * @hidden
  86587. */
  86588. _tag: number;
  86589. /**
  86590. * Creates a new bounding box
  86591. * @param min defines the minimum vector (in local space)
  86592. * @param max defines the maximum vector (in local space)
  86593. * @param worldMatrix defines the new world matrix
  86594. */
  86595. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86596. /**
  86597. * Recreates the entire bounding box from scratch as if we call the constructor in place
  86598. * @param min defines the new minimum vector (in local space)
  86599. * @param max defines the new maximum vector (in local space)
  86600. * @param worldMatrix defines the new world matrix
  86601. */
  86602. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86603. /**
  86604. * Scale the current bounding box by applying a scale factor
  86605. * @param factor defines the scale factor to apply
  86606. * @returns the current bounding box
  86607. */
  86608. scale(factor: number): BoundingBox;
  86609. /**
  86610. * Gets the world matrix of the bounding box
  86611. * @returns a matrix
  86612. */
  86613. getWorldMatrix(): DeepImmutable<Matrix>;
  86614. /** @hidden */
  86615. _update(world: DeepImmutable<Matrix>): void;
  86616. /**
  86617. * Tests if the bounding box is intersecting the frustum planes
  86618. * @param frustumPlanes defines the frustum planes to test
  86619. * @returns true if there is an intersection
  86620. */
  86621. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86622. /**
  86623. * Tests if the bounding box is entirely inside the frustum planes
  86624. * @param frustumPlanes defines the frustum planes to test
  86625. * @returns true if there is an inclusion
  86626. */
  86627. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86628. /**
  86629. * Tests if a point is inside the bounding box
  86630. * @param point defines the point to test
  86631. * @returns true if the point is inside the bounding box
  86632. */
  86633. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86634. /**
  86635. * Tests if the bounding box intersects with a bounding sphere
  86636. * @param sphere defines the sphere to test
  86637. * @returns true if there is an intersection
  86638. */
  86639. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  86640. /**
  86641. * Tests if the bounding box intersects with a box defined by a min and max vectors
  86642. * @param min defines the min vector to use
  86643. * @param max defines the max vector to use
  86644. * @returns true if there is an intersection
  86645. */
  86646. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  86647. /**
  86648. * Tests if two bounding boxes are intersections
  86649. * @param box0 defines the first box to test
  86650. * @param box1 defines the second box to test
  86651. * @returns true if there is an intersection
  86652. */
  86653. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  86654. /**
  86655. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  86656. * @param minPoint defines the minimum vector of the bounding box
  86657. * @param maxPoint defines the maximum vector of the bounding box
  86658. * @param sphereCenter defines the sphere center
  86659. * @param sphereRadius defines the sphere radius
  86660. * @returns true if there is an intersection
  86661. */
  86662. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  86663. /**
  86664. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  86665. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86666. * @param frustumPlanes defines the frustum planes to test
  86667. * @return true if there is an inclusion
  86668. */
  86669. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86670. /**
  86671. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  86672. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86673. * @param frustumPlanes defines the frustum planes to test
  86674. * @return true if there is an intersection
  86675. */
  86676. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86677. }
  86678. }
  86679. declare module BABYLON {
  86680. /** @hidden */
  86681. export class Collider {
  86682. /** Define if a collision was found */
  86683. collisionFound: boolean;
  86684. /**
  86685. * Define last intersection point in local space
  86686. */
  86687. intersectionPoint: Vector3;
  86688. /**
  86689. * Define last collided mesh
  86690. */
  86691. collidedMesh: Nullable<AbstractMesh>;
  86692. private _collisionPoint;
  86693. private _planeIntersectionPoint;
  86694. private _tempVector;
  86695. private _tempVector2;
  86696. private _tempVector3;
  86697. private _tempVector4;
  86698. private _edge;
  86699. private _baseToVertex;
  86700. private _destinationPoint;
  86701. private _slidePlaneNormal;
  86702. private _displacementVector;
  86703. /** @hidden */
  86704. _radius: Vector3;
  86705. /** @hidden */
  86706. _retry: number;
  86707. private _velocity;
  86708. private _basePoint;
  86709. private _epsilon;
  86710. /** @hidden */
  86711. _velocityWorldLength: number;
  86712. /** @hidden */
  86713. _basePointWorld: Vector3;
  86714. private _velocityWorld;
  86715. private _normalizedVelocity;
  86716. /** @hidden */
  86717. _initialVelocity: Vector3;
  86718. /** @hidden */
  86719. _initialPosition: Vector3;
  86720. private _nearestDistance;
  86721. private _collisionMask;
  86722. get collisionMask(): number;
  86723. set collisionMask(mask: number);
  86724. /**
  86725. * Gets the plane normal used to compute the sliding response (in local space)
  86726. */
  86727. get slidePlaneNormal(): Vector3;
  86728. /** @hidden */
  86729. _initialize(source: Vector3, dir: Vector3, e: number): void;
  86730. /** @hidden */
  86731. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  86732. /** @hidden */
  86733. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  86734. /** @hidden */
  86735. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  86736. /** @hidden */
  86737. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  86738. /** @hidden */
  86739. _getResponse(pos: Vector3, vel: Vector3): void;
  86740. }
  86741. }
  86742. declare module BABYLON {
  86743. /**
  86744. * Interface for cullable objects
  86745. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  86746. */
  86747. export interface ICullable {
  86748. /**
  86749. * Checks if the object or part of the object is in the frustum
  86750. * @param frustumPlanes Camera near/planes
  86751. * @returns true if the object is in frustum otherwise false
  86752. */
  86753. isInFrustum(frustumPlanes: Plane[]): boolean;
  86754. /**
  86755. * Checks if a cullable object (mesh...) is in the camera frustum
  86756. * Unlike isInFrustum this cheks the full bounding box
  86757. * @param frustumPlanes Camera near/planes
  86758. * @returns true if the object is in frustum otherwise false
  86759. */
  86760. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86761. }
  86762. /**
  86763. * Info for a bounding data of a mesh
  86764. */
  86765. export class BoundingInfo implements ICullable {
  86766. /**
  86767. * Bounding box for the mesh
  86768. */
  86769. readonly boundingBox: BoundingBox;
  86770. /**
  86771. * Bounding sphere for the mesh
  86772. */
  86773. readonly boundingSphere: BoundingSphere;
  86774. private _isLocked;
  86775. private static readonly TmpVector3;
  86776. /**
  86777. * Constructs bounding info
  86778. * @param minimum min vector of the bounding box/sphere
  86779. * @param maximum max vector of the bounding box/sphere
  86780. * @param worldMatrix defines the new world matrix
  86781. */
  86782. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86783. /**
  86784. * Recreates the entire bounding info from scratch as if we call the constructor in place
  86785. * @param min defines the new minimum vector (in local space)
  86786. * @param max defines the new maximum vector (in local space)
  86787. * @param worldMatrix defines the new world matrix
  86788. */
  86789. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86790. /**
  86791. * min vector of the bounding box/sphere
  86792. */
  86793. get minimum(): Vector3;
  86794. /**
  86795. * max vector of the bounding box/sphere
  86796. */
  86797. get maximum(): Vector3;
  86798. /**
  86799. * If the info is locked and won't be updated to avoid perf overhead
  86800. */
  86801. get isLocked(): boolean;
  86802. set isLocked(value: boolean);
  86803. /**
  86804. * Updates the bounding sphere and box
  86805. * @param world world matrix to be used to update
  86806. */
  86807. update(world: DeepImmutable<Matrix>): void;
  86808. /**
  86809. * Recreate the bounding info to be centered around a specific point given a specific extend.
  86810. * @param center New center of the bounding info
  86811. * @param extend New extend of the bounding info
  86812. * @returns the current bounding info
  86813. */
  86814. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  86815. /**
  86816. * Scale the current bounding info by applying a scale factor
  86817. * @param factor defines the scale factor to apply
  86818. * @returns the current bounding info
  86819. */
  86820. scale(factor: number): BoundingInfo;
  86821. /**
  86822. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  86823. * @param frustumPlanes defines the frustum to test
  86824. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  86825. * @returns true if the bounding info is in the frustum planes
  86826. */
  86827. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  86828. /**
  86829. * Gets the world distance between the min and max points of the bounding box
  86830. */
  86831. get diagonalLength(): number;
  86832. /**
  86833. * Checks if a cullable object (mesh...) is in the camera frustum
  86834. * Unlike isInFrustum this cheks the full bounding box
  86835. * @param frustumPlanes Camera near/planes
  86836. * @returns true if the object is in frustum otherwise false
  86837. */
  86838. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86839. /** @hidden */
  86840. _checkCollision(collider: Collider): boolean;
  86841. /**
  86842. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  86843. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86844. * @param point the point to check intersection with
  86845. * @returns if the point intersects
  86846. */
  86847. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86848. /**
  86849. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  86850. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86851. * @param boundingInfo the bounding info to check intersection with
  86852. * @param precise if the intersection should be done using OBB
  86853. * @returns if the bounding info intersects
  86854. */
  86855. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  86856. }
  86857. }
  86858. declare module BABYLON {
  86859. /**
  86860. * Extracts minimum and maximum values from a list of indexed positions
  86861. * @param positions defines the positions to use
  86862. * @param indices defines the indices to the positions
  86863. * @param indexStart defines the start index
  86864. * @param indexCount defines the end index
  86865. * @param bias defines bias value to add to the result
  86866. * @return minimum and maximum values
  86867. */
  86868. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  86869. minimum: Vector3;
  86870. maximum: Vector3;
  86871. };
  86872. /**
  86873. * Extracts minimum and maximum values from a list of positions
  86874. * @param positions defines the positions to use
  86875. * @param start defines the start index in the positions array
  86876. * @param count defines the number of positions to handle
  86877. * @param bias defines bias value to add to the result
  86878. * @param stride defines the stride size to use (distance between two positions in the positions array)
  86879. * @return minimum and maximum values
  86880. */
  86881. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  86882. minimum: Vector3;
  86883. maximum: Vector3;
  86884. };
  86885. }
  86886. declare module BABYLON {
  86887. /** @hidden */
  86888. export class WebGLDataBuffer extends DataBuffer {
  86889. private _buffer;
  86890. constructor(resource: WebGLBuffer);
  86891. get underlyingResource(): any;
  86892. }
  86893. }
  86894. declare module BABYLON {
  86895. /** @hidden */
  86896. export class WebGLPipelineContext implements IPipelineContext {
  86897. engine: ThinEngine;
  86898. program: Nullable<WebGLProgram>;
  86899. context?: WebGLRenderingContext;
  86900. vertexShader?: WebGLShader;
  86901. fragmentShader?: WebGLShader;
  86902. isParallelCompiled: boolean;
  86903. onCompiled?: () => void;
  86904. transformFeedback?: WebGLTransformFeedback | null;
  86905. vertexCompilationError: Nullable<string>;
  86906. fragmentCompilationError: Nullable<string>;
  86907. programLinkError: Nullable<string>;
  86908. programValidationError: Nullable<string>;
  86909. get isAsync(): boolean;
  86910. get isReady(): boolean;
  86911. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86912. _getVertexShaderCode(): string | null;
  86913. _getFragmentShaderCode(): string | null;
  86914. }
  86915. }
  86916. declare module BABYLON {
  86917. interface ThinEngine {
  86918. /**
  86919. * Create an uniform buffer
  86920. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86921. * @param elements defines the content of the uniform buffer
  86922. * @returns the webGL uniform buffer
  86923. */
  86924. createUniformBuffer(elements: FloatArray): DataBuffer;
  86925. /**
  86926. * Create a dynamic uniform buffer
  86927. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86928. * @param elements defines the content of the uniform buffer
  86929. * @returns the webGL uniform buffer
  86930. */
  86931. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  86932. /**
  86933. * Update an existing uniform buffer
  86934. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86935. * @param uniformBuffer defines the target uniform buffer
  86936. * @param elements defines the content to update
  86937. * @param offset defines the offset in the uniform buffer where update should start
  86938. * @param count defines the size of the data to update
  86939. */
  86940. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  86941. /**
  86942. * Bind an uniform buffer to the current webGL context
  86943. * @param buffer defines the buffer to bind
  86944. */
  86945. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  86946. /**
  86947. * Bind a buffer to the current webGL context at a given location
  86948. * @param buffer defines the buffer to bind
  86949. * @param location defines the index where to bind the buffer
  86950. */
  86951. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  86952. /**
  86953. * Bind a specific block at a given index in a specific shader program
  86954. * @param pipelineContext defines the pipeline context to use
  86955. * @param blockName defines the block name
  86956. * @param index defines the index where to bind the block
  86957. */
  86958. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  86959. }
  86960. }
  86961. declare module BABYLON {
  86962. /**
  86963. * Uniform buffer objects.
  86964. *
  86965. * Handles blocks of uniform on the GPU.
  86966. *
  86967. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86968. *
  86969. * For more information, please refer to :
  86970. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86971. */
  86972. export class UniformBuffer {
  86973. private _engine;
  86974. private _buffer;
  86975. private _data;
  86976. private _bufferData;
  86977. private _dynamic?;
  86978. private _uniformLocations;
  86979. private _uniformSizes;
  86980. private _uniformLocationPointer;
  86981. private _needSync;
  86982. private _noUBO;
  86983. private _currentEffect;
  86984. /** @hidden */
  86985. _alreadyBound: boolean;
  86986. private static _MAX_UNIFORM_SIZE;
  86987. private static _tempBuffer;
  86988. /**
  86989. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86990. * This is dynamic to allow compat with webgl 1 and 2.
  86991. * You will need to pass the name of the uniform as well as the value.
  86992. */
  86993. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86994. /**
  86995. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86996. * This is dynamic to allow compat with webgl 1 and 2.
  86997. * You will need to pass the name of the uniform as well as the value.
  86998. */
  86999. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  87000. /**
  87001. * Lambda to Update a single float in a uniform buffer.
  87002. * This is dynamic to allow compat with webgl 1 and 2.
  87003. * You will need to pass the name of the uniform as well as the value.
  87004. */
  87005. updateFloat: (name: string, x: number) => void;
  87006. /**
  87007. * Lambda to Update a vec2 of float in a uniform buffer.
  87008. * This is dynamic to allow compat with webgl 1 and 2.
  87009. * You will need to pass the name of the uniform as well as the value.
  87010. */
  87011. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  87012. /**
  87013. * Lambda to Update a vec3 of float in a uniform buffer.
  87014. * This is dynamic to allow compat with webgl 1 and 2.
  87015. * You will need to pass the name of the uniform as well as the value.
  87016. */
  87017. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  87018. /**
  87019. * Lambda to Update a vec4 of float in a uniform buffer.
  87020. * This is dynamic to allow compat with webgl 1 and 2.
  87021. * You will need to pass the name of the uniform as well as the value.
  87022. */
  87023. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  87024. /**
  87025. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  87026. * This is dynamic to allow compat with webgl 1 and 2.
  87027. * You will need to pass the name of the uniform as well as the value.
  87028. */
  87029. updateMatrix: (name: string, mat: Matrix) => void;
  87030. /**
  87031. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  87032. * This is dynamic to allow compat with webgl 1 and 2.
  87033. * You will need to pass the name of the uniform as well as the value.
  87034. */
  87035. updateVector3: (name: string, vector: Vector3) => void;
  87036. /**
  87037. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  87038. * This is dynamic to allow compat with webgl 1 and 2.
  87039. * You will need to pass the name of the uniform as well as the value.
  87040. */
  87041. updateVector4: (name: string, vector: Vector4) => void;
  87042. /**
  87043. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  87044. * This is dynamic to allow compat with webgl 1 and 2.
  87045. * You will need to pass the name of the uniform as well as the value.
  87046. */
  87047. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  87048. /**
  87049. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  87050. * This is dynamic to allow compat with webgl 1 and 2.
  87051. * You will need to pass the name of the uniform as well as the value.
  87052. */
  87053. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  87054. /**
  87055. * Instantiates a new Uniform buffer objects.
  87056. *
  87057. * Handles blocks of uniform on the GPU.
  87058. *
  87059. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87060. *
  87061. * For more information, please refer to :
  87062. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87063. * @param engine Define the engine the buffer is associated with
  87064. * @param data Define the data contained in the buffer
  87065. * @param dynamic Define if the buffer is updatable
  87066. */
  87067. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  87068. /**
  87069. * Indicates if the buffer is using the WebGL2 UBO implementation,
  87070. * or just falling back on setUniformXXX calls.
  87071. */
  87072. get useUbo(): boolean;
  87073. /**
  87074. * Indicates if the WebGL underlying uniform buffer is in sync
  87075. * with the javascript cache data.
  87076. */
  87077. get isSync(): boolean;
  87078. /**
  87079. * Indicates if the WebGL underlying uniform buffer is dynamic.
  87080. * Also, a dynamic UniformBuffer will disable cache verification and always
  87081. * update the underlying WebGL uniform buffer to the GPU.
  87082. * @returns if Dynamic, otherwise false
  87083. */
  87084. isDynamic(): boolean;
  87085. /**
  87086. * The data cache on JS side.
  87087. * @returns the underlying data as a float array
  87088. */
  87089. getData(): Float32Array;
  87090. /**
  87091. * The underlying WebGL Uniform buffer.
  87092. * @returns the webgl buffer
  87093. */
  87094. getBuffer(): Nullable<DataBuffer>;
  87095. /**
  87096. * std140 layout specifies how to align data within an UBO structure.
  87097. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  87098. * for specs.
  87099. */
  87100. private _fillAlignment;
  87101. /**
  87102. * Adds an uniform in the buffer.
  87103. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  87104. * for the layout to be correct !
  87105. * @param name Name of the uniform, as used in the uniform block in the shader.
  87106. * @param size Data size, or data directly.
  87107. */
  87108. addUniform(name: string, size: number | number[]): void;
  87109. /**
  87110. * Adds a Matrix 4x4 to the uniform buffer.
  87111. * @param name Name of the uniform, as used in the uniform block in the shader.
  87112. * @param mat A 4x4 matrix.
  87113. */
  87114. addMatrix(name: string, mat: Matrix): void;
  87115. /**
  87116. * Adds a vec2 to the uniform buffer.
  87117. * @param name Name of the uniform, as used in the uniform block in the shader.
  87118. * @param x Define the x component value of the vec2
  87119. * @param y Define the y component value of the vec2
  87120. */
  87121. addFloat2(name: string, x: number, y: number): void;
  87122. /**
  87123. * Adds a vec3 to the uniform buffer.
  87124. * @param name Name of the uniform, as used in the uniform block in the shader.
  87125. * @param x Define the x component value of the vec3
  87126. * @param y Define the y component value of the vec3
  87127. * @param z Define the z component value of the vec3
  87128. */
  87129. addFloat3(name: string, x: number, y: number, z: number): void;
  87130. /**
  87131. * Adds a vec3 to the uniform buffer.
  87132. * @param name Name of the uniform, as used in the uniform block in the shader.
  87133. * @param color Define the vec3 from a Color
  87134. */
  87135. addColor3(name: string, color: Color3): void;
  87136. /**
  87137. * Adds a vec4 to the uniform buffer.
  87138. * @param name Name of the uniform, as used in the uniform block in the shader.
  87139. * @param color Define the rgb components from a Color
  87140. * @param alpha Define the a component of the vec4
  87141. */
  87142. addColor4(name: string, color: Color3, alpha: number): void;
  87143. /**
  87144. * Adds a vec3 to the uniform buffer.
  87145. * @param name Name of the uniform, as used in the uniform block in the shader.
  87146. * @param vector Define the vec3 components from a Vector
  87147. */
  87148. addVector3(name: string, vector: Vector3): void;
  87149. /**
  87150. * Adds a Matrix 3x3 to the uniform buffer.
  87151. * @param name Name of the uniform, as used in the uniform block in the shader.
  87152. */
  87153. addMatrix3x3(name: string): void;
  87154. /**
  87155. * Adds a Matrix 2x2 to the uniform buffer.
  87156. * @param name Name of the uniform, as used in the uniform block in the shader.
  87157. */
  87158. addMatrix2x2(name: string): void;
  87159. /**
  87160. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  87161. */
  87162. create(): void;
  87163. /** @hidden */
  87164. _rebuild(): void;
  87165. /**
  87166. * Updates the WebGL Uniform Buffer on the GPU.
  87167. * If the `dynamic` flag is set to true, no cache comparison is done.
  87168. * Otherwise, the buffer will be updated only if the cache differs.
  87169. */
  87170. update(): void;
  87171. /**
  87172. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  87173. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87174. * @param data Define the flattened data
  87175. * @param size Define the size of the data.
  87176. */
  87177. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  87178. private _valueCache;
  87179. private _cacheMatrix;
  87180. private _updateMatrix3x3ForUniform;
  87181. private _updateMatrix3x3ForEffect;
  87182. private _updateMatrix2x2ForEffect;
  87183. private _updateMatrix2x2ForUniform;
  87184. private _updateFloatForEffect;
  87185. private _updateFloatForUniform;
  87186. private _updateFloat2ForEffect;
  87187. private _updateFloat2ForUniform;
  87188. private _updateFloat3ForEffect;
  87189. private _updateFloat3ForUniform;
  87190. private _updateFloat4ForEffect;
  87191. private _updateFloat4ForUniform;
  87192. private _updateMatrixForEffect;
  87193. private _updateMatrixForUniform;
  87194. private _updateVector3ForEffect;
  87195. private _updateVector3ForUniform;
  87196. private _updateVector4ForEffect;
  87197. private _updateVector4ForUniform;
  87198. private _updateColor3ForEffect;
  87199. private _updateColor3ForUniform;
  87200. private _updateColor4ForEffect;
  87201. private _updateColor4ForUniform;
  87202. /**
  87203. * Sets a sampler uniform on the effect.
  87204. * @param name Define the name of the sampler.
  87205. * @param texture Define the texture to set in the sampler
  87206. */
  87207. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  87208. /**
  87209. * Directly updates the value of the uniform in the cache AND on the GPU.
  87210. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87211. * @param data Define the flattened data
  87212. */
  87213. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  87214. /**
  87215. * Binds this uniform buffer to an effect.
  87216. * @param effect Define the effect to bind the buffer to
  87217. * @param name Name of the uniform block in the shader.
  87218. */
  87219. bindToEffect(effect: Effect, name: string): void;
  87220. /**
  87221. * Disposes the uniform buffer.
  87222. */
  87223. dispose(): void;
  87224. }
  87225. }
  87226. declare module BABYLON {
  87227. /**
  87228. * Enum that determines the text-wrapping mode to use.
  87229. */
  87230. export enum InspectableType {
  87231. /**
  87232. * Checkbox for booleans
  87233. */
  87234. Checkbox = 0,
  87235. /**
  87236. * Sliders for numbers
  87237. */
  87238. Slider = 1,
  87239. /**
  87240. * Vector3
  87241. */
  87242. Vector3 = 2,
  87243. /**
  87244. * Quaternions
  87245. */
  87246. Quaternion = 3,
  87247. /**
  87248. * Color3
  87249. */
  87250. Color3 = 4,
  87251. /**
  87252. * String
  87253. */
  87254. String = 5
  87255. }
  87256. /**
  87257. * Interface used to define custom inspectable properties.
  87258. * This interface is used by the inspector to display custom property grids
  87259. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87260. */
  87261. export interface IInspectable {
  87262. /**
  87263. * Gets the label to display
  87264. */
  87265. label: string;
  87266. /**
  87267. * Gets the name of the property to edit
  87268. */
  87269. propertyName: string;
  87270. /**
  87271. * Gets the type of the editor to use
  87272. */
  87273. type: InspectableType;
  87274. /**
  87275. * Gets the minimum value of the property when using in "slider" mode
  87276. */
  87277. min?: number;
  87278. /**
  87279. * Gets the maximum value of the property when using in "slider" mode
  87280. */
  87281. max?: number;
  87282. /**
  87283. * Gets the setp to use when using in "slider" mode
  87284. */
  87285. step?: number;
  87286. }
  87287. }
  87288. declare module BABYLON {
  87289. /**
  87290. * Class used to provide helper for timing
  87291. */
  87292. export class TimingTools {
  87293. /**
  87294. * Polyfill for setImmediate
  87295. * @param action defines the action to execute after the current execution block
  87296. */
  87297. static SetImmediate(action: () => void): void;
  87298. }
  87299. }
  87300. declare module BABYLON {
  87301. /**
  87302. * Class used to enable instatition of objects by class name
  87303. */
  87304. export class InstantiationTools {
  87305. /**
  87306. * Use this object to register external classes like custom textures or material
  87307. * to allow the laoders to instantiate them
  87308. */
  87309. static RegisteredExternalClasses: {
  87310. [key: string]: Object;
  87311. };
  87312. /**
  87313. * Tries to instantiate a new object from a given class name
  87314. * @param className defines the class name to instantiate
  87315. * @returns the new object or null if the system was not able to do the instantiation
  87316. */
  87317. static Instantiate(className: string): any;
  87318. }
  87319. }
  87320. declare module BABYLON {
  87321. /**
  87322. * Define options used to create a depth texture
  87323. */
  87324. export class DepthTextureCreationOptions {
  87325. /** Specifies whether or not a stencil should be allocated in the texture */
  87326. generateStencil?: boolean;
  87327. /** Specifies whether or not bilinear filtering is enable on the texture */
  87328. bilinearFiltering?: boolean;
  87329. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  87330. comparisonFunction?: number;
  87331. /** Specifies if the created texture is a cube texture */
  87332. isCube?: boolean;
  87333. }
  87334. }
  87335. declare module BABYLON {
  87336. interface ThinEngine {
  87337. /**
  87338. * Creates a depth stencil cube texture.
  87339. * This is only available in WebGL 2.
  87340. * @param size The size of face edge in the cube texture.
  87341. * @param options The options defining the cube texture.
  87342. * @returns The cube texture
  87343. */
  87344. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  87345. /**
  87346. * Creates a cube texture
  87347. * @param rootUrl defines the url where the files to load is located
  87348. * @param scene defines the current scene
  87349. * @param files defines the list of files to load (1 per face)
  87350. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87351. * @param onLoad defines an optional callback raised when the texture is loaded
  87352. * @param onError defines an optional callback raised if there is an issue to load the texture
  87353. * @param format defines the format of the data
  87354. * @param forcedExtension defines the extension to use to pick the right loader
  87355. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87356. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87357. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87358. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87359. * @returns the cube texture as an InternalTexture
  87360. */
  87361. 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;
  87362. /**
  87363. * Creates a cube texture
  87364. * @param rootUrl defines the url where the files to load is located
  87365. * @param scene defines the current scene
  87366. * @param files defines the list of files to load (1 per face)
  87367. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87368. * @param onLoad defines an optional callback raised when the texture is loaded
  87369. * @param onError defines an optional callback raised if there is an issue to load the texture
  87370. * @param format defines the format of the data
  87371. * @param forcedExtension defines the extension to use to pick the right loader
  87372. * @returns the cube texture as an InternalTexture
  87373. */
  87374. 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;
  87375. /**
  87376. * Creates a cube texture
  87377. * @param rootUrl defines the url where the files to load is located
  87378. * @param scene defines the current scene
  87379. * @param files defines the list of files to load (1 per face)
  87380. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87381. * @param onLoad defines an optional callback raised when the texture is loaded
  87382. * @param onError defines an optional callback raised if there is an issue to load the texture
  87383. * @param format defines the format of the data
  87384. * @param forcedExtension defines the extension to use to pick the right loader
  87385. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87386. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87387. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87388. * @returns the cube texture as an InternalTexture
  87389. */
  87390. 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;
  87391. /** @hidden */
  87392. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  87393. /** @hidden */
  87394. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  87395. /** @hidden */
  87396. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  87397. /** @hidden */
  87398. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  87399. /**
  87400. * @hidden
  87401. */
  87402. _setCubeMapTextureParams(loadMipmap: boolean): void;
  87403. }
  87404. }
  87405. declare module BABYLON {
  87406. /**
  87407. * Class for creating a cube texture
  87408. */
  87409. export class CubeTexture extends BaseTexture {
  87410. private _delayedOnLoad;
  87411. /**
  87412. * Observable triggered once the texture has been loaded.
  87413. */
  87414. onLoadObservable: Observable<CubeTexture>;
  87415. /**
  87416. * The url of the texture
  87417. */
  87418. url: string;
  87419. /**
  87420. * Gets or sets the center of the bounding box associated with the cube texture.
  87421. * It must define where the camera used to render the texture was set
  87422. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  87423. */
  87424. boundingBoxPosition: Vector3;
  87425. private _boundingBoxSize;
  87426. /**
  87427. * Gets or sets the size of the bounding box associated with the cube texture
  87428. * When defined, the cubemap will switch to local mode
  87429. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87430. * @example https://www.babylonjs-playground.com/#RNASML
  87431. */
  87432. set boundingBoxSize(value: Vector3);
  87433. /**
  87434. * Returns the bounding box size
  87435. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  87436. */
  87437. get boundingBoxSize(): Vector3;
  87438. protected _rotationY: number;
  87439. /**
  87440. * Sets texture matrix rotation angle around Y axis in radians.
  87441. */
  87442. set rotationY(value: number);
  87443. /**
  87444. * Gets texture matrix rotation angle around Y axis radians.
  87445. */
  87446. get rotationY(): number;
  87447. /**
  87448. * Are mip maps generated for this texture or not.
  87449. */
  87450. get noMipmap(): boolean;
  87451. private _noMipmap;
  87452. private _files;
  87453. protected _forcedExtension: Nullable<string>;
  87454. private _extensions;
  87455. private _textureMatrix;
  87456. private _format;
  87457. private _createPolynomials;
  87458. /**
  87459. * Creates a cube texture from an array of image urls
  87460. * @param files defines an array of image urls
  87461. * @param scene defines the hosting scene
  87462. * @param noMipmap specifies if mip maps are not used
  87463. * @returns a cube texture
  87464. */
  87465. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  87466. /**
  87467. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  87468. * @param url defines the url of the prefiltered texture
  87469. * @param scene defines the scene the texture is attached to
  87470. * @param forcedExtension defines the extension of the file if different from the url
  87471. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  87472. * @return the prefiltered texture
  87473. */
  87474. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  87475. /**
  87476. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  87477. * as prefiltered data.
  87478. * @param rootUrl defines the url of the texture or the root name of the six images
  87479. * @param null defines the scene or engine the texture is attached to
  87480. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  87481. * @param noMipmap defines if mipmaps should be created or not
  87482. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  87483. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  87484. * @param onError defines a callback triggered in case of error during load
  87485. * @param format defines the internal format to use for the texture once loaded
  87486. * @param prefiltered defines whether or not the texture is created from prefiltered data
  87487. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  87488. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  87489. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87490. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87491. * @return the cube texture
  87492. */
  87493. 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);
  87494. /**
  87495. * Get the current class name of the texture useful for serialization or dynamic coding.
  87496. * @returns "CubeTexture"
  87497. */
  87498. getClassName(): string;
  87499. /**
  87500. * Update the url (and optional buffer) of this texture if url was null during construction.
  87501. * @param url the url of the texture
  87502. * @param forcedExtension defines the extension to use
  87503. * @param onLoad callback called when the texture is loaded (defaults to null)
  87504. * @param prefiltered Defines whether the updated texture is prefiltered or not
  87505. */
  87506. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  87507. /**
  87508. * Delays loading of the cube texture
  87509. * @param forcedExtension defines the extension to use
  87510. */
  87511. delayLoad(forcedExtension?: string): void;
  87512. /**
  87513. * Returns the reflection texture matrix
  87514. * @returns the reflection texture matrix
  87515. */
  87516. getReflectionTextureMatrix(): Matrix;
  87517. /**
  87518. * Sets the reflection texture matrix
  87519. * @param value Reflection texture matrix
  87520. */
  87521. setReflectionTextureMatrix(value: Matrix): void;
  87522. /**
  87523. * Parses text to create a cube texture
  87524. * @param parsedTexture define the serialized text to read from
  87525. * @param scene defines the hosting scene
  87526. * @param rootUrl defines the root url of the cube texture
  87527. * @returns a cube texture
  87528. */
  87529. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  87530. /**
  87531. * Makes a clone, or deep copy, of the cube texture
  87532. * @returns a new cube texture
  87533. */
  87534. clone(): CubeTexture;
  87535. }
  87536. }
  87537. declare module BABYLON {
  87538. /**
  87539. * Manages the defines for the Material
  87540. */
  87541. export class MaterialDefines {
  87542. /** @hidden */
  87543. protected _keys: string[];
  87544. private _isDirty;
  87545. /** @hidden */
  87546. _renderId: number;
  87547. /** @hidden */
  87548. _areLightsDirty: boolean;
  87549. /** @hidden */
  87550. _areLightsDisposed: boolean;
  87551. /** @hidden */
  87552. _areAttributesDirty: boolean;
  87553. /** @hidden */
  87554. _areTexturesDirty: boolean;
  87555. /** @hidden */
  87556. _areFresnelDirty: boolean;
  87557. /** @hidden */
  87558. _areMiscDirty: boolean;
  87559. /** @hidden */
  87560. _areImageProcessingDirty: boolean;
  87561. /** @hidden */
  87562. _normals: boolean;
  87563. /** @hidden */
  87564. _uvs: boolean;
  87565. /** @hidden */
  87566. _needNormals: boolean;
  87567. /** @hidden */
  87568. _needUVs: boolean;
  87569. [id: string]: any;
  87570. /**
  87571. * Specifies if the material needs to be re-calculated
  87572. */
  87573. get isDirty(): boolean;
  87574. /**
  87575. * Marks the material to indicate that it has been re-calculated
  87576. */
  87577. markAsProcessed(): void;
  87578. /**
  87579. * Marks the material to indicate that it needs to be re-calculated
  87580. */
  87581. markAsUnprocessed(): void;
  87582. /**
  87583. * Marks the material to indicate all of its defines need to be re-calculated
  87584. */
  87585. markAllAsDirty(): void;
  87586. /**
  87587. * Marks the material to indicate that image processing needs to be re-calculated
  87588. */
  87589. markAsImageProcessingDirty(): void;
  87590. /**
  87591. * Marks the material to indicate the lights need to be re-calculated
  87592. * @param disposed Defines whether the light is dirty due to dispose or not
  87593. */
  87594. markAsLightDirty(disposed?: boolean): void;
  87595. /**
  87596. * Marks the attribute state as changed
  87597. */
  87598. markAsAttributesDirty(): void;
  87599. /**
  87600. * Marks the texture state as changed
  87601. */
  87602. markAsTexturesDirty(): void;
  87603. /**
  87604. * Marks the fresnel state as changed
  87605. */
  87606. markAsFresnelDirty(): void;
  87607. /**
  87608. * Marks the misc state as changed
  87609. */
  87610. markAsMiscDirty(): void;
  87611. /**
  87612. * Rebuilds the material defines
  87613. */
  87614. rebuild(): void;
  87615. /**
  87616. * Specifies if two material defines are equal
  87617. * @param other - A material define instance to compare to
  87618. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  87619. */
  87620. isEqual(other: MaterialDefines): boolean;
  87621. /**
  87622. * Clones this instance's defines to another instance
  87623. * @param other - material defines to clone values to
  87624. */
  87625. cloneTo(other: MaterialDefines): void;
  87626. /**
  87627. * Resets the material define values
  87628. */
  87629. reset(): void;
  87630. /**
  87631. * Converts the material define values to a string
  87632. * @returns - String of material define information
  87633. */
  87634. toString(): string;
  87635. }
  87636. }
  87637. declare module BABYLON {
  87638. /**
  87639. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  87640. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  87641. * 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;
  87642. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  87643. */
  87644. export class ColorCurves {
  87645. private _dirty;
  87646. private _tempColor;
  87647. private _globalCurve;
  87648. private _highlightsCurve;
  87649. private _midtonesCurve;
  87650. private _shadowsCurve;
  87651. private _positiveCurve;
  87652. private _negativeCurve;
  87653. private _globalHue;
  87654. private _globalDensity;
  87655. private _globalSaturation;
  87656. private _globalExposure;
  87657. /**
  87658. * Gets the global Hue value.
  87659. * 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).
  87660. */
  87661. get globalHue(): number;
  87662. /**
  87663. * Sets the global Hue value.
  87664. * 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).
  87665. */
  87666. set globalHue(value: number);
  87667. /**
  87668. * Gets the global Density value.
  87669. * 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.
  87670. * Values less than zero provide a filter of opposite hue.
  87671. */
  87672. get globalDensity(): number;
  87673. /**
  87674. * Sets the global Density value.
  87675. * 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.
  87676. * Values less than zero provide a filter of opposite hue.
  87677. */
  87678. set globalDensity(value: number);
  87679. /**
  87680. * Gets the global Saturation value.
  87681. * 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.
  87682. */
  87683. get globalSaturation(): number;
  87684. /**
  87685. * Sets the global Saturation value.
  87686. * 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.
  87687. */
  87688. set globalSaturation(value: number);
  87689. /**
  87690. * Gets the global Exposure value.
  87691. * 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.
  87692. */
  87693. get globalExposure(): number;
  87694. /**
  87695. * Sets the global Exposure value.
  87696. * 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.
  87697. */
  87698. set globalExposure(value: number);
  87699. private _highlightsHue;
  87700. private _highlightsDensity;
  87701. private _highlightsSaturation;
  87702. private _highlightsExposure;
  87703. /**
  87704. * Gets the highlights Hue value.
  87705. * 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).
  87706. */
  87707. get highlightsHue(): number;
  87708. /**
  87709. * Sets the highlights Hue value.
  87710. * 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).
  87711. */
  87712. set highlightsHue(value: number);
  87713. /**
  87714. * Gets the highlights Density value.
  87715. * 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.
  87716. * Values less than zero provide a filter of opposite hue.
  87717. */
  87718. get highlightsDensity(): number;
  87719. /**
  87720. * Sets the highlights Density value.
  87721. * 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.
  87722. * Values less than zero provide a filter of opposite hue.
  87723. */
  87724. set highlightsDensity(value: number);
  87725. /**
  87726. * Gets the highlights Saturation value.
  87727. * 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.
  87728. */
  87729. get highlightsSaturation(): number;
  87730. /**
  87731. * Sets the highlights Saturation value.
  87732. * 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.
  87733. */
  87734. set highlightsSaturation(value: number);
  87735. /**
  87736. * Gets the highlights Exposure value.
  87737. * 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.
  87738. */
  87739. get highlightsExposure(): number;
  87740. /**
  87741. * Sets the highlights Exposure value.
  87742. * 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.
  87743. */
  87744. set highlightsExposure(value: number);
  87745. private _midtonesHue;
  87746. private _midtonesDensity;
  87747. private _midtonesSaturation;
  87748. private _midtonesExposure;
  87749. /**
  87750. * Gets the midtones Hue value.
  87751. * 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).
  87752. */
  87753. get midtonesHue(): number;
  87754. /**
  87755. * Sets the midtones Hue value.
  87756. * 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).
  87757. */
  87758. set midtonesHue(value: number);
  87759. /**
  87760. * Gets the midtones Density value.
  87761. * 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.
  87762. * Values less than zero provide a filter of opposite hue.
  87763. */
  87764. get midtonesDensity(): number;
  87765. /**
  87766. * Sets the midtones Density value.
  87767. * 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.
  87768. * Values less than zero provide a filter of opposite hue.
  87769. */
  87770. set midtonesDensity(value: number);
  87771. /**
  87772. * Gets the midtones Saturation value.
  87773. * 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.
  87774. */
  87775. get midtonesSaturation(): number;
  87776. /**
  87777. * Sets the midtones Saturation value.
  87778. * 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.
  87779. */
  87780. set midtonesSaturation(value: number);
  87781. /**
  87782. * Gets the midtones Exposure value.
  87783. * 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.
  87784. */
  87785. get midtonesExposure(): number;
  87786. /**
  87787. * Sets the midtones Exposure value.
  87788. * 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.
  87789. */
  87790. set midtonesExposure(value: number);
  87791. private _shadowsHue;
  87792. private _shadowsDensity;
  87793. private _shadowsSaturation;
  87794. private _shadowsExposure;
  87795. /**
  87796. * Gets the shadows Hue value.
  87797. * 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).
  87798. */
  87799. get shadowsHue(): number;
  87800. /**
  87801. * Sets the shadows Hue value.
  87802. * 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).
  87803. */
  87804. set shadowsHue(value: number);
  87805. /**
  87806. * Gets the shadows Density value.
  87807. * 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.
  87808. * Values less than zero provide a filter of opposite hue.
  87809. */
  87810. get shadowsDensity(): number;
  87811. /**
  87812. * Sets the shadows Density value.
  87813. * 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.
  87814. * Values less than zero provide a filter of opposite hue.
  87815. */
  87816. set shadowsDensity(value: number);
  87817. /**
  87818. * Gets the shadows Saturation value.
  87819. * 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.
  87820. */
  87821. get shadowsSaturation(): number;
  87822. /**
  87823. * Sets the shadows Saturation value.
  87824. * 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.
  87825. */
  87826. set shadowsSaturation(value: number);
  87827. /**
  87828. * Gets the shadows Exposure value.
  87829. * 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.
  87830. */
  87831. get shadowsExposure(): number;
  87832. /**
  87833. * Sets the shadows Exposure value.
  87834. * 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.
  87835. */
  87836. set shadowsExposure(value: number);
  87837. /**
  87838. * Returns the class name
  87839. * @returns The class name
  87840. */
  87841. getClassName(): string;
  87842. /**
  87843. * Binds the color curves to the shader.
  87844. * @param colorCurves The color curve to bind
  87845. * @param effect The effect to bind to
  87846. * @param positiveUniform The positive uniform shader parameter
  87847. * @param neutralUniform The neutral uniform shader parameter
  87848. * @param negativeUniform The negative uniform shader parameter
  87849. */
  87850. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  87851. /**
  87852. * Prepare the list of uniforms associated with the ColorCurves effects.
  87853. * @param uniformsList The list of uniforms used in the effect
  87854. */
  87855. static PrepareUniforms(uniformsList: string[]): void;
  87856. /**
  87857. * Returns color grading data based on a hue, density, saturation and exposure value.
  87858. * @param filterHue The hue of the color filter.
  87859. * @param filterDensity The density of the color filter.
  87860. * @param saturation The saturation.
  87861. * @param exposure The exposure.
  87862. * @param result The result data container.
  87863. */
  87864. private getColorGradingDataToRef;
  87865. /**
  87866. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  87867. * @param value The input slider value in range [-100,100].
  87868. * @returns Adjusted value.
  87869. */
  87870. private static applyColorGradingSliderNonlinear;
  87871. /**
  87872. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  87873. * @param hue The hue (H) input.
  87874. * @param saturation The saturation (S) input.
  87875. * @param brightness The brightness (B) input.
  87876. * @result An RGBA color represented as Vector4.
  87877. */
  87878. private static fromHSBToRef;
  87879. /**
  87880. * Returns a value clamped between min and max
  87881. * @param value The value to clamp
  87882. * @param min The minimum of value
  87883. * @param max The maximum of value
  87884. * @returns The clamped value.
  87885. */
  87886. private static clamp;
  87887. /**
  87888. * Clones the current color curve instance.
  87889. * @return The cloned curves
  87890. */
  87891. clone(): ColorCurves;
  87892. /**
  87893. * Serializes the current color curve instance to a json representation.
  87894. * @return a JSON representation
  87895. */
  87896. serialize(): any;
  87897. /**
  87898. * Parses the color curve from a json representation.
  87899. * @param source the JSON source to parse
  87900. * @return The parsed curves
  87901. */
  87902. static Parse(source: any): ColorCurves;
  87903. }
  87904. }
  87905. declare module BABYLON {
  87906. /**
  87907. * Interface to follow in your material defines to integrate easily the
  87908. * Image proccessing functions.
  87909. * @hidden
  87910. */
  87911. export interface IImageProcessingConfigurationDefines {
  87912. IMAGEPROCESSING: boolean;
  87913. VIGNETTE: boolean;
  87914. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87915. VIGNETTEBLENDMODEOPAQUE: boolean;
  87916. TONEMAPPING: boolean;
  87917. TONEMAPPING_ACES: boolean;
  87918. CONTRAST: boolean;
  87919. EXPOSURE: boolean;
  87920. COLORCURVES: boolean;
  87921. COLORGRADING: boolean;
  87922. COLORGRADING3D: boolean;
  87923. SAMPLER3DGREENDEPTH: boolean;
  87924. SAMPLER3DBGRMAP: boolean;
  87925. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87926. }
  87927. /**
  87928. * @hidden
  87929. */
  87930. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  87931. IMAGEPROCESSING: boolean;
  87932. VIGNETTE: boolean;
  87933. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87934. VIGNETTEBLENDMODEOPAQUE: boolean;
  87935. TONEMAPPING: boolean;
  87936. TONEMAPPING_ACES: boolean;
  87937. CONTRAST: boolean;
  87938. COLORCURVES: boolean;
  87939. COLORGRADING: boolean;
  87940. COLORGRADING3D: boolean;
  87941. SAMPLER3DGREENDEPTH: boolean;
  87942. SAMPLER3DBGRMAP: boolean;
  87943. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87944. EXPOSURE: boolean;
  87945. constructor();
  87946. }
  87947. /**
  87948. * This groups together the common properties used for image processing either in direct forward pass
  87949. * or through post processing effect depending on the use of the image processing pipeline in your scene
  87950. * or not.
  87951. */
  87952. export class ImageProcessingConfiguration {
  87953. /**
  87954. * Default tone mapping applied in BabylonJS.
  87955. */
  87956. static readonly TONEMAPPING_STANDARD: number;
  87957. /**
  87958. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  87959. * to other engines rendering to increase portability.
  87960. */
  87961. static readonly TONEMAPPING_ACES: number;
  87962. /**
  87963. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  87964. */
  87965. colorCurves: Nullable<ColorCurves>;
  87966. private _colorCurvesEnabled;
  87967. /**
  87968. * Gets wether the color curves effect is enabled.
  87969. */
  87970. get colorCurvesEnabled(): boolean;
  87971. /**
  87972. * Sets wether the color curves effect is enabled.
  87973. */
  87974. set colorCurvesEnabled(value: boolean);
  87975. private _colorGradingTexture;
  87976. /**
  87977. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87978. */
  87979. get colorGradingTexture(): Nullable<BaseTexture>;
  87980. /**
  87981. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87982. */
  87983. set colorGradingTexture(value: Nullable<BaseTexture>);
  87984. private _colorGradingEnabled;
  87985. /**
  87986. * Gets wether the color grading effect is enabled.
  87987. */
  87988. get colorGradingEnabled(): boolean;
  87989. /**
  87990. * Sets wether the color grading effect is enabled.
  87991. */
  87992. set colorGradingEnabled(value: boolean);
  87993. private _colorGradingWithGreenDepth;
  87994. /**
  87995. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  87996. */
  87997. get colorGradingWithGreenDepth(): boolean;
  87998. /**
  87999. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88000. */
  88001. set colorGradingWithGreenDepth(value: boolean);
  88002. private _colorGradingBGR;
  88003. /**
  88004. * Gets wether the color grading texture contains BGR values.
  88005. */
  88006. get colorGradingBGR(): boolean;
  88007. /**
  88008. * Sets wether the color grading texture contains BGR values.
  88009. */
  88010. set colorGradingBGR(value: boolean);
  88011. /** @hidden */
  88012. _exposure: number;
  88013. /**
  88014. * Gets the Exposure used in the effect.
  88015. */
  88016. get exposure(): number;
  88017. /**
  88018. * Sets the Exposure used in the effect.
  88019. */
  88020. set exposure(value: number);
  88021. private _toneMappingEnabled;
  88022. /**
  88023. * Gets wether the tone mapping effect is enabled.
  88024. */
  88025. get toneMappingEnabled(): boolean;
  88026. /**
  88027. * Sets wether the tone mapping effect is enabled.
  88028. */
  88029. set toneMappingEnabled(value: boolean);
  88030. private _toneMappingType;
  88031. /**
  88032. * Gets the type of tone mapping effect.
  88033. */
  88034. get toneMappingType(): number;
  88035. /**
  88036. * Sets the type of tone mapping effect used in BabylonJS.
  88037. */
  88038. set toneMappingType(value: number);
  88039. protected _contrast: number;
  88040. /**
  88041. * Gets the contrast used in the effect.
  88042. */
  88043. get contrast(): number;
  88044. /**
  88045. * Sets the contrast used in the effect.
  88046. */
  88047. set contrast(value: number);
  88048. /**
  88049. * Vignette stretch size.
  88050. */
  88051. vignetteStretch: number;
  88052. /**
  88053. * Vignette centre X Offset.
  88054. */
  88055. vignetteCentreX: number;
  88056. /**
  88057. * Vignette centre Y Offset.
  88058. */
  88059. vignetteCentreY: number;
  88060. /**
  88061. * Vignette weight or intensity of the vignette effect.
  88062. */
  88063. vignetteWeight: number;
  88064. /**
  88065. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88066. * if vignetteEnabled is set to true.
  88067. */
  88068. vignetteColor: Color4;
  88069. /**
  88070. * Camera field of view used by the Vignette effect.
  88071. */
  88072. vignetteCameraFov: number;
  88073. private _vignetteBlendMode;
  88074. /**
  88075. * Gets the vignette blend mode allowing different kind of effect.
  88076. */
  88077. get vignetteBlendMode(): number;
  88078. /**
  88079. * Sets the vignette blend mode allowing different kind of effect.
  88080. */
  88081. set vignetteBlendMode(value: number);
  88082. private _vignetteEnabled;
  88083. /**
  88084. * Gets wether the vignette effect is enabled.
  88085. */
  88086. get vignetteEnabled(): boolean;
  88087. /**
  88088. * Sets wether the vignette effect is enabled.
  88089. */
  88090. set vignetteEnabled(value: boolean);
  88091. private _applyByPostProcess;
  88092. /**
  88093. * Gets wether the image processing is applied through a post process or not.
  88094. */
  88095. get applyByPostProcess(): boolean;
  88096. /**
  88097. * Sets wether the image processing is applied through a post process or not.
  88098. */
  88099. set applyByPostProcess(value: boolean);
  88100. private _isEnabled;
  88101. /**
  88102. * Gets wether the image processing is enabled or not.
  88103. */
  88104. get isEnabled(): boolean;
  88105. /**
  88106. * Sets wether the image processing is enabled or not.
  88107. */
  88108. set isEnabled(value: boolean);
  88109. /**
  88110. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88111. */
  88112. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88113. /**
  88114. * Method called each time the image processing information changes requires to recompile the effect.
  88115. */
  88116. protected _updateParameters(): void;
  88117. /**
  88118. * Gets the current class name.
  88119. * @return "ImageProcessingConfiguration"
  88120. */
  88121. getClassName(): string;
  88122. /**
  88123. * Prepare the list of uniforms associated with the Image Processing effects.
  88124. * @param uniforms The list of uniforms used in the effect
  88125. * @param defines the list of defines currently in use
  88126. */
  88127. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88128. /**
  88129. * Prepare the list of samplers associated with the Image Processing effects.
  88130. * @param samplersList The list of uniforms used in the effect
  88131. * @param defines the list of defines currently in use
  88132. */
  88133. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88134. /**
  88135. * Prepare the list of defines associated to the shader.
  88136. * @param defines the list of defines to complete
  88137. * @param forPostProcess Define if we are currently in post process mode or not
  88138. */
  88139. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88140. /**
  88141. * Returns true if all the image processing information are ready.
  88142. * @returns True if ready, otherwise, false
  88143. */
  88144. isReady(): boolean;
  88145. /**
  88146. * Binds the image processing to the shader.
  88147. * @param effect The effect to bind to
  88148. * @param overrideAspectRatio Override the aspect ratio of the effect
  88149. */
  88150. bind(effect: Effect, overrideAspectRatio?: number): void;
  88151. /**
  88152. * Clones the current image processing instance.
  88153. * @return The cloned image processing
  88154. */
  88155. clone(): ImageProcessingConfiguration;
  88156. /**
  88157. * Serializes the current image processing instance to a json representation.
  88158. * @return a JSON representation
  88159. */
  88160. serialize(): any;
  88161. /**
  88162. * Parses the image processing from a json representation.
  88163. * @param source the JSON source to parse
  88164. * @return The parsed image processing
  88165. */
  88166. static Parse(source: any): ImageProcessingConfiguration;
  88167. private static _VIGNETTEMODE_MULTIPLY;
  88168. private static _VIGNETTEMODE_OPAQUE;
  88169. /**
  88170. * Used to apply the vignette as a mix with the pixel color.
  88171. */
  88172. static get VIGNETTEMODE_MULTIPLY(): number;
  88173. /**
  88174. * Used to apply the vignette as a replacement of the pixel color.
  88175. */
  88176. static get VIGNETTEMODE_OPAQUE(): number;
  88177. }
  88178. }
  88179. declare module BABYLON {
  88180. /** @hidden */
  88181. export var postprocessVertexShader: {
  88182. name: string;
  88183. shader: string;
  88184. };
  88185. }
  88186. declare module BABYLON {
  88187. interface ThinEngine {
  88188. /**
  88189. * Creates a new render target texture
  88190. * @param size defines the size of the texture
  88191. * @param options defines the options used to create the texture
  88192. * @returns a new render target texture stored in an InternalTexture
  88193. */
  88194. createRenderTargetTexture(size: number | {
  88195. width: number;
  88196. height: number;
  88197. layers?: number;
  88198. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88199. /**
  88200. * Creates a depth stencil texture.
  88201. * This is only available in WebGL 2 or with the depth texture extension available.
  88202. * @param size The size of face edge in the texture.
  88203. * @param options The options defining the texture.
  88204. * @returns The texture
  88205. */
  88206. createDepthStencilTexture(size: number | {
  88207. width: number;
  88208. height: number;
  88209. layers?: number;
  88210. }, options: DepthTextureCreationOptions): InternalTexture;
  88211. /** @hidden */
  88212. _createDepthStencilTexture(size: number | {
  88213. width: number;
  88214. height: number;
  88215. layers?: number;
  88216. }, options: DepthTextureCreationOptions): InternalTexture;
  88217. }
  88218. }
  88219. declare module BABYLON {
  88220. /**
  88221. * Defines the kind of connection point for node based material
  88222. */
  88223. export enum NodeMaterialBlockConnectionPointTypes {
  88224. /** Float */
  88225. Float = 1,
  88226. /** Int */
  88227. Int = 2,
  88228. /** Vector2 */
  88229. Vector2 = 4,
  88230. /** Vector3 */
  88231. Vector3 = 8,
  88232. /** Vector4 */
  88233. Vector4 = 16,
  88234. /** Color3 */
  88235. Color3 = 32,
  88236. /** Color4 */
  88237. Color4 = 64,
  88238. /** Matrix */
  88239. Matrix = 128,
  88240. /** Custom object */
  88241. Object = 256,
  88242. /** Detect type based on connection */
  88243. AutoDetect = 1024,
  88244. /** Output type that will be defined by input type */
  88245. BasedOnInput = 2048
  88246. }
  88247. }
  88248. declare module BABYLON {
  88249. /**
  88250. * Enum used to define the target of a block
  88251. */
  88252. export enum NodeMaterialBlockTargets {
  88253. /** Vertex shader */
  88254. Vertex = 1,
  88255. /** Fragment shader */
  88256. Fragment = 2,
  88257. /** Neutral */
  88258. Neutral = 4,
  88259. /** Vertex and Fragment */
  88260. VertexAndFragment = 3
  88261. }
  88262. }
  88263. declare module BABYLON {
  88264. /**
  88265. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  88266. */
  88267. export enum NodeMaterialBlockConnectionPointMode {
  88268. /** Value is an uniform */
  88269. Uniform = 0,
  88270. /** Value is a mesh attribute */
  88271. Attribute = 1,
  88272. /** Value is a varying between vertex and fragment shaders */
  88273. Varying = 2,
  88274. /** Mode is undefined */
  88275. Undefined = 3
  88276. }
  88277. }
  88278. declare module BABYLON {
  88279. /**
  88280. * Enum used to define system values e.g. values automatically provided by the system
  88281. */
  88282. export enum NodeMaterialSystemValues {
  88283. /** World */
  88284. World = 1,
  88285. /** View */
  88286. View = 2,
  88287. /** Projection */
  88288. Projection = 3,
  88289. /** ViewProjection */
  88290. ViewProjection = 4,
  88291. /** WorldView */
  88292. WorldView = 5,
  88293. /** WorldViewProjection */
  88294. WorldViewProjection = 6,
  88295. /** CameraPosition */
  88296. CameraPosition = 7,
  88297. /** Fog Color */
  88298. FogColor = 8,
  88299. /** Delta time */
  88300. DeltaTime = 9
  88301. }
  88302. }
  88303. declare module BABYLON {
  88304. /** Defines supported spaces */
  88305. export enum Space {
  88306. /** Local (object) space */
  88307. LOCAL = 0,
  88308. /** World space */
  88309. WORLD = 1,
  88310. /** Bone space */
  88311. BONE = 2
  88312. }
  88313. /** Defines the 3 main axes */
  88314. export class Axis {
  88315. /** X axis */
  88316. static X: Vector3;
  88317. /** Y axis */
  88318. static Y: Vector3;
  88319. /** Z axis */
  88320. static Z: Vector3;
  88321. }
  88322. }
  88323. declare module BABYLON {
  88324. /**
  88325. * Represents a camera frustum
  88326. */
  88327. export class Frustum {
  88328. /**
  88329. * Gets the planes representing the frustum
  88330. * @param transform matrix to be applied to the returned planes
  88331. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  88332. */
  88333. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  88334. /**
  88335. * Gets the near frustum plane transformed by the transform matrix
  88336. * @param transform transformation matrix to be applied to the resulting frustum plane
  88337. * @param frustumPlane the resuling frustum plane
  88338. */
  88339. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88340. /**
  88341. * Gets the far frustum plane transformed by the transform matrix
  88342. * @param transform transformation matrix to be applied to the resulting frustum plane
  88343. * @param frustumPlane the resuling frustum plane
  88344. */
  88345. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88346. /**
  88347. * Gets the left frustum plane transformed by the transform matrix
  88348. * @param transform transformation matrix to be applied to the resulting frustum plane
  88349. * @param frustumPlane the resuling frustum plane
  88350. */
  88351. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88352. /**
  88353. * Gets the right frustum plane transformed by the transform matrix
  88354. * @param transform transformation matrix to be applied to the resulting frustum plane
  88355. * @param frustumPlane the resuling frustum plane
  88356. */
  88357. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88358. /**
  88359. * Gets the top frustum plane transformed by the transform matrix
  88360. * @param transform transformation matrix to be applied to the resulting frustum plane
  88361. * @param frustumPlane the resuling frustum plane
  88362. */
  88363. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88364. /**
  88365. * Gets the bottom frustum plane transformed by the transform matrix
  88366. * @param transform transformation matrix to be applied to the resulting frustum plane
  88367. * @param frustumPlane the resuling frustum plane
  88368. */
  88369. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88370. /**
  88371. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  88372. * @param transform transformation matrix to be applied to the resulting frustum planes
  88373. * @param frustumPlanes the resuling frustum planes
  88374. */
  88375. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  88376. }
  88377. }
  88378. declare module BABYLON {
  88379. /**
  88380. * Interface for the size containing width and height
  88381. */
  88382. export interface ISize {
  88383. /**
  88384. * Width
  88385. */
  88386. width: number;
  88387. /**
  88388. * Heighht
  88389. */
  88390. height: number;
  88391. }
  88392. /**
  88393. * Size containing widht and height
  88394. */
  88395. export class Size implements ISize {
  88396. /**
  88397. * Width
  88398. */
  88399. width: number;
  88400. /**
  88401. * Height
  88402. */
  88403. height: number;
  88404. /**
  88405. * Creates a Size object from the given width and height (floats).
  88406. * @param width width of the new size
  88407. * @param height height of the new size
  88408. */
  88409. constructor(width: number, height: number);
  88410. /**
  88411. * Returns a string with the Size width and height
  88412. * @returns a string with the Size width and height
  88413. */
  88414. toString(): string;
  88415. /**
  88416. * "Size"
  88417. * @returns the string "Size"
  88418. */
  88419. getClassName(): string;
  88420. /**
  88421. * Returns the Size hash code.
  88422. * @returns a hash code for a unique width and height
  88423. */
  88424. getHashCode(): number;
  88425. /**
  88426. * Updates the current size from the given one.
  88427. * @param src the given size
  88428. */
  88429. copyFrom(src: Size): void;
  88430. /**
  88431. * Updates in place the current Size from the given floats.
  88432. * @param width width of the new size
  88433. * @param height height of the new size
  88434. * @returns the updated Size.
  88435. */
  88436. copyFromFloats(width: number, height: number): Size;
  88437. /**
  88438. * Updates in place the current Size from the given floats.
  88439. * @param width width to set
  88440. * @param height height to set
  88441. * @returns the updated Size.
  88442. */
  88443. set(width: number, height: number): Size;
  88444. /**
  88445. * Multiplies the width and height by numbers
  88446. * @param w factor to multiple the width by
  88447. * @param h factor to multiple the height by
  88448. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  88449. */
  88450. multiplyByFloats(w: number, h: number): Size;
  88451. /**
  88452. * Clones the size
  88453. * @returns a new Size copied from the given one.
  88454. */
  88455. clone(): Size;
  88456. /**
  88457. * True if the current Size and the given one width and height are strictly equal.
  88458. * @param other the other size to compare against
  88459. * @returns True if the current Size and the given one width and height are strictly equal.
  88460. */
  88461. equals(other: Size): boolean;
  88462. /**
  88463. * The surface of the Size : width * height (float).
  88464. */
  88465. get surface(): number;
  88466. /**
  88467. * Create a new size of zero
  88468. * @returns a new Size set to (0.0, 0.0)
  88469. */
  88470. static Zero(): Size;
  88471. /**
  88472. * Sums the width and height of two sizes
  88473. * @param otherSize size to add to this size
  88474. * @returns a new Size set as the addition result of the current Size and the given one.
  88475. */
  88476. add(otherSize: Size): Size;
  88477. /**
  88478. * Subtracts the width and height of two
  88479. * @param otherSize size to subtract to this size
  88480. * @returns a new Size set as the subtraction result of the given one from the current Size.
  88481. */
  88482. subtract(otherSize: Size): Size;
  88483. /**
  88484. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  88485. * @param start starting size to lerp between
  88486. * @param end end size to lerp between
  88487. * @param amount amount to lerp between the start and end values
  88488. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  88489. */
  88490. static Lerp(start: Size, end: Size, amount: number): Size;
  88491. }
  88492. }
  88493. declare module BABYLON {
  88494. /**
  88495. * Contains position and normal vectors for a vertex
  88496. */
  88497. export class PositionNormalVertex {
  88498. /** the position of the vertex (defaut: 0,0,0) */
  88499. position: Vector3;
  88500. /** the normal of the vertex (defaut: 0,1,0) */
  88501. normal: Vector3;
  88502. /**
  88503. * Creates a PositionNormalVertex
  88504. * @param position the position of the vertex (defaut: 0,0,0)
  88505. * @param normal the normal of the vertex (defaut: 0,1,0)
  88506. */
  88507. constructor(
  88508. /** the position of the vertex (defaut: 0,0,0) */
  88509. position?: Vector3,
  88510. /** the normal of the vertex (defaut: 0,1,0) */
  88511. normal?: Vector3);
  88512. /**
  88513. * Clones the PositionNormalVertex
  88514. * @returns the cloned PositionNormalVertex
  88515. */
  88516. clone(): PositionNormalVertex;
  88517. }
  88518. /**
  88519. * Contains position, normal and uv vectors for a vertex
  88520. */
  88521. export class PositionNormalTextureVertex {
  88522. /** the position of the vertex (defaut: 0,0,0) */
  88523. position: Vector3;
  88524. /** the normal of the vertex (defaut: 0,1,0) */
  88525. normal: Vector3;
  88526. /** the uv of the vertex (default: 0,0) */
  88527. uv: Vector2;
  88528. /**
  88529. * Creates a PositionNormalTextureVertex
  88530. * @param position the position of the vertex (defaut: 0,0,0)
  88531. * @param normal the normal of the vertex (defaut: 0,1,0)
  88532. * @param uv the uv of the vertex (default: 0,0)
  88533. */
  88534. constructor(
  88535. /** the position of the vertex (defaut: 0,0,0) */
  88536. position?: Vector3,
  88537. /** the normal of the vertex (defaut: 0,1,0) */
  88538. normal?: Vector3,
  88539. /** the uv of the vertex (default: 0,0) */
  88540. uv?: Vector2);
  88541. /**
  88542. * Clones the PositionNormalTextureVertex
  88543. * @returns the cloned PositionNormalTextureVertex
  88544. */
  88545. clone(): PositionNormalTextureVertex;
  88546. }
  88547. }
  88548. declare module BABYLON {
  88549. /**
  88550. * Enum defining the type of animations supported by InputBlock
  88551. */
  88552. export enum AnimatedInputBlockTypes {
  88553. /** No animation */
  88554. None = 0,
  88555. /** Time based animation. Will only work for floats */
  88556. Time = 1
  88557. }
  88558. }
  88559. declare module BABYLON {
  88560. /**
  88561. * Interface describing all the common properties and methods a shadow light needs to implement.
  88562. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  88563. * as well as binding the different shadow properties to the effects.
  88564. */
  88565. export interface IShadowLight extends Light {
  88566. /**
  88567. * The light id in the scene (used in scene.findLighById for instance)
  88568. */
  88569. id: string;
  88570. /**
  88571. * The position the shdow will be casted from.
  88572. */
  88573. position: Vector3;
  88574. /**
  88575. * In 2d mode (needCube being false), the direction used to cast the shadow.
  88576. */
  88577. direction: Vector3;
  88578. /**
  88579. * The transformed position. Position of the light in world space taking parenting in account.
  88580. */
  88581. transformedPosition: Vector3;
  88582. /**
  88583. * The transformed direction. Direction of the light in world space taking parenting in account.
  88584. */
  88585. transformedDirection: Vector3;
  88586. /**
  88587. * The friendly name of the light in the scene.
  88588. */
  88589. name: string;
  88590. /**
  88591. * Defines the shadow projection clipping minimum z value.
  88592. */
  88593. shadowMinZ: number;
  88594. /**
  88595. * Defines the shadow projection clipping maximum z value.
  88596. */
  88597. shadowMaxZ: number;
  88598. /**
  88599. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88600. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88601. */
  88602. computeTransformedInformation(): boolean;
  88603. /**
  88604. * Gets the scene the light belongs to.
  88605. * @returns The scene
  88606. */
  88607. getScene(): Scene;
  88608. /**
  88609. * Callback defining a custom Projection Matrix Builder.
  88610. * This can be used to override the default projection matrix computation.
  88611. */
  88612. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88613. /**
  88614. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88615. * @param matrix The materix to updated with the projection information
  88616. * @param viewMatrix The transform matrix of the light
  88617. * @param renderList The list of mesh to render in the map
  88618. * @returns The current light
  88619. */
  88620. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88621. /**
  88622. * Gets the current depth scale used in ESM.
  88623. * @returns The scale
  88624. */
  88625. getDepthScale(): number;
  88626. /**
  88627. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88628. * @returns true if a cube texture needs to be use
  88629. */
  88630. needCube(): boolean;
  88631. /**
  88632. * Detects if the projection matrix requires to be recomputed this frame.
  88633. * @returns true if it requires to be recomputed otherwise, false.
  88634. */
  88635. needProjectionMatrixCompute(): boolean;
  88636. /**
  88637. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88638. */
  88639. forceProjectionMatrixCompute(): void;
  88640. /**
  88641. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88642. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88643. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88644. */
  88645. getShadowDirection(faceIndex?: number): Vector3;
  88646. /**
  88647. * Gets the minZ used for shadow according to both the scene and the light.
  88648. * @param activeCamera The camera we are returning the min for
  88649. * @returns the depth min z
  88650. */
  88651. getDepthMinZ(activeCamera: Camera): number;
  88652. /**
  88653. * Gets the maxZ used for shadow according to both the scene and the light.
  88654. * @param activeCamera The camera we are returning the max for
  88655. * @returns the depth max z
  88656. */
  88657. getDepthMaxZ(activeCamera: Camera): number;
  88658. }
  88659. /**
  88660. * Base implementation IShadowLight
  88661. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  88662. */
  88663. export abstract class ShadowLight extends Light implements IShadowLight {
  88664. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  88665. protected _position: Vector3;
  88666. protected _setPosition(value: Vector3): void;
  88667. /**
  88668. * Sets the position the shadow will be casted from. Also use as the light position for both
  88669. * point and spot lights.
  88670. */
  88671. get position(): Vector3;
  88672. /**
  88673. * Sets the position the shadow will be casted from. Also use as the light position for both
  88674. * point and spot lights.
  88675. */
  88676. set position(value: Vector3);
  88677. protected _direction: Vector3;
  88678. protected _setDirection(value: Vector3): void;
  88679. /**
  88680. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  88681. * Also use as the light direction on spot and directional lights.
  88682. */
  88683. get direction(): Vector3;
  88684. /**
  88685. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  88686. * Also use as the light direction on spot and directional lights.
  88687. */
  88688. set direction(value: Vector3);
  88689. protected _shadowMinZ: number;
  88690. /**
  88691. * Gets the shadow projection clipping minimum z value.
  88692. */
  88693. get shadowMinZ(): number;
  88694. /**
  88695. * Sets the shadow projection clipping minimum z value.
  88696. */
  88697. set shadowMinZ(value: number);
  88698. protected _shadowMaxZ: number;
  88699. /**
  88700. * Sets the shadow projection clipping maximum z value.
  88701. */
  88702. get shadowMaxZ(): number;
  88703. /**
  88704. * Gets the shadow projection clipping maximum z value.
  88705. */
  88706. set shadowMaxZ(value: number);
  88707. /**
  88708. * Callback defining a custom Projection Matrix Builder.
  88709. * This can be used to override the default projection matrix computation.
  88710. */
  88711. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88712. /**
  88713. * The transformed position. Position of the light in world space taking parenting in account.
  88714. */
  88715. transformedPosition: Vector3;
  88716. /**
  88717. * The transformed direction. Direction of the light in world space taking parenting in account.
  88718. */
  88719. transformedDirection: Vector3;
  88720. private _needProjectionMatrixCompute;
  88721. /**
  88722. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88723. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88724. */
  88725. computeTransformedInformation(): boolean;
  88726. /**
  88727. * Return the depth scale used for the shadow map.
  88728. * @returns the depth scale.
  88729. */
  88730. getDepthScale(): number;
  88731. /**
  88732. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88733. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88734. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88735. */
  88736. getShadowDirection(faceIndex?: number): Vector3;
  88737. /**
  88738. * Returns the ShadowLight absolute position in the World.
  88739. * @returns the position vector in world space
  88740. */
  88741. getAbsolutePosition(): Vector3;
  88742. /**
  88743. * Sets the ShadowLight direction toward the passed target.
  88744. * @param target The point to target in local space
  88745. * @returns the updated ShadowLight direction
  88746. */
  88747. setDirectionToTarget(target: Vector3): Vector3;
  88748. /**
  88749. * Returns the light rotation in euler definition.
  88750. * @returns the x y z rotation in local space.
  88751. */
  88752. getRotation(): Vector3;
  88753. /**
  88754. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88755. * @returns true if a cube texture needs to be use
  88756. */
  88757. needCube(): boolean;
  88758. /**
  88759. * Detects if the projection matrix requires to be recomputed this frame.
  88760. * @returns true if it requires to be recomputed otherwise, false.
  88761. */
  88762. needProjectionMatrixCompute(): boolean;
  88763. /**
  88764. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88765. */
  88766. forceProjectionMatrixCompute(): void;
  88767. /** @hidden */
  88768. _initCache(): void;
  88769. /** @hidden */
  88770. _isSynchronized(): boolean;
  88771. /**
  88772. * Computes the world matrix of the node
  88773. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88774. * @returns the world matrix
  88775. */
  88776. computeWorldMatrix(force?: boolean): Matrix;
  88777. /**
  88778. * Gets the minZ used for shadow according to both the scene and the light.
  88779. * @param activeCamera The camera we are returning the min for
  88780. * @returns the depth min z
  88781. */
  88782. getDepthMinZ(activeCamera: Camera): number;
  88783. /**
  88784. * Gets the maxZ used for shadow according to both the scene and the light.
  88785. * @param activeCamera The camera we are returning the max for
  88786. * @returns the depth max z
  88787. */
  88788. getDepthMaxZ(activeCamera: Camera): number;
  88789. /**
  88790. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88791. * @param matrix The materix to updated with the projection information
  88792. * @param viewMatrix The transform matrix of the light
  88793. * @param renderList The list of mesh to render in the map
  88794. * @returns The current light
  88795. */
  88796. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88797. }
  88798. }
  88799. declare module BABYLON {
  88800. /** @hidden */
  88801. export var packingFunctions: {
  88802. name: string;
  88803. shader: string;
  88804. };
  88805. }
  88806. declare module BABYLON {
  88807. /** @hidden */
  88808. export var bayerDitherFunctions: {
  88809. name: string;
  88810. shader: string;
  88811. };
  88812. }
  88813. declare module BABYLON {
  88814. /** @hidden */
  88815. export var shadowMapFragmentDeclaration: {
  88816. name: string;
  88817. shader: string;
  88818. };
  88819. }
  88820. declare module BABYLON {
  88821. /** @hidden */
  88822. export var clipPlaneFragmentDeclaration: {
  88823. name: string;
  88824. shader: string;
  88825. };
  88826. }
  88827. declare module BABYLON {
  88828. /** @hidden */
  88829. export var clipPlaneFragment: {
  88830. name: string;
  88831. shader: string;
  88832. };
  88833. }
  88834. declare module BABYLON {
  88835. /** @hidden */
  88836. export var shadowMapFragment: {
  88837. name: string;
  88838. shader: string;
  88839. };
  88840. }
  88841. declare module BABYLON {
  88842. /** @hidden */
  88843. export var shadowMapPixelShader: {
  88844. name: string;
  88845. shader: string;
  88846. };
  88847. }
  88848. declare module BABYLON {
  88849. /** @hidden */
  88850. export var bonesDeclaration: {
  88851. name: string;
  88852. shader: string;
  88853. };
  88854. }
  88855. declare module BABYLON {
  88856. /** @hidden */
  88857. export var morphTargetsVertexGlobalDeclaration: {
  88858. name: string;
  88859. shader: string;
  88860. };
  88861. }
  88862. declare module BABYLON {
  88863. /** @hidden */
  88864. export var morphTargetsVertexDeclaration: {
  88865. name: string;
  88866. shader: string;
  88867. };
  88868. }
  88869. declare module BABYLON {
  88870. /** @hidden */
  88871. export var instancesDeclaration: {
  88872. name: string;
  88873. shader: string;
  88874. };
  88875. }
  88876. declare module BABYLON {
  88877. /** @hidden */
  88878. export var helperFunctions: {
  88879. name: string;
  88880. shader: string;
  88881. };
  88882. }
  88883. declare module BABYLON {
  88884. /** @hidden */
  88885. export var shadowMapVertexDeclaration: {
  88886. name: string;
  88887. shader: string;
  88888. };
  88889. }
  88890. declare module BABYLON {
  88891. /** @hidden */
  88892. export var clipPlaneVertexDeclaration: {
  88893. name: string;
  88894. shader: string;
  88895. };
  88896. }
  88897. declare module BABYLON {
  88898. /** @hidden */
  88899. export var morphTargetsVertex: {
  88900. name: string;
  88901. shader: string;
  88902. };
  88903. }
  88904. declare module BABYLON {
  88905. /** @hidden */
  88906. export var instancesVertex: {
  88907. name: string;
  88908. shader: string;
  88909. };
  88910. }
  88911. declare module BABYLON {
  88912. /** @hidden */
  88913. export var bonesVertex: {
  88914. name: string;
  88915. shader: string;
  88916. };
  88917. }
  88918. declare module BABYLON {
  88919. /** @hidden */
  88920. export var shadowMapVertexNormalBias: {
  88921. name: string;
  88922. shader: string;
  88923. };
  88924. }
  88925. declare module BABYLON {
  88926. /** @hidden */
  88927. export var shadowMapVertexMetric: {
  88928. name: string;
  88929. shader: string;
  88930. };
  88931. }
  88932. declare module BABYLON {
  88933. /** @hidden */
  88934. export var clipPlaneVertex: {
  88935. name: string;
  88936. shader: string;
  88937. };
  88938. }
  88939. declare module BABYLON {
  88940. /** @hidden */
  88941. export var shadowMapVertexShader: {
  88942. name: string;
  88943. shader: string;
  88944. };
  88945. }
  88946. declare module BABYLON {
  88947. /** @hidden */
  88948. export var depthBoxBlurPixelShader: {
  88949. name: string;
  88950. shader: string;
  88951. };
  88952. }
  88953. declare module BABYLON {
  88954. /** @hidden */
  88955. export var shadowMapFragmentSoftTransparentShadow: {
  88956. name: string;
  88957. shader: string;
  88958. };
  88959. }
  88960. declare module BABYLON {
  88961. /**
  88962. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88963. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88964. */
  88965. export class EffectFallbacks implements IEffectFallbacks {
  88966. private _defines;
  88967. private _currentRank;
  88968. private _maxRank;
  88969. private _mesh;
  88970. /**
  88971. * Removes the fallback from the bound mesh.
  88972. */
  88973. unBindMesh(): void;
  88974. /**
  88975. * Adds a fallback on the specified property.
  88976. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88977. * @param define The name of the define in the shader
  88978. */
  88979. addFallback(rank: number, define: string): void;
  88980. /**
  88981. * Sets the mesh to use CPU skinning when needing to fallback.
  88982. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88983. * @param mesh The mesh to use the fallbacks.
  88984. */
  88985. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88986. /**
  88987. * Checks to see if more fallbacks are still availible.
  88988. */
  88989. get hasMoreFallbacks(): boolean;
  88990. /**
  88991. * Removes the defines that should be removed when falling back.
  88992. * @param currentDefines defines the current define statements for the shader.
  88993. * @param effect defines the current effect we try to compile
  88994. * @returns The resulting defines with defines of the current rank removed.
  88995. */
  88996. reduce(currentDefines: string, effect: Effect): string;
  88997. }
  88998. }
  88999. declare module BABYLON {
  89000. /**
  89001. * Interface used to define Action
  89002. */
  89003. export interface IAction {
  89004. /**
  89005. * Trigger for the action
  89006. */
  89007. trigger: number;
  89008. /** Options of the trigger */
  89009. triggerOptions: any;
  89010. /**
  89011. * Gets the trigger parameters
  89012. * @returns the trigger parameters
  89013. */
  89014. getTriggerParameter(): any;
  89015. /**
  89016. * Internal only - executes current action event
  89017. * @hidden
  89018. */
  89019. _executeCurrent(evt?: ActionEvent): void;
  89020. /**
  89021. * Serialize placeholder for child classes
  89022. * @param parent of child
  89023. * @returns the serialized object
  89024. */
  89025. serialize(parent: any): any;
  89026. /**
  89027. * Internal only
  89028. * @hidden
  89029. */
  89030. _prepare(): void;
  89031. /**
  89032. * Internal only - manager for action
  89033. * @hidden
  89034. */
  89035. _actionManager: AbstractActionManager;
  89036. /**
  89037. * Adds action to chain of actions, may be a DoNothingAction
  89038. * @param action defines the next action to execute
  89039. * @returns The action passed in
  89040. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89041. */
  89042. then(action: IAction): IAction;
  89043. }
  89044. /**
  89045. * The action to be carried out following a trigger
  89046. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  89047. */
  89048. export class Action implements IAction {
  89049. /** the trigger, with or without parameters, for the action */
  89050. triggerOptions: any;
  89051. /**
  89052. * Trigger for the action
  89053. */
  89054. trigger: number;
  89055. /**
  89056. * Internal only - manager for action
  89057. * @hidden
  89058. */
  89059. _actionManager: ActionManager;
  89060. private _nextActiveAction;
  89061. private _child;
  89062. private _condition?;
  89063. private _triggerParameter;
  89064. /**
  89065. * An event triggered prior to action being executed.
  89066. */
  89067. onBeforeExecuteObservable: Observable<Action>;
  89068. /**
  89069. * Creates a new Action
  89070. * @param triggerOptions the trigger, with or without parameters, for the action
  89071. * @param condition an optional determinant of action
  89072. */
  89073. constructor(
  89074. /** the trigger, with or without parameters, for the action */
  89075. triggerOptions: any, condition?: Condition);
  89076. /**
  89077. * Internal only
  89078. * @hidden
  89079. */
  89080. _prepare(): void;
  89081. /**
  89082. * Gets the trigger parameters
  89083. * @returns the trigger parameters
  89084. */
  89085. getTriggerParameter(): any;
  89086. /**
  89087. * Internal only - executes current action event
  89088. * @hidden
  89089. */
  89090. _executeCurrent(evt?: ActionEvent): void;
  89091. /**
  89092. * Execute placeholder for child classes
  89093. * @param evt optional action event
  89094. */
  89095. execute(evt?: ActionEvent): void;
  89096. /**
  89097. * Skips to next active action
  89098. */
  89099. skipToNextActiveAction(): void;
  89100. /**
  89101. * Adds action to chain of actions, may be a DoNothingAction
  89102. * @param action defines the next action to execute
  89103. * @returns The action passed in
  89104. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89105. */
  89106. then(action: Action): Action;
  89107. /**
  89108. * Internal only
  89109. * @hidden
  89110. */
  89111. _getProperty(propertyPath: string): string;
  89112. /**
  89113. * Internal only
  89114. * @hidden
  89115. */
  89116. _getEffectiveTarget(target: any, propertyPath: string): any;
  89117. /**
  89118. * Serialize placeholder for child classes
  89119. * @param parent of child
  89120. * @returns the serialized object
  89121. */
  89122. serialize(parent: any): any;
  89123. /**
  89124. * Internal only called by serialize
  89125. * @hidden
  89126. */
  89127. protected _serialize(serializedAction: any, parent?: any): any;
  89128. /**
  89129. * Internal only
  89130. * @hidden
  89131. */
  89132. static _SerializeValueAsString: (value: any) => string;
  89133. /**
  89134. * Internal only
  89135. * @hidden
  89136. */
  89137. static _GetTargetProperty: (target: Scene | Node) => {
  89138. name: string;
  89139. targetType: string;
  89140. value: string;
  89141. };
  89142. }
  89143. }
  89144. declare module BABYLON {
  89145. /**
  89146. * A Condition applied to an Action
  89147. */
  89148. export class Condition {
  89149. /**
  89150. * Internal only - manager for action
  89151. * @hidden
  89152. */
  89153. _actionManager: ActionManager;
  89154. /**
  89155. * Internal only
  89156. * @hidden
  89157. */
  89158. _evaluationId: number;
  89159. /**
  89160. * Internal only
  89161. * @hidden
  89162. */
  89163. _currentResult: boolean;
  89164. /**
  89165. * Creates a new Condition
  89166. * @param actionManager the manager of the action the condition is applied to
  89167. */
  89168. constructor(actionManager: ActionManager);
  89169. /**
  89170. * Check if the current condition is valid
  89171. * @returns a boolean
  89172. */
  89173. isValid(): boolean;
  89174. /**
  89175. * Internal only
  89176. * @hidden
  89177. */
  89178. _getProperty(propertyPath: string): string;
  89179. /**
  89180. * Internal only
  89181. * @hidden
  89182. */
  89183. _getEffectiveTarget(target: any, propertyPath: string): any;
  89184. /**
  89185. * Serialize placeholder for child classes
  89186. * @returns the serialized object
  89187. */
  89188. serialize(): any;
  89189. /**
  89190. * Internal only
  89191. * @hidden
  89192. */
  89193. protected _serialize(serializedCondition: any): any;
  89194. }
  89195. /**
  89196. * Defines specific conditional operators as extensions of Condition
  89197. */
  89198. export class ValueCondition extends Condition {
  89199. /** path to specify the property of the target the conditional operator uses */
  89200. propertyPath: string;
  89201. /** the value compared by the conditional operator against the current value of the property */
  89202. value: any;
  89203. /** the conditional operator, default ValueCondition.IsEqual */
  89204. operator: number;
  89205. /**
  89206. * Internal only
  89207. * @hidden
  89208. */
  89209. private static _IsEqual;
  89210. /**
  89211. * Internal only
  89212. * @hidden
  89213. */
  89214. private static _IsDifferent;
  89215. /**
  89216. * Internal only
  89217. * @hidden
  89218. */
  89219. private static _IsGreater;
  89220. /**
  89221. * Internal only
  89222. * @hidden
  89223. */
  89224. private static _IsLesser;
  89225. /**
  89226. * returns the number for IsEqual
  89227. */
  89228. static get IsEqual(): number;
  89229. /**
  89230. * Returns the number for IsDifferent
  89231. */
  89232. static get IsDifferent(): number;
  89233. /**
  89234. * Returns the number for IsGreater
  89235. */
  89236. static get IsGreater(): number;
  89237. /**
  89238. * Returns the number for IsLesser
  89239. */
  89240. static get IsLesser(): number;
  89241. /**
  89242. * Internal only The action manager for the condition
  89243. * @hidden
  89244. */
  89245. _actionManager: ActionManager;
  89246. /**
  89247. * Internal only
  89248. * @hidden
  89249. */
  89250. private _target;
  89251. /**
  89252. * Internal only
  89253. * @hidden
  89254. */
  89255. private _effectiveTarget;
  89256. /**
  89257. * Internal only
  89258. * @hidden
  89259. */
  89260. private _property;
  89261. /**
  89262. * Creates a new ValueCondition
  89263. * @param actionManager manager for the action the condition applies to
  89264. * @param target for the action
  89265. * @param propertyPath path to specify the property of the target the conditional operator uses
  89266. * @param value the value compared by the conditional operator against the current value of the property
  89267. * @param operator the conditional operator, default ValueCondition.IsEqual
  89268. */
  89269. constructor(actionManager: ActionManager, target: any,
  89270. /** path to specify the property of the target the conditional operator uses */
  89271. propertyPath: string,
  89272. /** the value compared by the conditional operator against the current value of the property */
  89273. value: any,
  89274. /** the conditional operator, default ValueCondition.IsEqual */
  89275. operator?: number);
  89276. /**
  89277. * Compares the given value with the property value for the specified conditional operator
  89278. * @returns the result of the comparison
  89279. */
  89280. isValid(): boolean;
  89281. /**
  89282. * Serialize the ValueCondition into a JSON compatible object
  89283. * @returns serialization object
  89284. */
  89285. serialize(): any;
  89286. /**
  89287. * Gets the name of the conditional operator for the ValueCondition
  89288. * @param operator the conditional operator
  89289. * @returns the name
  89290. */
  89291. static GetOperatorName(operator: number): string;
  89292. }
  89293. /**
  89294. * Defines a predicate condition as an extension of Condition
  89295. */
  89296. export class PredicateCondition extends Condition {
  89297. /** defines the predicate function used to validate the condition */
  89298. predicate: () => boolean;
  89299. /**
  89300. * Internal only - manager for action
  89301. * @hidden
  89302. */
  89303. _actionManager: ActionManager;
  89304. /**
  89305. * Creates a new PredicateCondition
  89306. * @param actionManager manager for the action the condition applies to
  89307. * @param predicate defines the predicate function used to validate the condition
  89308. */
  89309. constructor(actionManager: ActionManager,
  89310. /** defines the predicate function used to validate the condition */
  89311. predicate: () => boolean);
  89312. /**
  89313. * @returns the validity of the predicate condition
  89314. */
  89315. isValid(): boolean;
  89316. }
  89317. /**
  89318. * Defines a state condition as an extension of Condition
  89319. */
  89320. export class StateCondition extends Condition {
  89321. /** Value to compare with target state */
  89322. value: string;
  89323. /**
  89324. * Internal only - manager for action
  89325. * @hidden
  89326. */
  89327. _actionManager: ActionManager;
  89328. /**
  89329. * Internal only
  89330. * @hidden
  89331. */
  89332. private _target;
  89333. /**
  89334. * Creates a new StateCondition
  89335. * @param actionManager manager for the action the condition applies to
  89336. * @param target of the condition
  89337. * @param value to compare with target state
  89338. */
  89339. constructor(actionManager: ActionManager, target: any,
  89340. /** Value to compare with target state */
  89341. value: string);
  89342. /**
  89343. * Gets a boolean indicating if the current condition is met
  89344. * @returns the validity of the state
  89345. */
  89346. isValid(): boolean;
  89347. /**
  89348. * Serialize the StateCondition into a JSON compatible object
  89349. * @returns serialization object
  89350. */
  89351. serialize(): any;
  89352. }
  89353. }
  89354. declare module BABYLON {
  89355. /**
  89356. * This defines an action responsible to toggle a boolean once triggered.
  89357. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89358. */
  89359. export class SwitchBooleanAction extends Action {
  89360. /**
  89361. * The path to the boolean property in the target object
  89362. */
  89363. propertyPath: string;
  89364. private _target;
  89365. private _effectiveTarget;
  89366. private _property;
  89367. /**
  89368. * Instantiate the action
  89369. * @param triggerOptions defines the trigger options
  89370. * @param target defines the object containing the boolean
  89371. * @param propertyPath defines the path to the boolean property in the target object
  89372. * @param condition defines the trigger related conditions
  89373. */
  89374. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  89375. /** @hidden */
  89376. _prepare(): void;
  89377. /**
  89378. * Execute the action toggle the boolean value.
  89379. */
  89380. execute(): void;
  89381. /**
  89382. * Serializes the actions and its related information.
  89383. * @param parent defines the object to serialize in
  89384. * @returns the serialized object
  89385. */
  89386. serialize(parent: any): any;
  89387. }
  89388. /**
  89389. * This defines an action responsible to set a the state field of the target
  89390. * to a desired value once triggered.
  89391. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89392. */
  89393. export class SetStateAction extends Action {
  89394. /**
  89395. * The value to store in the state field.
  89396. */
  89397. value: string;
  89398. private _target;
  89399. /**
  89400. * Instantiate the action
  89401. * @param triggerOptions defines the trigger options
  89402. * @param target defines the object containing the state property
  89403. * @param value defines the value to store in the state field
  89404. * @param condition defines the trigger related conditions
  89405. */
  89406. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  89407. /**
  89408. * Execute the action and store the value on the target state property.
  89409. */
  89410. execute(): void;
  89411. /**
  89412. * Serializes the actions and its related information.
  89413. * @param parent defines the object to serialize in
  89414. * @returns the serialized object
  89415. */
  89416. serialize(parent: any): any;
  89417. }
  89418. /**
  89419. * This defines an action responsible to set a property of the target
  89420. * to a desired value once triggered.
  89421. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89422. */
  89423. export class SetValueAction extends Action {
  89424. /**
  89425. * The path of the property to set in the target.
  89426. */
  89427. propertyPath: string;
  89428. /**
  89429. * The value to set in the property
  89430. */
  89431. value: any;
  89432. private _target;
  89433. private _effectiveTarget;
  89434. private _property;
  89435. /**
  89436. * Instantiate the action
  89437. * @param triggerOptions defines the trigger options
  89438. * @param target defines the object containing the property
  89439. * @param propertyPath defines the path of the property to set in the target
  89440. * @param value defines the value to set in the property
  89441. * @param condition defines the trigger related conditions
  89442. */
  89443. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  89444. /** @hidden */
  89445. _prepare(): void;
  89446. /**
  89447. * Execute the action and set the targetted property to the desired value.
  89448. */
  89449. execute(): void;
  89450. /**
  89451. * Serializes the actions and its related information.
  89452. * @param parent defines the object to serialize in
  89453. * @returns the serialized object
  89454. */
  89455. serialize(parent: any): any;
  89456. }
  89457. /**
  89458. * This defines an action responsible to increment the target value
  89459. * to a desired value once triggered.
  89460. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89461. */
  89462. export class IncrementValueAction extends Action {
  89463. /**
  89464. * The path of the property to increment in the target.
  89465. */
  89466. propertyPath: string;
  89467. /**
  89468. * The value we should increment the property by.
  89469. */
  89470. value: any;
  89471. private _target;
  89472. private _effectiveTarget;
  89473. private _property;
  89474. /**
  89475. * Instantiate the action
  89476. * @param triggerOptions defines the trigger options
  89477. * @param target defines the object containing the property
  89478. * @param propertyPath defines the path of the property to increment in the target
  89479. * @param value defines the value value we should increment the property by
  89480. * @param condition defines the trigger related conditions
  89481. */
  89482. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  89483. /** @hidden */
  89484. _prepare(): void;
  89485. /**
  89486. * Execute the action and increment the target of the value amount.
  89487. */
  89488. execute(): void;
  89489. /**
  89490. * Serializes the actions and its related information.
  89491. * @param parent defines the object to serialize in
  89492. * @returns the serialized object
  89493. */
  89494. serialize(parent: any): any;
  89495. }
  89496. /**
  89497. * This defines an action responsible to start an animation once triggered.
  89498. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89499. */
  89500. export class PlayAnimationAction extends Action {
  89501. /**
  89502. * Where the animation should start (animation frame)
  89503. */
  89504. from: number;
  89505. /**
  89506. * Where the animation should stop (animation frame)
  89507. */
  89508. to: number;
  89509. /**
  89510. * Define if the animation should loop or stop after the first play.
  89511. */
  89512. loop?: boolean;
  89513. private _target;
  89514. /**
  89515. * Instantiate the action
  89516. * @param triggerOptions defines the trigger options
  89517. * @param target defines the target animation or animation name
  89518. * @param from defines from where the animation should start (animation frame)
  89519. * @param end defines where the animation should stop (animation frame)
  89520. * @param loop defines if the animation should loop or stop after the first play
  89521. * @param condition defines the trigger related conditions
  89522. */
  89523. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  89524. /** @hidden */
  89525. _prepare(): void;
  89526. /**
  89527. * Execute the action and play the animation.
  89528. */
  89529. execute(): void;
  89530. /**
  89531. * Serializes the actions and its related information.
  89532. * @param parent defines the object to serialize in
  89533. * @returns the serialized object
  89534. */
  89535. serialize(parent: any): any;
  89536. }
  89537. /**
  89538. * This defines an action responsible to stop an animation once triggered.
  89539. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89540. */
  89541. export class StopAnimationAction extends Action {
  89542. private _target;
  89543. /**
  89544. * Instantiate the action
  89545. * @param triggerOptions defines the trigger options
  89546. * @param target defines the target animation or animation name
  89547. * @param condition defines the trigger related conditions
  89548. */
  89549. constructor(triggerOptions: any, target: any, condition?: Condition);
  89550. /** @hidden */
  89551. _prepare(): void;
  89552. /**
  89553. * Execute the action and stop the animation.
  89554. */
  89555. execute(): void;
  89556. /**
  89557. * Serializes the actions and its related information.
  89558. * @param parent defines the object to serialize in
  89559. * @returns the serialized object
  89560. */
  89561. serialize(parent: any): any;
  89562. }
  89563. /**
  89564. * This defines an action responsible that does nothing once triggered.
  89565. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89566. */
  89567. export class DoNothingAction extends Action {
  89568. /**
  89569. * Instantiate the action
  89570. * @param triggerOptions defines the trigger options
  89571. * @param condition defines the trigger related conditions
  89572. */
  89573. constructor(triggerOptions?: any, condition?: Condition);
  89574. /**
  89575. * Execute the action and do nothing.
  89576. */
  89577. execute(): void;
  89578. /**
  89579. * Serializes the actions and its related information.
  89580. * @param parent defines the object to serialize in
  89581. * @returns the serialized object
  89582. */
  89583. serialize(parent: any): any;
  89584. }
  89585. /**
  89586. * This defines an action responsible to trigger several actions once triggered.
  89587. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89588. */
  89589. export class CombineAction extends Action {
  89590. /**
  89591. * The list of aggregated animations to run.
  89592. */
  89593. children: Action[];
  89594. /**
  89595. * Instantiate the action
  89596. * @param triggerOptions defines the trigger options
  89597. * @param children defines the list of aggregated animations to run
  89598. * @param condition defines the trigger related conditions
  89599. */
  89600. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  89601. /** @hidden */
  89602. _prepare(): void;
  89603. /**
  89604. * Execute the action and executes all the aggregated actions.
  89605. */
  89606. execute(evt: ActionEvent): void;
  89607. /**
  89608. * Serializes the actions and its related information.
  89609. * @param parent defines the object to serialize in
  89610. * @returns the serialized object
  89611. */
  89612. serialize(parent: any): any;
  89613. }
  89614. /**
  89615. * This defines an action responsible to run code (external event) once triggered.
  89616. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89617. */
  89618. export class ExecuteCodeAction extends Action {
  89619. /**
  89620. * The callback function to run.
  89621. */
  89622. func: (evt: ActionEvent) => void;
  89623. /**
  89624. * Instantiate the action
  89625. * @param triggerOptions defines the trigger options
  89626. * @param func defines the callback function to run
  89627. * @param condition defines the trigger related conditions
  89628. */
  89629. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  89630. /**
  89631. * Execute the action and run the attached code.
  89632. */
  89633. execute(evt: ActionEvent): void;
  89634. }
  89635. /**
  89636. * This defines an action responsible to set the parent property of the target once triggered.
  89637. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89638. */
  89639. export class SetParentAction extends Action {
  89640. private _parent;
  89641. private _target;
  89642. /**
  89643. * Instantiate the action
  89644. * @param triggerOptions defines the trigger options
  89645. * @param target defines the target containing the parent property
  89646. * @param parent defines from where the animation should start (animation frame)
  89647. * @param condition defines the trigger related conditions
  89648. */
  89649. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  89650. /** @hidden */
  89651. _prepare(): void;
  89652. /**
  89653. * Execute the action and set the parent property.
  89654. */
  89655. execute(): void;
  89656. /**
  89657. * Serializes the actions and its related information.
  89658. * @param parent defines the object to serialize in
  89659. * @returns the serialized object
  89660. */
  89661. serialize(parent: any): any;
  89662. }
  89663. }
  89664. declare module BABYLON {
  89665. /**
  89666. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  89667. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  89668. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89669. */
  89670. export class ActionManager extends AbstractActionManager {
  89671. /**
  89672. * Nothing
  89673. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89674. */
  89675. static readonly NothingTrigger: number;
  89676. /**
  89677. * On pick
  89678. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89679. */
  89680. static readonly OnPickTrigger: number;
  89681. /**
  89682. * On left pick
  89683. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89684. */
  89685. static readonly OnLeftPickTrigger: number;
  89686. /**
  89687. * On right pick
  89688. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89689. */
  89690. static readonly OnRightPickTrigger: number;
  89691. /**
  89692. * On center pick
  89693. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89694. */
  89695. static readonly OnCenterPickTrigger: number;
  89696. /**
  89697. * On pick down
  89698. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89699. */
  89700. static readonly OnPickDownTrigger: number;
  89701. /**
  89702. * On double pick
  89703. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89704. */
  89705. static readonly OnDoublePickTrigger: number;
  89706. /**
  89707. * On pick up
  89708. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89709. */
  89710. static readonly OnPickUpTrigger: number;
  89711. /**
  89712. * On pick out.
  89713. * This trigger will only be raised if you also declared a OnPickDown
  89714. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89715. */
  89716. static readonly OnPickOutTrigger: number;
  89717. /**
  89718. * On long press
  89719. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89720. */
  89721. static readonly OnLongPressTrigger: number;
  89722. /**
  89723. * On pointer over
  89724. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89725. */
  89726. static readonly OnPointerOverTrigger: number;
  89727. /**
  89728. * On pointer out
  89729. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89730. */
  89731. static readonly OnPointerOutTrigger: number;
  89732. /**
  89733. * On every frame
  89734. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89735. */
  89736. static readonly OnEveryFrameTrigger: number;
  89737. /**
  89738. * On intersection enter
  89739. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89740. */
  89741. static readonly OnIntersectionEnterTrigger: number;
  89742. /**
  89743. * On intersection exit
  89744. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89745. */
  89746. static readonly OnIntersectionExitTrigger: number;
  89747. /**
  89748. * On key down
  89749. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89750. */
  89751. static readonly OnKeyDownTrigger: number;
  89752. /**
  89753. * On key up
  89754. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89755. */
  89756. static readonly OnKeyUpTrigger: number;
  89757. private _scene;
  89758. /**
  89759. * Creates a new action manager
  89760. * @param scene defines the hosting scene
  89761. */
  89762. constructor(scene: Scene);
  89763. /**
  89764. * Releases all associated resources
  89765. */
  89766. dispose(): void;
  89767. /**
  89768. * Gets hosting scene
  89769. * @returns the hosting scene
  89770. */
  89771. getScene(): Scene;
  89772. /**
  89773. * Does this action manager handles actions of any of the given triggers
  89774. * @param triggers defines the triggers to be tested
  89775. * @return a boolean indicating whether one (or more) of the triggers is handled
  89776. */
  89777. hasSpecificTriggers(triggers: number[]): boolean;
  89778. /**
  89779. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  89780. * speed.
  89781. * @param triggerA defines the trigger to be tested
  89782. * @param triggerB defines the trigger to be tested
  89783. * @return a boolean indicating whether one (or more) of the triggers is handled
  89784. */
  89785. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  89786. /**
  89787. * Does this action manager handles actions of a given trigger
  89788. * @param trigger defines the trigger to be tested
  89789. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  89790. * @return whether the trigger is handled
  89791. */
  89792. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  89793. /**
  89794. * Does this action manager has pointer triggers
  89795. */
  89796. get hasPointerTriggers(): boolean;
  89797. /**
  89798. * Does this action manager has pick triggers
  89799. */
  89800. get hasPickTriggers(): boolean;
  89801. /**
  89802. * Registers an action to this action manager
  89803. * @param action defines the action to be registered
  89804. * @return the action amended (prepared) after registration
  89805. */
  89806. registerAction(action: IAction): Nullable<IAction>;
  89807. /**
  89808. * Unregisters an action to this action manager
  89809. * @param action defines the action to be unregistered
  89810. * @return a boolean indicating whether the action has been unregistered
  89811. */
  89812. unregisterAction(action: IAction): Boolean;
  89813. /**
  89814. * Process a specific trigger
  89815. * @param trigger defines the trigger to process
  89816. * @param evt defines the event details to be processed
  89817. */
  89818. processTrigger(trigger: number, evt?: IActionEvent): void;
  89819. /** @hidden */
  89820. _getEffectiveTarget(target: any, propertyPath: string): any;
  89821. /** @hidden */
  89822. _getProperty(propertyPath: string): string;
  89823. /**
  89824. * Serialize this manager to a JSON object
  89825. * @param name defines the property name to store this manager
  89826. * @returns a JSON representation of this manager
  89827. */
  89828. serialize(name: string): any;
  89829. /**
  89830. * Creates a new ActionManager from a JSON data
  89831. * @param parsedActions defines the JSON data to read from
  89832. * @param object defines the hosting mesh
  89833. * @param scene defines the hosting scene
  89834. */
  89835. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  89836. /**
  89837. * Get a trigger name by index
  89838. * @param trigger defines the trigger index
  89839. * @returns a trigger name
  89840. */
  89841. static GetTriggerName(trigger: number): string;
  89842. }
  89843. }
  89844. declare module BABYLON {
  89845. /**
  89846. * Class used to represent a sprite
  89847. * @see https://doc.babylonjs.com/babylon101/sprites
  89848. */
  89849. export class Sprite implements IAnimatable {
  89850. /** defines the name */
  89851. name: string;
  89852. /** Gets or sets the current world position */
  89853. position: Vector3;
  89854. /** Gets or sets the main color */
  89855. color: Color4;
  89856. /** Gets or sets the width */
  89857. width: number;
  89858. /** Gets or sets the height */
  89859. height: number;
  89860. /** Gets or sets rotation angle */
  89861. angle: number;
  89862. /** Gets or sets the cell index in the sprite sheet */
  89863. cellIndex: number;
  89864. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  89865. cellRef: string;
  89866. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  89867. invertU: boolean;
  89868. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  89869. invertV: boolean;
  89870. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  89871. disposeWhenFinishedAnimating: boolean;
  89872. /** Gets the list of attached animations */
  89873. animations: Nullable<Array<Animation>>;
  89874. /** Gets or sets a boolean indicating if the sprite can be picked */
  89875. isPickable: boolean;
  89876. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  89877. useAlphaForPicking: boolean;
  89878. /** @hidden */
  89879. _xOffset: number;
  89880. /** @hidden */
  89881. _yOffset: number;
  89882. /** @hidden */
  89883. _xSize: number;
  89884. /** @hidden */
  89885. _ySize: number;
  89886. /**
  89887. * Gets or sets the associated action manager
  89888. */
  89889. actionManager: Nullable<ActionManager>;
  89890. /**
  89891. * An event triggered when the control has been disposed
  89892. */
  89893. onDisposeObservable: Observable<Sprite>;
  89894. private _animationStarted;
  89895. private _loopAnimation;
  89896. private _fromIndex;
  89897. private _toIndex;
  89898. private _delay;
  89899. private _direction;
  89900. private _manager;
  89901. private _time;
  89902. private _onAnimationEnd;
  89903. /**
  89904. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  89905. */
  89906. isVisible: boolean;
  89907. /**
  89908. * Gets or sets the sprite size
  89909. */
  89910. get size(): number;
  89911. set size(value: number);
  89912. /**
  89913. * Returns a boolean indicating if the animation is started
  89914. */
  89915. get animationStarted(): boolean;
  89916. /**
  89917. * Gets or sets the unique id of the sprite
  89918. */
  89919. uniqueId: number;
  89920. /**
  89921. * Gets the manager of this sprite
  89922. */
  89923. get manager(): ISpriteManager;
  89924. /**
  89925. * Creates a new Sprite
  89926. * @param name defines the name
  89927. * @param manager defines the manager
  89928. */
  89929. constructor(
  89930. /** defines the name */
  89931. name: string, manager: ISpriteManager);
  89932. /**
  89933. * Returns the string "Sprite"
  89934. * @returns "Sprite"
  89935. */
  89936. getClassName(): string;
  89937. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  89938. get fromIndex(): number;
  89939. set fromIndex(value: number);
  89940. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  89941. get toIndex(): number;
  89942. set toIndex(value: number);
  89943. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  89944. get loopAnimation(): boolean;
  89945. set loopAnimation(value: boolean);
  89946. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  89947. get delay(): number;
  89948. set delay(value: number);
  89949. /**
  89950. * Starts an animation
  89951. * @param from defines the initial key
  89952. * @param to defines the end key
  89953. * @param loop defines if the animation must loop
  89954. * @param delay defines the start delay (in ms)
  89955. * @param onAnimationEnd defines a callback to call when animation ends
  89956. */
  89957. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  89958. /** Stops current animation (if any) */
  89959. stopAnimation(): void;
  89960. /** @hidden */
  89961. _animate(deltaTime: number): void;
  89962. /** Release associated resources */
  89963. dispose(): void;
  89964. /**
  89965. * Serializes the sprite to a JSON object
  89966. * @returns the JSON object
  89967. */
  89968. serialize(): any;
  89969. /**
  89970. * Parses a JSON object to create a new sprite
  89971. * @param parsedSprite The JSON object to parse
  89972. * @param manager defines the hosting manager
  89973. * @returns the new sprite
  89974. */
  89975. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  89976. }
  89977. }
  89978. declare module BABYLON {
  89979. /**
  89980. * Information about the result of picking within a scene
  89981. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  89982. */
  89983. export class PickingInfo {
  89984. /** @hidden */
  89985. _pickingUnavailable: boolean;
  89986. /**
  89987. * If the pick collided with an object
  89988. */
  89989. hit: boolean;
  89990. /**
  89991. * Distance away where the pick collided
  89992. */
  89993. distance: number;
  89994. /**
  89995. * The location of pick collision
  89996. */
  89997. pickedPoint: Nullable<Vector3>;
  89998. /**
  89999. * The mesh corresponding the the pick collision
  90000. */
  90001. pickedMesh: Nullable<AbstractMesh>;
  90002. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  90003. bu: number;
  90004. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  90005. bv: number;
  90006. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90007. faceId: number;
  90008. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90009. subMeshFaceId: number;
  90010. /** Id of the the submesh that was picked */
  90011. subMeshId: number;
  90012. /** If a sprite was picked, this will be the sprite the pick collided with */
  90013. pickedSprite: Nullable<Sprite>;
  90014. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  90015. thinInstanceIndex: number;
  90016. /**
  90017. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  90018. */
  90019. originMesh: Nullable<AbstractMesh>;
  90020. /**
  90021. * The ray that was used to perform the picking.
  90022. */
  90023. ray: Nullable<Ray>;
  90024. /**
  90025. * Gets the normal correspodning to the face the pick collided with
  90026. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  90027. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  90028. * @returns The normal correspodning to the face the pick collided with
  90029. */
  90030. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  90031. /**
  90032. * Gets the texture coordinates of where the pick occured
  90033. * @returns the vector containing the coordnates of the texture
  90034. */
  90035. getTextureCoordinates(): Nullable<Vector2>;
  90036. }
  90037. }
  90038. declare module BABYLON {
  90039. /**
  90040. * Class representing a ray with position and direction
  90041. */
  90042. export class Ray {
  90043. /** origin point */
  90044. origin: Vector3;
  90045. /** direction */
  90046. direction: Vector3;
  90047. /** length of the ray */
  90048. length: number;
  90049. private static readonly _TmpVector3;
  90050. private _tmpRay;
  90051. /**
  90052. * Creates a new ray
  90053. * @param origin origin point
  90054. * @param direction direction
  90055. * @param length length of the ray
  90056. */
  90057. constructor(
  90058. /** origin point */
  90059. origin: Vector3,
  90060. /** direction */
  90061. direction: Vector3,
  90062. /** length of the ray */
  90063. length?: number);
  90064. /**
  90065. * Checks if the ray intersects a box
  90066. * This does not account for the ray lenght by design to improve perfs.
  90067. * @param minimum bound of the box
  90068. * @param maximum bound of the box
  90069. * @param intersectionTreshold extra extend to be added to the box in all direction
  90070. * @returns if the box was hit
  90071. */
  90072. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  90073. /**
  90074. * Checks if the ray intersects a box
  90075. * This does not account for the ray lenght by design to improve perfs.
  90076. * @param box the bounding box to check
  90077. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  90078. * @returns if the box was hit
  90079. */
  90080. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  90081. /**
  90082. * If the ray hits a sphere
  90083. * @param sphere the bounding sphere to check
  90084. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  90085. * @returns true if it hits the sphere
  90086. */
  90087. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  90088. /**
  90089. * If the ray hits a triange
  90090. * @param vertex0 triangle vertex
  90091. * @param vertex1 triangle vertex
  90092. * @param vertex2 triangle vertex
  90093. * @returns intersection information if hit
  90094. */
  90095. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  90096. /**
  90097. * Checks if ray intersects a plane
  90098. * @param plane the plane to check
  90099. * @returns the distance away it was hit
  90100. */
  90101. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  90102. /**
  90103. * Calculate the intercept of a ray on a given axis
  90104. * @param axis to check 'x' | 'y' | 'z'
  90105. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  90106. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  90107. */
  90108. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  90109. /**
  90110. * Checks if ray intersects a mesh
  90111. * @param mesh the mesh to check
  90112. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90113. * @returns picking info of the intersecton
  90114. */
  90115. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  90116. /**
  90117. * Checks if ray intersects a mesh
  90118. * @param meshes the meshes to check
  90119. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90120. * @param results array to store result in
  90121. * @returns Array of picking infos
  90122. */
  90123. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  90124. private _comparePickingInfo;
  90125. private static smallnum;
  90126. private static rayl;
  90127. /**
  90128. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  90129. * @param sega the first point of the segment to test the intersection against
  90130. * @param segb the second point of the segment to test the intersection against
  90131. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  90132. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  90133. */
  90134. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  90135. /**
  90136. * Update the ray from viewport position
  90137. * @param x position
  90138. * @param y y position
  90139. * @param viewportWidth viewport width
  90140. * @param viewportHeight viewport height
  90141. * @param world world matrix
  90142. * @param view view matrix
  90143. * @param projection projection matrix
  90144. * @returns this ray updated
  90145. */
  90146. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90147. /**
  90148. * Creates a ray with origin and direction of 0,0,0
  90149. * @returns the new ray
  90150. */
  90151. static Zero(): Ray;
  90152. /**
  90153. * Creates a new ray from screen space and viewport
  90154. * @param x position
  90155. * @param y y position
  90156. * @param viewportWidth viewport width
  90157. * @param viewportHeight viewport height
  90158. * @param world world matrix
  90159. * @param view view matrix
  90160. * @param projection projection matrix
  90161. * @returns new ray
  90162. */
  90163. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90164. /**
  90165. * 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
  90166. * transformed to the given world matrix.
  90167. * @param origin The origin point
  90168. * @param end The end point
  90169. * @param world a matrix to transform the ray to. Default is the identity matrix.
  90170. * @returns the new ray
  90171. */
  90172. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  90173. /**
  90174. * Transforms a ray by a matrix
  90175. * @param ray ray to transform
  90176. * @param matrix matrix to apply
  90177. * @returns the resulting new ray
  90178. */
  90179. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  90180. /**
  90181. * Transforms a ray by a matrix
  90182. * @param ray ray to transform
  90183. * @param matrix matrix to apply
  90184. * @param result ray to store result in
  90185. */
  90186. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  90187. /**
  90188. * Unproject a ray from screen space to object space
  90189. * @param sourceX defines the screen space x coordinate to use
  90190. * @param sourceY defines the screen space y coordinate to use
  90191. * @param viewportWidth defines the current width of the viewport
  90192. * @param viewportHeight defines the current height of the viewport
  90193. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  90194. * @param view defines the view matrix to use
  90195. * @param projection defines the projection matrix to use
  90196. */
  90197. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  90198. }
  90199. /**
  90200. * Type used to define predicate used to select faces when a mesh intersection is detected
  90201. */
  90202. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  90203. interface Scene {
  90204. /** @hidden */
  90205. _tempPickingRay: Nullable<Ray>;
  90206. /** @hidden */
  90207. _cachedRayForTransform: Ray;
  90208. /** @hidden */
  90209. _pickWithRayInverseMatrix: Matrix;
  90210. /** @hidden */
  90211. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90212. /** @hidden */
  90213. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90214. /** @hidden */
  90215. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90216. }
  90217. }
  90218. declare module BABYLON {
  90219. /**
  90220. * Groups all the scene component constants in one place to ease maintenance.
  90221. * @hidden
  90222. */
  90223. export class SceneComponentConstants {
  90224. static readonly NAME_EFFECTLAYER: string;
  90225. static readonly NAME_LAYER: string;
  90226. static readonly NAME_LENSFLARESYSTEM: string;
  90227. static readonly NAME_BOUNDINGBOXRENDERER: string;
  90228. static readonly NAME_PARTICLESYSTEM: string;
  90229. static readonly NAME_GAMEPAD: string;
  90230. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  90231. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  90232. static readonly NAME_PREPASSRENDERER: string;
  90233. static readonly NAME_DEPTHRENDERER: string;
  90234. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  90235. static readonly NAME_SPRITE: string;
  90236. static readonly NAME_OUTLINERENDERER: string;
  90237. static readonly NAME_PROCEDURALTEXTURE: string;
  90238. static readonly NAME_SHADOWGENERATOR: string;
  90239. static readonly NAME_OCTREE: string;
  90240. static readonly NAME_PHYSICSENGINE: string;
  90241. static readonly NAME_AUDIO: string;
  90242. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  90243. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90244. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  90245. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90246. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  90247. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  90248. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  90249. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  90250. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  90251. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  90252. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  90253. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  90254. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  90255. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  90256. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  90257. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  90258. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  90259. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  90260. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  90261. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  90262. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  90263. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  90264. static readonly STEP_AFTERRENDER_AUDIO: number;
  90265. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  90266. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  90267. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  90268. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  90269. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  90270. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  90271. static readonly STEP_POINTERMOVE_SPRITE: number;
  90272. static readonly STEP_POINTERDOWN_SPRITE: number;
  90273. static readonly STEP_POINTERUP_SPRITE: number;
  90274. }
  90275. /**
  90276. * This represents a scene component.
  90277. *
  90278. * This is used to decouple the dependency the scene is having on the different workloads like
  90279. * layers, post processes...
  90280. */
  90281. export interface ISceneComponent {
  90282. /**
  90283. * The name of the component. Each component must have a unique name.
  90284. */
  90285. name: string;
  90286. /**
  90287. * The scene the component belongs to.
  90288. */
  90289. scene: Scene;
  90290. /**
  90291. * Register the component to one instance of a scene.
  90292. */
  90293. register(): void;
  90294. /**
  90295. * Rebuilds the elements related to this component in case of
  90296. * context lost for instance.
  90297. */
  90298. rebuild(): void;
  90299. /**
  90300. * Disposes the component and the associated ressources.
  90301. */
  90302. dispose(): void;
  90303. }
  90304. /**
  90305. * This represents a SERIALIZABLE scene component.
  90306. *
  90307. * This extends Scene Component to add Serialization methods on top.
  90308. */
  90309. export interface ISceneSerializableComponent extends ISceneComponent {
  90310. /**
  90311. * Adds all the elements from the container to the scene
  90312. * @param container the container holding the elements
  90313. */
  90314. addFromContainer(container: AbstractScene): void;
  90315. /**
  90316. * Removes all the elements in the container from the scene
  90317. * @param container contains the elements to remove
  90318. * @param dispose if the removed element should be disposed (default: false)
  90319. */
  90320. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  90321. /**
  90322. * Serializes the component data to the specified json object
  90323. * @param serializationObject The object to serialize to
  90324. */
  90325. serialize(serializationObject: any): void;
  90326. }
  90327. /**
  90328. * Strong typing of a Mesh related stage step action
  90329. */
  90330. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  90331. /**
  90332. * Strong typing of a Evaluate Sub Mesh related stage step action
  90333. */
  90334. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  90335. /**
  90336. * Strong typing of a Active Mesh related stage step action
  90337. */
  90338. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  90339. /**
  90340. * Strong typing of a Camera related stage step action
  90341. */
  90342. export type CameraStageAction = (camera: Camera) => void;
  90343. /**
  90344. * Strong typing of a Camera Frame buffer related stage step action
  90345. */
  90346. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  90347. /**
  90348. * Strong typing of a Render Target related stage step action
  90349. */
  90350. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  90351. /**
  90352. * Strong typing of a RenderingGroup related stage step action
  90353. */
  90354. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  90355. /**
  90356. * Strong typing of a Mesh Render related stage step action
  90357. */
  90358. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  90359. /**
  90360. * Strong typing of a simple stage step action
  90361. */
  90362. export type SimpleStageAction = () => void;
  90363. /**
  90364. * Strong typing of a render target action.
  90365. */
  90366. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  90367. /**
  90368. * Strong typing of a pointer move action.
  90369. */
  90370. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  90371. /**
  90372. * Strong typing of a pointer up/down action.
  90373. */
  90374. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  90375. /**
  90376. * Representation of a stage in the scene (Basically a list of ordered steps)
  90377. * @hidden
  90378. */
  90379. export class Stage<T extends Function> extends Array<{
  90380. index: number;
  90381. component: ISceneComponent;
  90382. action: T;
  90383. }> {
  90384. /**
  90385. * Hide ctor from the rest of the world.
  90386. * @param items The items to add.
  90387. */
  90388. private constructor();
  90389. /**
  90390. * Creates a new Stage.
  90391. * @returns A new instance of a Stage
  90392. */
  90393. static Create<T extends Function>(): Stage<T>;
  90394. /**
  90395. * Registers a step in an ordered way in the targeted stage.
  90396. * @param index Defines the position to register the step in
  90397. * @param component Defines the component attached to the step
  90398. * @param action Defines the action to launch during the step
  90399. */
  90400. registerStep(index: number, component: ISceneComponent, action: T): void;
  90401. /**
  90402. * Clears all the steps from the stage.
  90403. */
  90404. clear(): void;
  90405. }
  90406. }
  90407. declare module BABYLON {
  90408. interface Scene {
  90409. /** @hidden */
  90410. _pointerOverSprite: Nullable<Sprite>;
  90411. /** @hidden */
  90412. _pickedDownSprite: Nullable<Sprite>;
  90413. /** @hidden */
  90414. _tempSpritePickingRay: Nullable<Ray>;
  90415. /**
  90416. * All of the sprite managers added to this scene
  90417. * @see https://doc.babylonjs.com/babylon101/sprites
  90418. */
  90419. spriteManagers: Array<ISpriteManager>;
  90420. /**
  90421. * An event triggered when sprites rendering is about to start
  90422. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  90423. */
  90424. onBeforeSpritesRenderingObservable: Observable<Scene>;
  90425. /**
  90426. * An event triggered when sprites rendering is done
  90427. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  90428. */
  90429. onAfterSpritesRenderingObservable: Observable<Scene>;
  90430. /** @hidden */
  90431. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90432. /** Launch a ray to try to pick a sprite in the scene
  90433. * @param x position on screen
  90434. * @param y position on screen
  90435. * @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
  90436. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90437. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90438. * @returns a PickingInfo
  90439. */
  90440. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90441. /** Use the given ray to pick a sprite in the scene
  90442. * @param ray The ray (in world space) to use to pick meshes
  90443. * @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
  90444. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90445. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  90446. * @returns a PickingInfo
  90447. */
  90448. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90449. /** @hidden */
  90450. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90451. /** Launch a ray to try to pick sprites in the scene
  90452. * @param x position on screen
  90453. * @param y position on screen
  90454. * @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
  90455. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90456. * @returns a PickingInfo array
  90457. */
  90458. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90459. /** Use the given ray to pick sprites in the scene
  90460. * @param ray The ray (in world space) to use to pick meshes
  90461. * @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
  90462. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  90463. * @returns a PickingInfo array
  90464. */
  90465. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90466. /**
  90467. * Force the sprite under the pointer
  90468. * @param sprite defines the sprite to use
  90469. */
  90470. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  90471. /**
  90472. * Gets the sprite under the pointer
  90473. * @returns a Sprite or null if no sprite is under the pointer
  90474. */
  90475. getPointerOverSprite(): Nullable<Sprite>;
  90476. }
  90477. /**
  90478. * Defines the sprite scene component responsible to manage sprites
  90479. * in a given scene.
  90480. */
  90481. export class SpriteSceneComponent implements ISceneComponent {
  90482. /**
  90483. * The component name helpfull to identify the component in the list of scene components.
  90484. */
  90485. readonly name: string;
  90486. /**
  90487. * The scene the component belongs to.
  90488. */
  90489. scene: Scene;
  90490. /** @hidden */
  90491. private _spritePredicate;
  90492. /**
  90493. * Creates a new instance of the component for the given scene
  90494. * @param scene Defines the scene to register the component in
  90495. */
  90496. constructor(scene: Scene);
  90497. /**
  90498. * Registers the component in a given scene
  90499. */
  90500. register(): void;
  90501. /**
  90502. * Rebuilds the elements related to this component in case of
  90503. * context lost for instance.
  90504. */
  90505. rebuild(): void;
  90506. /**
  90507. * Disposes the component and the associated ressources.
  90508. */
  90509. dispose(): void;
  90510. private _pickSpriteButKeepRay;
  90511. private _pointerMove;
  90512. private _pointerDown;
  90513. private _pointerUp;
  90514. }
  90515. }
  90516. declare module BABYLON {
  90517. /** @hidden */
  90518. export var fogFragmentDeclaration: {
  90519. name: string;
  90520. shader: string;
  90521. };
  90522. }
  90523. declare module BABYLON {
  90524. /** @hidden */
  90525. export var fogFragment: {
  90526. name: string;
  90527. shader: string;
  90528. };
  90529. }
  90530. declare module BABYLON {
  90531. /** @hidden */
  90532. export var spritesPixelShader: {
  90533. name: string;
  90534. shader: string;
  90535. };
  90536. }
  90537. declare module BABYLON {
  90538. /** @hidden */
  90539. export var fogVertexDeclaration: {
  90540. name: string;
  90541. shader: string;
  90542. };
  90543. }
  90544. declare module BABYLON {
  90545. /** @hidden */
  90546. export var spritesVertexShader: {
  90547. name: string;
  90548. shader: string;
  90549. };
  90550. }
  90551. declare module BABYLON {
  90552. /**
  90553. * Defines the minimum interface to fullfil in order to be a sprite manager.
  90554. */
  90555. export interface ISpriteManager extends IDisposable {
  90556. /**
  90557. * Gets manager's name
  90558. */
  90559. name: string;
  90560. /**
  90561. * Restricts the camera to viewing objects with the same layerMask.
  90562. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  90563. */
  90564. layerMask: number;
  90565. /**
  90566. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  90567. */
  90568. isPickable: boolean;
  90569. /**
  90570. * Gets the hosting scene
  90571. */
  90572. scene: Scene;
  90573. /**
  90574. * Specifies the rendering group id for this mesh (0 by default)
  90575. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  90576. */
  90577. renderingGroupId: number;
  90578. /**
  90579. * Defines the list of sprites managed by the manager.
  90580. */
  90581. sprites: Array<Sprite>;
  90582. /**
  90583. * Gets or sets the spritesheet texture
  90584. */
  90585. texture: Texture;
  90586. /** Defines the default width of a cell in the spritesheet */
  90587. cellWidth: number;
  90588. /** Defines the default height of a cell in the spritesheet */
  90589. cellHeight: number;
  90590. /**
  90591. * Tests the intersection of a sprite with a specific ray.
  90592. * @param ray The ray we are sending to test the collision
  90593. * @param camera The camera space we are sending rays in
  90594. * @param predicate A predicate allowing excluding sprites from the list of object to test
  90595. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90596. * @returns picking info or null.
  90597. */
  90598. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90599. /**
  90600. * Intersects the sprites with a ray
  90601. * @param ray defines the ray to intersect with
  90602. * @param camera defines the current active camera
  90603. * @param predicate defines a predicate used to select candidate sprites
  90604. * @returns null if no hit or a PickingInfo array
  90605. */
  90606. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90607. /**
  90608. * Renders the list of sprites on screen.
  90609. */
  90610. render(): void;
  90611. }
  90612. /**
  90613. * Class used to manage multiple sprites on the same spritesheet
  90614. * @see https://doc.babylonjs.com/babylon101/sprites
  90615. */
  90616. export class SpriteManager implements ISpriteManager {
  90617. /** defines the manager's name */
  90618. name: string;
  90619. /** Define the Url to load snippets */
  90620. static SnippetUrl: string;
  90621. /** Snippet ID if the manager was created from the snippet server */
  90622. snippetId: string;
  90623. /** Gets the list of sprites */
  90624. sprites: Sprite[];
  90625. /** Gets or sets the rendering group id (0 by default) */
  90626. renderingGroupId: number;
  90627. /** Gets or sets camera layer mask */
  90628. layerMask: number;
  90629. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  90630. fogEnabled: boolean;
  90631. /** Gets or sets a boolean indicating if the sprites are pickable */
  90632. isPickable: boolean;
  90633. /** Defines the default width of a cell in the spritesheet */
  90634. cellWidth: number;
  90635. /** Defines the default height of a cell in the spritesheet */
  90636. cellHeight: number;
  90637. /** Associative array from JSON sprite data file */
  90638. private _cellData;
  90639. /** Array of sprite names from JSON sprite data file */
  90640. private _spriteMap;
  90641. /** True when packed cell data from JSON file is ready*/
  90642. private _packedAndReady;
  90643. private _textureContent;
  90644. private _useInstancing;
  90645. /**
  90646. * An event triggered when the manager is disposed.
  90647. */
  90648. onDisposeObservable: Observable<SpriteManager>;
  90649. private _onDisposeObserver;
  90650. /**
  90651. * Callback called when the manager is disposed
  90652. */
  90653. set onDispose(callback: () => void);
  90654. private _capacity;
  90655. private _fromPacked;
  90656. private _spriteTexture;
  90657. private _epsilon;
  90658. private _scene;
  90659. private _vertexData;
  90660. private _buffer;
  90661. private _vertexBuffers;
  90662. private _spriteBuffer;
  90663. private _indexBuffer;
  90664. private _effectBase;
  90665. private _effectFog;
  90666. private _vertexBufferSize;
  90667. /**
  90668. * Gets or sets the unique id of the sprite
  90669. */
  90670. uniqueId: number;
  90671. /**
  90672. * Gets the array of sprites
  90673. */
  90674. get children(): Sprite[];
  90675. /**
  90676. * Gets the hosting scene
  90677. */
  90678. get scene(): Scene;
  90679. /**
  90680. * Gets the capacity of the manager
  90681. */
  90682. get capacity(): number;
  90683. /**
  90684. * Gets or sets the spritesheet texture
  90685. */
  90686. get texture(): Texture;
  90687. set texture(value: Texture);
  90688. private _blendMode;
  90689. /**
  90690. * Blend mode use to render the particle, it can be any of
  90691. * the static Constants.ALPHA_x properties provided in this class.
  90692. * Default value is Constants.ALPHA_COMBINE
  90693. */
  90694. get blendMode(): number;
  90695. set blendMode(blendMode: number);
  90696. /** Disables writing to the depth buffer when rendering the sprites.
  90697. * It can be handy to disable depth writing when using textures without alpha channel
  90698. * and setting some specific blend modes.
  90699. */
  90700. disableDepthWrite: boolean;
  90701. /**
  90702. * Creates a new sprite manager
  90703. * @param name defines the manager's name
  90704. * @param imgUrl defines the sprite sheet url
  90705. * @param capacity defines the maximum allowed number of sprites
  90706. * @param cellSize defines the size of a sprite cell
  90707. * @param scene defines the hosting scene
  90708. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  90709. * @param samplingMode defines the smapling mode to use with spritesheet
  90710. * @param fromPacked set to false; do not alter
  90711. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  90712. */
  90713. constructor(
  90714. /** defines the manager's name */
  90715. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  90716. /**
  90717. * Returns the string "SpriteManager"
  90718. * @returns "SpriteManager"
  90719. */
  90720. getClassName(): string;
  90721. private _makePacked;
  90722. private _appendSpriteVertex;
  90723. private _checkTextureAlpha;
  90724. /**
  90725. * Intersects the sprites with a ray
  90726. * @param ray defines the ray to intersect with
  90727. * @param camera defines the current active camera
  90728. * @param predicate defines a predicate used to select candidate sprites
  90729. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  90730. * @returns null if no hit or a PickingInfo
  90731. */
  90732. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90733. /**
  90734. * Intersects the sprites with a ray
  90735. * @param ray defines the ray to intersect with
  90736. * @param camera defines the current active camera
  90737. * @param predicate defines a predicate used to select candidate sprites
  90738. * @returns null if no hit or a PickingInfo array
  90739. */
  90740. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90741. /**
  90742. * Render all child sprites
  90743. */
  90744. render(): void;
  90745. /**
  90746. * Release associated resources
  90747. */
  90748. dispose(): void;
  90749. /**
  90750. * Serializes the sprite manager to a JSON object
  90751. * @param serializeTexture defines if the texture must be serialized as well
  90752. * @returns the JSON object
  90753. */
  90754. serialize(serializeTexture?: boolean): any;
  90755. /**
  90756. * Parses a JSON object to create a new sprite manager.
  90757. * @param parsedManager The JSON object to parse
  90758. * @param scene The scene to create the sprite managerin
  90759. * @param rootUrl The root url to use to load external dependencies like texture
  90760. * @returns the new sprite manager
  90761. */
  90762. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  90763. /**
  90764. * Creates a sprite manager from a snippet saved in a remote file
  90765. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  90766. * @param url defines the url to load from
  90767. * @param scene defines the hosting scene
  90768. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90769. * @returns a promise that will resolve to the new sprite manager
  90770. */
  90771. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90772. /**
  90773. * Creates a sprite manager from a snippet saved by the sprite editor
  90774. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  90775. * @param scene defines the hosting scene
  90776. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90777. * @returns a promise that will resolve to the new sprite manager
  90778. */
  90779. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90780. }
  90781. }
  90782. declare module BABYLON {
  90783. /** Interface used by value gradients (color, factor, ...) */
  90784. export interface IValueGradient {
  90785. /**
  90786. * Gets or sets the gradient value (between 0 and 1)
  90787. */
  90788. gradient: number;
  90789. }
  90790. /** Class used to store color4 gradient */
  90791. export class ColorGradient implements IValueGradient {
  90792. /**
  90793. * Gets or sets the gradient value (between 0 and 1)
  90794. */
  90795. gradient: number;
  90796. /**
  90797. * Gets or sets first associated color
  90798. */
  90799. color1: Color4;
  90800. /**
  90801. * Gets or sets second associated color
  90802. */
  90803. color2?: Color4 | undefined;
  90804. /**
  90805. * Creates a new color4 gradient
  90806. * @param gradient gets or sets the gradient value (between 0 and 1)
  90807. * @param color1 gets or sets first associated color
  90808. * @param color2 gets or sets first second color
  90809. */
  90810. constructor(
  90811. /**
  90812. * Gets or sets the gradient value (between 0 and 1)
  90813. */
  90814. gradient: number,
  90815. /**
  90816. * Gets or sets first associated color
  90817. */
  90818. color1: Color4,
  90819. /**
  90820. * Gets or sets second associated color
  90821. */
  90822. color2?: Color4 | undefined);
  90823. /**
  90824. * Will get a color picked randomly between color1 and color2.
  90825. * If color2 is undefined then color1 will be used
  90826. * @param result defines the target Color4 to store the result in
  90827. */
  90828. getColorToRef(result: Color4): void;
  90829. }
  90830. /** Class used to store color 3 gradient */
  90831. export class Color3Gradient implements IValueGradient {
  90832. /**
  90833. * Gets or sets the gradient value (between 0 and 1)
  90834. */
  90835. gradient: number;
  90836. /**
  90837. * Gets or sets the associated color
  90838. */
  90839. color: Color3;
  90840. /**
  90841. * Creates a new color3 gradient
  90842. * @param gradient gets or sets the gradient value (between 0 and 1)
  90843. * @param color gets or sets associated color
  90844. */
  90845. constructor(
  90846. /**
  90847. * Gets or sets the gradient value (between 0 and 1)
  90848. */
  90849. gradient: number,
  90850. /**
  90851. * Gets or sets the associated color
  90852. */
  90853. color: Color3);
  90854. }
  90855. /** Class used to store factor gradient */
  90856. export class FactorGradient implements IValueGradient {
  90857. /**
  90858. * Gets or sets the gradient value (between 0 and 1)
  90859. */
  90860. gradient: number;
  90861. /**
  90862. * Gets or sets first associated factor
  90863. */
  90864. factor1: number;
  90865. /**
  90866. * Gets or sets second associated factor
  90867. */
  90868. factor2?: number | undefined;
  90869. /**
  90870. * Creates a new factor gradient
  90871. * @param gradient gets or sets the gradient value (between 0 and 1)
  90872. * @param factor1 gets or sets first associated factor
  90873. * @param factor2 gets or sets second associated factor
  90874. */
  90875. constructor(
  90876. /**
  90877. * Gets or sets the gradient value (between 0 and 1)
  90878. */
  90879. gradient: number,
  90880. /**
  90881. * Gets or sets first associated factor
  90882. */
  90883. factor1: number,
  90884. /**
  90885. * Gets or sets second associated factor
  90886. */
  90887. factor2?: number | undefined);
  90888. /**
  90889. * Will get a number picked randomly between factor1 and factor2.
  90890. * If factor2 is undefined then factor1 will be used
  90891. * @returns the picked number
  90892. */
  90893. getFactor(): number;
  90894. }
  90895. /**
  90896. * Helper used to simplify some generic gradient tasks
  90897. */
  90898. export class GradientHelper {
  90899. /**
  90900. * Gets the current gradient from an array of IValueGradient
  90901. * @param ratio defines the current ratio to get
  90902. * @param gradients defines the array of IValueGradient
  90903. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90904. */
  90905. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90906. }
  90907. }
  90908. declare module BABYLON {
  90909. interface ThinEngine {
  90910. /**
  90911. * Creates a raw texture
  90912. * @param data defines the data to store in the texture
  90913. * @param width defines the width of the texture
  90914. * @param height defines the height of the texture
  90915. * @param format defines the format of the data
  90916. * @param generateMipMaps defines if the engine should generate the mip levels
  90917. * @param invertY defines if data must be stored with Y axis inverted
  90918. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  90919. * @param compression defines the compression used (null by default)
  90920. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90921. * @returns the raw texture inside an InternalTexture
  90922. */
  90923. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  90924. /**
  90925. * Update a raw texture
  90926. * @param texture defines the texture to update
  90927. * @param data defines the data to store in the texture
  90928. * @param format defines the format of the data
  90929. * @param invertY defines if data must be stored with Y axis inverted
  90930. */
  90931. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90932. /**
  90933. * Update a raw texture
  90934. * @param texture defines the texture to update
  90935. * @param data defines the data to store in the texture
  90936. * @param format defines the format of the data
  90937. * @param invertY defines if data must be stored with Y axis inverted
  90938. * @param compression defines the compression used (null by default)
  90939. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90940. */
  90941. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  90942. /**
  90943. * Creates a new raw cube texture
  90944. * @param data defines the array of data to use to create each face
  90945. * @param size defines the size of the textures
  90946. * @param format defines the format of the data
  90947. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90948. * @param generateMipMaps defines if the engine should generate the mip levels
  90949. * @param invertY defines if data must be stored with Y axis inverted
  90950. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90951. * @param compression defines the compression used (null by default)
  90952. * @returns the cube texture as an InternalTexture
  90953. */
  90954. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  90955. /**
  90956. * Update a raw cube texture
  90957. * @param texture defines the texture to udpdate
  90958. * @param data defines the data to store
  90959. * @param format defines the data format
  90960. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90961. * @param invertY defines if data must be stored with Y axis inverted
  90962. */
  90963. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  90964. /**
  90965. * Update a raw cube texture
  90966. * @param texture defines the texture to udpdate
  90967. * @param data defines the data to store
  90968. * @param format defines the data format
  90969. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90970. * @param invertY defines if data must be stored with Y axis inverted
  90971. * @param compression defines the compression used (null by default)
  90972. */
  90973. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  90974. /**
  90975. * Update a raw cube texture
  90976. * @param texture defines the texture to udpdate
  90977. * @param data defines the data to store
  90978. * @param format defines the data format
  90979. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90980. * @param invertY defines if data must be stored with Y axis inverted
  90981. * @param compression defines the compression used (null by default)
  90982. * @param level defines which level of the texture to update
  90983. */
  90984. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  90985. /**
  90986. * Creates a new raw cube texture from a specified url
  90987. * @param url defines the url where the data is located
  90988. * @param scene defines the current scene
  90989. * @param size defines the size of the textures
  90990. * @param format defines the format of the data
  90991. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90992. * @param noMipmap defines if the engine should avoid generating the mip levels
  90993. * @param callback defines a callback used to extract texture data from loaded data
  90994. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90995. * @param onLoad defines a callback called when texture is loaded
  90996. * @param onError defines a callback called if there is an error
  90997. * @returns the cube texture as an InternalTexture
  90998. */
  90999. 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;
  91000. /**
  91001. * Creates a new raw cube texture from a specified url
  91002. * @param url defines the url where the data is located
  91003. * @param scene defines the current scene
  91004. * @param size defines the size of the textures
  91005. * @param format defines the format of the data
  91006. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91007. * @param noMipmap defines if the engine should avoid generating the mip levels
  91008. * @param callback defines a callback used to extract texture data from loaded data
  91009. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91010. * @param onLoad defines a callback called when texture is loaded
  91011. * @param onError defines a callback called if there is an error
  91012. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91013. * @param invertY defines if data must be stored with Y axis inverted
  91014. * @returns the cube texture as an InternalTexture
  91015. */
  91016. 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;
  91017. /**
  91018. * Creates a new raw 3D texture
  91019. * @param data defines the data used to create the texture
  91020. * @param width defines the width of the texture
  91021. * @param height defines the height of the texture
  91022. * @param depth defines the depth of the texture
  91023. * @param format defines the format of the texture
  91024. * @param generateMipMaps defines if the engine must generate mip levels
  91025. * @param invertY defines if data must be stored with Y axis inverted
  91026. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91027. * @param compression defines the compressed used (can be null)
  91028. * @param textureType defines the compressed used (can be null)
  91029. * @returns a new raw 3D texture (stored in an InternalTexture)
  91030. */
  91031. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91032. /**
  91033. * Update a raw 3D texture
  91034. * @param texture defines the texture to update
  91035. * @param data defines the data to store
  91036. * @param format defines the data format
  91037. * @param invertY defines if data must be stored with Y axis inverted
  91038. */
  91039. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91040. /**
  91041. * Update a raw 3D texture
  91042. * @param texture defines the texture to update
  91043. * @param data defines the data to store
  91044. * @param format defines the data format
  91045. * @param invertY defines if data must be stored with Y axis inverted
  91046. * @param compression defines the used compression (can be null)
  91047. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91048. */
  91049. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91050. /**
  91051. * Creates a new raw 2D array texture
  91052. * @param data defines the data used to create the texture
  91053. * @param width defines the width of the texture
  91054. * @param height defines the height of the texture
  91055. * @param depth defines the number of layers of the texture
  91056. * @param format defines the format of the texture
  91057. * @param generateMipMaps defines if the engine must generate mip levels
  91058. * @param invertY defines if data must be stored with Y axis inverted
  91059. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91060. * @param compression defines the compressed used (can be null)
  91061. * @param textureType defines the compressed used (can be null)
  91062. * @returns a new raw 2D array texture (stored in an InternalTexture)
  91063. */
  91064. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91065. /**
  91066. * Update a raw 2D array texture
  91067. * @param texture defines the texture to update
  91068. * @param data defines the data to store
  91069. * @param format defines the data format
  91070. * @param invertY defines if data must be stored with Y axis inverted
  91071. */
  91072. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91073. /**
  91074. * Update a raw 2D array texture
  91075. * @param texture defines the texture to update
  91076. * @param data defines the data to store
  91077. * @param format defines the data format
  91078. * @param invertY defines if data must be stored with Y axis inverted
  91079. * @param compression defines the used compression (can be null)
  91080. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91081. */
  91082. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91083. }
  91084. }
  91085. declare module BABYLON {
  91086. /**
  91087. * Raw texture can help creating a texture directly from an array of data.
  91088. * This can be super useful if you either get the data from an uncompressed source or
  91089. * if you wish to create your texture pixel by pixel.
  91090. */
  91091. export class RawTexture extends Texture {
  91092. /**
  91093. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91094. */
  91095. format: number;
  91096. /**
  91097. * Instantiates a new RawTexture.
  91098. * Raw texture can help creating a texture directly from an array of data.
  91099. * This can be super useful if you either get the data from an uncompressed source or
  91100. * if you wish to create your texture pixel by pixel.
  91101. * @param data define the array of data to use to create the texture
  91102. * @param width define the width of the texture
  91103. * @param height define the height of the texture
  91104. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91105. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91106. * @param generateMipMaps define whether mip maps should be generated or not
  91107. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91108. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91109. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91110. */
  91111. constructor(data: ArrayBufferView, width: number, height: number,
  91112. /**
  91113. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91114. */
  91115. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  91116. /**
  91117. * Updates the texture underlying data.
  91118. * @param data Define the new data of the texture
  91119. */
  91120. update(data: ArrayBufferView): void;
  91121. /**
  91122. * Creates a luminance texture from some data.
  91123. * @param data Define the texture data
  91124. * @param width Define the width of the texture
  91125. * @param height Define the height of the texture
  91126. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91127. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91128. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91129. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91130. * @returns the luminance texture
  91131. */
  91132. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91133. /**
  91134. * Creates a luminance alpha texture from some data.
  91135. * @param data Define the texture data
  91136. * @param width Define the width of the texture
  91137. * @param height Define the height of the texture
  91138. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91139. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91140. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91141. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91142. * @returns the luminance alpha texture
  91143. */
  91144. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91145. /**
  91146. * Creates an alpha texture from some data.
  91147. * @param data Define the texture data
  91148. * @param width Define the width of the texture
  91149. * @param height Define the height of the texture
  91150. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91151. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91152. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91153. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91154. * @returns the alpha texture
  91155. */
  91156. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91157. /**
  91158. * Creates a RGB texture from some data.
  91159. * @param data Define the texture data
  91160. * @param width Define the width of the texture
  91161. * @param height Define the height of the texture
  91162. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91163. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91164. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91165. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91166. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91167. * @returns the RGB alpha texture
  91168. */
  91169. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91170. /**
  91171. * Creates a RGBA texture from some data.
  91172. * @param data Define the texture data
  91173. * @param width Define the width of the texture
  91174. * @param height Define the height of the texture
  91175. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91176. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91177. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91178. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91179. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91180. * @returns the RGBA texture
  91181. */
  91182. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91183. /**
  91184. * Creates a R texture from some data.
  91185. * @param data Define the texture data
  91186. * @param width Define the width of the texture
  91187. * @param height Define the height of the texture
  91188. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91189. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91190. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91191. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91192. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91193. * @returns the R texture
  91194. */
  91195. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91196. }
  91197. }
  91198. declare module BABYLON {
  91199. interface ThinEngine {
  91200. /**
  91201. * Update a dynamic index buffer
  91202. * @param indexBuffer defines the target index buffer
  91203. * @param indices defines the data to update
  91204. * @param offset defines the offset in the target index buffer where update should start
  91205. */
  91206. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91207. /**
  91208. * Updates a dynamic vertex buffer.
  91209. * @param vertexBuffer the vertex buffer to update
  91210. * @param data the data used to update the vertex buffer
  91211. * @param byteOffset the byte offset of the data
  91212. * @param byteLength the byte length of the data
  91213. */
  91214. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91215. }
  91216. }
  91217. declare module BABYLON {
  91218. interface AbstractScene {
  91219. /**
  91220. * The list of procedural textures added to the scene
  91221. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91222. */
  91223. proceduralTextures: Array<ProceduralTexture>;
  91224. }
  91225. /**
  91226. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  91227. * in a given scene.
  91228. */
  91229. export class ProceduralTextureSceneComponent implements ISceneComponent {
  91230. /**
  91231. * The component name helpfull to identify the component in the list of scene components.
  91232. */
  91233. readonly name: string;
  91234. /**
  91235. * The scene the component belongs to.
  91236. */
  91237. scene: Scene;
  91238. /**
  91239. * Creates a new instance of the component for the given scene
  91240. * @param scene Defines the scene to register the component in
  91241. */
  91242. constructor(scene: Scene);
  91243. /**
  91244. * Registers the component in a given scene
  91245. */
  91246. register(): void;
  91247. /**
  91248. * Rebuilds the elements related to this component in case of
  91249. * context lost for instance.
  91250. */
  91251. rebuild(): void;
  91252. /**
  91253. * Disposes the component and the associated ressources.
  91254. */
  91255. dispose(): void;
  91256. private _beforeClear;
  91257. }
  91258. }
  91259. declare module BABYLON {
  91260. interface ThinEngine {
  91261. /**
  91262. * Creates a new render target cube texture
  91263. * @param size defines the size of the texture
  91264. * @param options defines the options used to create the texture
  91265. * @returns a new render target cube texture stored in an InternalTexture
  91266. */
  91267. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  91268. }
  91269. }
  91270. declare module BABYLON {
  91271. /** @hidden */
  91272. export var proceduralVertexShader: {
  91273. name: string;
  91274. shader: string;
  91275. };
  91276. }
  91277. declare module BABYLON {
  91278. /**
  91279. * 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.
  91280. * This is the base class of any Procedural texture and contains most of the shareable code.
  91281. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91282. */
  91283. export class ProceduralTexture extends Texture {
  91284. isCube: boolean;
  91285. /**
  91286. * Define if the texture is enabled or not (disabled texture will not render)
  91287. */
  91288. isEnabled: boolean;
  91289. /**
  91290. * Define if the texture must be cleared before rendering (default is true)
  91291. */
  91292. autoClear: boolean;
  91293. /**
  91294. * Callback called when the texture is generated
  91295. */
  91296. onGenerated: () => void;
  91297. /**
  91298. * Event raised when the texture is generated
  91299. */
  91300. onGeneratedObservable: Observable<ProceduralTexture>;
  91301. /** @hidden */
  91302. _generateMipMaps: boolean;
  91303. /** @hidden **/
  91304. _effect: Effect;
  91305. /** @hidden */
  91306. _textures: {
  91307. [key: string]: Texture;
  91308. };
  91309. /** @hidden */
  91310. protected _fallbackTexture: Nullable<Texture>;
  91311. private _size;
  91312. private _currentRefreshId;
  91313. private _frameId;
  91314. private _refreshRate;
  91315. private _vertexBuffers;
  91316. private _indexBuffer;
  91317. private _uniforms;
  91318. private _samplers;
  91319. private _fragment;
  91320. private _floats;
  91321. private _ints;
  91322. private _floatsArrays;
  91323. private _colors3;
  91324. private _colors4;
  91325. private _vectors2;
  91326. private _vectors3;
  91327. private _matrices;
  91328. private _fallbackTextureUsed;
  91329. private _fullEngine;
  91330. private _cachedDefines;
  91331. private _contentUpdateId;
  91332. private _contentData;
  91333. /**
  91334. * Instantiates a new procedural texture.
  91335. * 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.
  91336. * This is the base class of any Procedural texture and contains most of the shareable code.
  91337. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91338. * @param name Define the name of the texture
  91339. * @param size Define the size of the texture to create
  91340. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  91341. * @param scene Define the scene the texture belongs to
  91342. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  91343. * @param generateMipMaps Define if the texture should creates mip maps or not
  91344. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  91345. */
  91346. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  91347. /**
  91348. * The effect that is created when initializing the post process.
  91349. * @returns The created effect corresponding the the postprocess.
  91350. */
  91351. getEffect(): Effect;
  91352. /**
  91353. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  91354. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  91355. */
  91356. getContent(): Nullable<ArrayBufferView>;
  91357. private _createIndexBuffer;
  91358. /** @hidden */
  91359. _rebuild(): void;
  91360. /**
  91361. * Resets the texture in order to recreate its associated resources.
  91362. * This can be called in case of context loss
  91363. */
  91364. reset(): void;
  91365. protected _getDefines(): string;
  91366. /**
  91367. * Is the texture ready to be used ? (rendered at least once)
  91368. * @returns true if ready, otherwise, false.
  91369. */
  91370. isReady(): boolean;
  91371. /**
  91372. * Resets the refresh counter of the texture and start bak from scratch.
  91373. * Could be useful to regenerate the texture if it is setup to render only once.
  91374. */
  91375. resetRefreshCounter(): void;
  91376. /**
  91377. * Set the fragment shader to use in order to render the texture.
  91378. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  91379. */
  91380. setFragment(fragment: any): void;
  91381. /**
  91382. * Define the refresh rate of the texture or the rendering frequency.
  91383. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  91384. */
  91385. get refreshRate(): number;
  91386. set refreshRate(value: number);
  91387. /** @hidden */
  91388. _shouldRender(): boolean;
  91389. /**
  91390. * Get the size the texture is rendering at.
  91391. * @returns the size (texture is always squared)
  91392. */
  91393. getRenderSize(): number;
  91394. /**
  91395. * Resize the texture to new value.
  91396. * @param size Define the new size the texture should have
  91397. * @param generateMipMaps Define whether the new texture should create mip maps
  91398. */
  91399. resize(size: number, generateMipMaps: boolean): void;
  91400. private _checkUniform;
  91401. /**
  91402. * Set a texture in the shader program used to render.
  91403. * @param name Define the name of the uniform samplers as defined in the shader
  91404. * @param texture Define the texture to bind to this sampler
  91405. * @return the texture itself allowing "fluent" like uniform updates
  91406. */
  91407. setTexture(name: string, texture: Texture): ProceduralTexture;
  91408. /**
  91409. * Set a float in the shader.
  91410. * @param name Define the name of the uniform as defined in the shader
  91411. * @param value Define the value to give to the uniform
  91412. * @return the texture itself allowing "fluent" like uniform updates
  91413. */
  91414. setFloat(name: string, value: number): ProceduralTexture;
  91415. /**
  91416. * Set a int in the shader.
  91417. * @param name Define the name of the uniform as defined in the shader
  91418. * @param value Define the value to give to the uniform
  91419. * @return the texture itself allowing "fluent" like uniform updates
  91420. */
  91421. setInt(name: string, value: number): ProceduralTexture;
  91422. /**
  91423. * Set an array of floats in the shader.
  91424. * @param name Define the name of the uniform as defined in the shader
  91425. * @param value Define the value to give to the uniform
  91426. * @return the texture itself allowing "fluent" like uniform updates
  91427. */
  91428. setFloats(name: string, value: number[]): ProceduralTexture;
  91429. /**
  91430. * Set a vec3 in the shader from a Color3.
  91431. * @param name Define the name of the uniform as defined in the shader
  91432. * @param value Define the value to give to the uniform
  91433. * @return the texture itself allowing "fluent" like uniform updates
  91434. */
  91435. setColor3(name: string, value: Color3): ProceduralTexture;
  91436. /**
  91437. * Set a vec4 in the shader from a Color4.
  91438. * @param name Define the name of the uniform as defined in the shader
  91439. * @param value Define the value to give to the uniform
  91440. * @return the texture itself allowing "fluent" like uniform updates
  91441. */
  91442. setColor4(name: string, value: Color4): ProceduralTexture;
  91443. /**
  91444. * Set a vec2 in the shader from a Vector2.
  91445. * @param name Define the name of the uniform as defined in the shader
  91446. * @param value Define the value to give to the uniform
  91447. * @return the texture itself allowing "fluent" like uniform updates
  91448. */
  91449. setVector2(name: string, value: Vector2): ProceduralTexture;
  91450. /**
  91451. * Set a vec3 in the shader from a Vector3.
  91452. * @param name Define the name of the uniform as defined in the shader
  91453. * @param value Define the value to give to the uniform
  91454. * @return the texture itself allowing "fluent" like uniform updates
  91455. */
  91456. setVector3(name: string, value: Vector3): ProceduralTexture;
  91457. /**
  91458. * Set a mat4 in the shader from a MAtrix.
  91459. * @param name Define the name of the uniform as defined in the shader
  91460. * @param value Define the value to give to the uniform
  91461. * @return the texture itself allowing "fluent" like uniform updates
  91462. */
  91463. setMatrix(name: string, value: Matrix): ProceduralTexture;
  91464. /**
  91465. * Render the texture to its associated render target.
  91466. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  91467. */
  91468. render(useCameraPostProcess?: boolean): void;
  91469. /**
  91470. * Clone the texture.
  91471. * @returns the cloned texture
  91472. */
  91473. clone(): ProceduralTexture;
  91474. /**
  91475. * Dispose the texture and release its asoociated resources.
  91476. */
  91477. dispose(): void;
  91478. }
  91479. }
  91480. declare module BABYLON {
  91481. /**
  91482. * This represents the base class for particle system in Babylon.
  91483. * 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.
  91484. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  91485. * @example https://doc.babylonjs.com/babylon101/particles
  91486. */
  91487. export class BaseParticleSystem {
  91488. /**
  91489. * Source color is added to the destination color without alpha affecting the result
  91490. */
  91491. static BLENDMODE_ONEONE: number;
  91492. /**
  91493. * Blend current color and particle color using particle’s alpha
  91494. */
  91495. static BLENDMODE_STANDARD: number;
  91496. /**
  91497. * Add current color and particle color multiplied by particle’s alpha
  91498. */
  91499. static BLENDMODE_ADD: number;
  91500. /**
  91501. * Multiply current color with particle color
  91502. */
  91503. static BLENDMODE_MULTIPLY: number;
  91504. /**
  91505. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  91506. */
  91507. static BLENDMODE_MULTIPLYADD: number;
  91508. /**
  91509. * List of animations used by the particle system.
  91510. */
  91511. animations: Animation[];
  91512. /**
  91513. * Gets or sets the unique id of the particle system
  91514. */
  91515. uniqueId: number;
  91516. /**
  91517. * The id of the Particle system.
  91518. */
  91519. id: string;
  91520. /**
  91521. * The friendly name of the Particle system.
  91522. */
  91523. name: string;
  91524. /**
  91525. * Snippet ID if the particle system was created from the snippet server
  91526. */
  91527. snippetId: string;
  91528. /**
  91529. * The rendering group used by the Particle system to chose when to render.
  91530. */
  91531. renderingGroupId: number;
  91532. /**
  91533. * The emitter represents the Mesh or position we are attaching the particle system to.
  91534. */
  91535. emitter: Nullable<AbstractMesh | Vector3>;
  91536. /**
  91537. * The maximum number of particles to emit per frame
  91538. */
  91539. emitRate: number;
  91540. /**
  91541. * If you want to launch only a few particles at once, that can be done, as well.
  91542. */
  91543. manualEmitCount: number;
  91544. /**
  91545. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91546. */
  91547. updateSpeed: number;
  91548. /**
  91549. * The amount of time the particle system is running (depends of the overall update speed).
  91550. */
  91551. targetStopDuration: number;
  91552. /**
  91553. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91554. */
  91555. disposeOnStop: boolean;
  91556. /**
  91557. * Minimum power of emitting particles.
  91558. */
  91559. minEmitPower: number;
  91560. /**
  91561. * Maximum power of emitting particles.
  91562. */
  91563. maxEmitPower: number;
  91564. /**
  91565. * Minimum life time of emitting particles.
  91566. */
  91567. minLifeTime: number;
  91568. /**
  91569. * Maximum life time of emitting particles.
  91570. */
  91571. maxLifeTime: number;
  91572. /**
  91573. * Minimum Size of emitting particles.
  91574. */
  91575. minSize: number;
  91576. /**
  91577. * Maximum Size of emitting particles.
  91578. */
  91579. maxSize: number;
  91580. /**
  91581. * Minimum scale of emitting particles on X axis.
  91582. */
  91583. minScaleX: number;
  91584. /**
  91585. * Maximum scale of emitting particles on X axis.
  91586. */
  91587. maxScaleX: number;
  91588. /**
  91589. * Minimum scale of emitting particles on Y axis.
  91590. */
  91591. minScaleY: number;
  91592. /**
  91593. * Maximum scale of emitting particles on Y axis.
  91594. */
  91595. maxScaleY: number;
  91596. /**
  91597. * Gets or sets the minimal initial rotation in radians.
  91598. */
  91599. minInitialRotation: number;
  91600. /**
  91601. * Gets or sets the maximal initial rotation in radians.
  91602. */
  91603. maxInitialRotation: number;
  91604. /**
  91605. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91606. */
  91607. minAngularSpeed: number;
  91608. /**
  91609. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91610. */
  91611. maxAngularSpeed: number;
  91612. /**
  91613. * The texture used to render each particle. (this can be a spritesheet)
  91614. */
  91615. particleTexture: Nullable<BaseTexture>;
  91616. /**
  91617. * The layer mask we are rendering the particles through.
  91618. */
  91619. layerMask: number;
  91620. /**
  91621. * This can help using your own shader to render the particle system.
  91622. * The according effect will be created
  91623. */
  91624. customShader: any;
  91625. /**
  91626. * By default particle system starts as soon as they are created. This prevents the
  91627. * automatic start to happen and let you decide when to start emitting particles.
  91628. */
  91629. preventAutoStart: boolean;
  91630. private _noiseTexture;
  91631. /**
  91632. * Gets or sets a texture used to add random noise to particle positions
  91633. */
  91634. get noiseTexture(): Nullable<ProceduralTexture>;
  91635. set noiseTexture(value: Nullable<ProceduralTexture>);
  91636. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91637. noiseStrength: Vector3;
  91638. /**
  91639. * Callback triggered when the particle animation is ending.
  91640. */
  91641. onAnimationEnd: Nullable<() => void>;
  91642. /**
  91643. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  91644. */
  91645. blendMode: number;
  91646. /**
  91647. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  91648. * to override the particles.
  91649. */
  91650. forceDepthWrite: boolean;
  91651. /** 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 */
  91652. preWarmCycles: number;
  91653. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  91654. preWarmStepOffset: number;
  91655. /**
  91656. * 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)
  91657. */
  91658. spriteCellChangeSpeed: number;
  91659. /**
  91660. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91661. */
  91662. startSpriteCellID: number;
  91663. /**
  91664. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91665. */
  91666. endSpriteCellID: number;
  91667. /**
  91668. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91669. */
  91670. spriteCellWidth: number;
  91671. /**
  91672. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91673. */
  91674. spriteCellHeight: number;
  91675. /**
  91676. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91677. */
  91678. spriteRandomStartCell: boolean;
  91679. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91680. translationPivot: Vector2;
  91681. /** @hidden */
  91682. protected _isAnimationSheetEnabled: boolean;
  91683. /**
  91684. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91685. */
  91686. beginAnimationOnStart: boolean;
  91687. /**
  91688. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91689. */
  91690. beginAnimationFrom: number;
  91691. /**
  91692. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91693. */
  91694. beginAnimationTo: number;
  91695. /**
  91696. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91697. */
  91698. beginAnimationLoop: boolean;
  91699. /**
  91700. * Gets or sets a world offset applied to all particles
  91701. */
  91702. worldOffset: Vector3;
  91703. /**
  91704. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  91705. */
  91706. get isAnimationSheetEnabled(): boolean;
  91707. set isAnimationSheetEnabled(value: boolean);
  91708. /**
  91709. * Get hosting scene
  91710. * @returns the scene
  91711. */
  91712. getScene(): Nullable<Scene>;
  91713. /**
  91714. * You can use gravity if you want to give an orientation to your particles.
  91715. */
  91716. gravity: Vector3;
  91717. protected _colorGradients: Nullable<Array<ColorGradient>>;
  91718. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  91719. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  91720. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  91721. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  91722. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  91723. protected _dragGradients: Nullable<Array<FactorGradient>>;
  91724. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  91725. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  91726. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  91727. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  91728. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  91729. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  91730. /**
  91731. * Defines the delay in milliseconds before starting the system (0 by default)
  91732. */
  91733. startDelay: number;
  91734. /**
  91735. * Gets the current list of drag gradients.
  91736. * You must use addDragGradient and removeDragGradient to udpate this list
  91737. * @returns the list of drag gradients
  91738. */
  91739. getDragGradients(): Nullable<Array<FactorGradient>>;
  91740. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91741. limitVelocityDamping: number;
  91742. /**
  91743. * Gets the current list of limit velocity gradients.
  91744. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91745. * @returns the list of limit velocity gradients
  91746. */
  91747. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91748. /**
  91749. * Gets the current list of color gradients.
  91750. * You must use addColorGradient and removeColorGradient to udpate this list
  91751. * @returns the list of color gradients
  91752. */
  91753. getColorGradients(): Nullable<Array<ColorGradient>>;
  91754. /**
  91755. * Gets the current list of size gradients.
  91756. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91757. * @returns the list of size gradients
  91758. */
  91759. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91760. /**
  91761. * Gets the current list of color remap gradients.
  91762. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91763. * @returns the list of color remap gradients
  91764. */
  91765. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91766. /**
  91767. * Gets the current list of alpha remap gradients.
  91768. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91769. * @returns the list of alpha remap gradients
  91770. */
  91771. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91772. /**
  91773. * Gets the current list of life time gradients.
  91774. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91775. * @returns the list of life time gradients
  91776. */
  91777. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91778. /**
  91779. * Gets the current list of angular speed gradients.
  91780. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91781. * @returns the list of angular speed gradients
  91782. */
  91783. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91784. /**
  91785. * Gets the current list of velocity gradients.
  91786. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91787. * @returns the list of velocity gradients
  91788. */
  91789. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91790. /**
  91791. * Gets the current list of start size gradients.
  91792. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91793. * @returns the list of start size gradients
  91794. */
  91795. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91796. /**
  91797. * Gets the current list of emit rate gradients.
  91798. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91799. * @returns the list of emit rate gradients
  91800. */
  91801. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91802. /**
  91803. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91804. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91805. */
  91806. get direction1(): Vector3;
  91807. set direction1(value: Vector3);
  91808. /**
  91809. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91810. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91811. */
  91812. get direction2(): Vector3;
  91813. set direction2(value: Vector3);
  91814. /**
  91815. * 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.
  91816. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91817. */
  91818. get minEmitBox(): Vector3;
  91819. set minEmitBox(value: Vector3);
  91820. /**
  91821. * 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.
  91822. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91823. */
  91824. get maxEmitBox(): Vector3;
  91825. set maxEmitBox(value: Vector3);
  91826. /**
  91827. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91828. */
  91829. color1: Color4;
  91830. /**
  91831. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91832. */
  91833. color2: Color4;
  91834. /**
  91835. * Color the particle will have at the end of its lifetime
  91836. */
  91837. colorDead: Color4;
  91838. /**
  91839. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  91840. */
  91841. textureMask: Color4;
  91842. /**
  91843. * The particle emitter type defines the emitter used by the particle system.
  91844. * It can be for example box, sphere, or cone...
  91845. */
  91846. particleEmitterType: IParticleEmitterType;
  91847. /** @hidden */
  91848. _isSubEmitter: boolean;
  91849. /**
  91850. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91851. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91852. */
  91853. billboardMode: number;
  91854. protected _isBillboardBased: boolean;
  91855. /**
  91856. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91857. */
  91858. get isBillboardBased(): boolean;
  91859. set isBillboardBased(value: boolean);
  91860. /**
  91861. * The scene the particle system belongs to.
  91862. */
  91863. protected _scene: Nullable<Scene>;
  91864. /**
  91865. * The engine the particle system belongs to.
  91866. */
  91867. protected _engine: ThinEngine;
  91868. /**
  91869. * Local cache of defines for image processing.
  91870. */
  91871. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  91872. /**
  91873. * Default configuration related to image processing available in the standard Material.
  91874. */
  91875. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  91876. /**
  91877. * Gets the image processing configuration used either in this material.
  91878. */
  91879. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  91880. /**
  91881. * Sets the Default image processing configuration used either in the this material.
  91882. *
  91883. * If sets to null, the scene one is in use.
  91884. */
  91885. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  91886. /**
  91887. * Attaches a new image processing configuration to the Standard Material.
  91888. * @param configuration
  91889. */
  91890. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  91891. /** @hidden */
  91892. protected _reset(): void;
  91893. /** @hidden */
  91894. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  91895. /**
  91896. * Instantiates a particle system.
  91897. * 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.
  91898. * @param name The name of the particle system
  91899. */
  91900. constructor(name: string);
  91901. /**
  91902. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91903. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91904. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91905. * @returns the emitter
  91906. */
  91907. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91908. /**
  91909. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91910. * @param radius The radius of the hemisphere to emit from
  91911. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91912. * @returns the emitter
  91913. */
  91914. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  91915. /**
  91916. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91917. * @param radius The radius of the sphere to emit from
  91918. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91919. * @returns the emitter
  91920. */
  91921. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  91922. /**
  91923. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91924. * @param radius The radius of the sphere to emit from
  91925. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91926. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91927. * @returns the emitter
  91928. */
  91929. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  91930. /**
  91931. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91932. * @param radius The radius of the emission cylinder
  91933. * @param height The height of the emission cylinder
  91934. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91935. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91936. * @returns the emitter
  91937. */
  91938. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  91939. /**
  91940. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91941. * @param radius The radius of the cylinder to emit from
  91942. * @param height The height of the emission cylinder
  91943. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91944. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91945. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91946. * @returns the emitter
  91947. */
  91948. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  91949. /**
  91950. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91951. * @param radius The radius of the cone to emit from
  91952. * @param angle The base angle of the cone
  91953. * @returns the emitter
  91954. */
  91955. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  91956. /**
  91957. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91958. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91959. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91960. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91961. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91962. * @returns the emitter
  91963. */
  91964. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91965. }
  91966. }
  91967. declare module BABYLON {
  91968. /**
  91969. * Type of sub emitter
  91970. */
  91971. export enum SubEmitterType {
  91972. /**
  91973. * Attached to the particle over it's lifetime
  91974. */
  91975. ATTACHED = 0,
  91976. /**
  91977. * Created when the particle dies
  91978. */
  91979. END = 1
  91980. }
  91981. /**
  91982. * Sub emitter class used to emit particles from an existing particle
  91983. */
  91984. export class SubEmitter {
  91985. /**
  91986. * the particle system to be used by the sub emitter
  91987. */
  91988. particleSystem: ParticleSystem;
  91989. /**
  91990. * Type of the submitter (Default: END)
  91991. */
  91992. type: SubEmitterType;
  91993. /**
  91994. * 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)
  91995. * Note: This only is supported when using an emitter of type Mesh
  91996. */
  91997. inheritDirection: boolean;
  91998. /**
  91999. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  92000. */
  92001. inheritedVelocityAmount: number;
  92002. /**
  92003. * Creates a sub emitter
  92004. * @param particleSystem the particle system to be used by the sub emitter
  92005. */
  92006. constructor(
  92007. /**
  92008. * the particle system to be used by the sub emitter
  92009. */
  92010. particleSystem: ParticleSystem);
  92011. /**
  92012. * Clones the sub emitter
  92013. * @returns the cloned sub emitter
  92014. */
  92015. clone(): SubEmitter;
  92016. /**
  92017. * Serialize current object to a JSON object
  92018. * @returns the serialized object
  92019. */
  92020. serialize(): any;
  92021. /** @hidden */
  92022. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  92023. /**
  92024. * Creates a new SubEmitter from a serialized JSON version
  92025. * @param serializationObject defines the JSON object to read from
  92026. * @param sceneOrEngine defines the hosting scene or the hosting engine
  92027. * @param rootUrl defines the rootUrl for data loading
  92028. * @returns a new SubEmitter
  92029. */
  92030. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  92031. /** Release associated resources */
  92032. dispose(): void;
  92033. }
  92034. }
  92035. declare module BABYLON {
  92036. /** @hidden */
  92037. export var imageProcessingDeclaration: {
  92038. name: string;
  92039. shader: string;
  92040. };
  92041. }
  92042. declare module BABYLON {
  92043. /** @hidden */
  92044. export var imageProcessingFunctions: {
  92045. name: string;
  92046. shader: string;
  92047. };
  92048. }
  92049. declare module BABYLON {
  92050. /** @hidden */
  92051. export var particlesPixelShader: {
  92052. name: string;
  92053. shader: string;
  92054. };
  92055. }
  92056. declare module BABYLON {
  92057. /** @hidden */
  92058. export var particlesVertexShader: {
  92059. name: string;
  92060. shader: string;
  92061. };
  92062. }
  92063. declare module BABYLON {
  92064. /**
  92065. * Interface used to define entities containing multiple clip planes
  92066. */
  92067. export interface IClipPlanesHolder {
  92068. /**
  92069. * Gets or sets the active clipplane 1
  92070. */
  92071. clipPlane: Nullable<Plane>;
  92072. /**
  92073. * Gets or sets the active clipplane 2
  92074. */
  92075. clipPlane2: Nullable<Plane>;
  92076. /**
  92077. * Gets or sets the active clipplane 3
  92078. */
  92079. clipPlane3: Nullable<Plane>;
  92080. /**
  92081. * Gets or sets the active clipplane 4
  92082. */
  92083. clipPlane4: Nullable<Plane>;
  92084. /**
  92085. * Gets or sets the active clipplane 5
  92086. */
  92087. clipPlane5: Nullable<Plane>;
  92088. /**
  92089. * Gets or sets the active clipplane 6
  92090. */
  92091. clipPlane6: Nullable<Plane>;
  92092. }
  92093. }
  92094. declare module BABYLON {
  92095. /**
  92096. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  92097. *
  92098. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  92099. *
  92100. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  92101. */
  92102. export class ThinMaterialHelper {
  92103. /**
  92104. * Binds the clip plane information from the holder to the effect.
  92105. * @param effect The effect we are binding the data to
  92106. * @param holder The entity containing the clip plane information
  92107. */
  92108. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  92109. }
  92110. }
  92111. declare module BABYLON {
  92112. interface ThinEngine {
  92113. /**
  92114. * Sets alpha constants used by some alpha blending modes
  92115. * @param r defines the red component
  92116. * @param g defines the green component
  92117. * @param b defines the blue component
  92118. * @param a defines the alpha component
  92119. */
  92120. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  92121. /**
  92122. * Sets the current alpha mode
  92123. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  92124. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  92125. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92126. */
  92127. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  92128. /**
  92129. * Gets the current alpha mode
  92130. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92131. * @returns the current alpha mode
  92132. */
  92133. getAlphaMode(): number;
  92134. /**
  92135. * Sets the current alpha equation
  92136. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  92137. */
  92138. setAlphaEquation(equation: number): void;
  92139. /**
  92140. * Gets the current alpha equation.
  92141. * @returns the current alpha equation
  92142. */
  92143. getAlphaEquation(): number;
  92144. }
  92145. }
  92146. declare module BABYLON {
  92147. /**
  92148. * This represents a particle system in Babylon.
  92149. * 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.
  92150. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92151. * @example https://doc.babylonjs.com/babylon101/particles
  92152. */
  92153. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  92154. /**
  92155. * Billboard mode will only apply to Y axis
  92156. */
  92157. static readonly BILLBOARDMODE_Y: number;
  92158. /**
  92159. * Billboard mode will apply to all axes
  92160. */
  92161. static readonly BILLBOARDMODE_ALL: number;
  92162. /**
  92163. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  92164. */
  92165. static readonly BILLBOARDMODE_STRETCHED: number;
  92166. /**
  92167. * This function can be defined to provide custom update for active particles.
  92168. * This function will be called instead of regular update (age, position, color, etc.).
  92169. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  92170. */
  92171. updateFunction: (particles: Particle[]) => void;
  92172. private _emitterWorldMatrix;
  92173. /**
  92174. * This function can be defined to specify initial direction for every new particle.
  92175. * It by default use the emitterType defined function
  92176. */
  92177. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92178. /**
  92179. * This function can be defined to specify initial position for every new particle.
  92180. * It by default use the emitterType defined function
  92181. */
  92182. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92183. /**
  92184. * @hidden
  92185. */
  92186. _inheritedVelocityOffset: Vector3;
  92187. /**
  92188. * An event triggered when the system is disposed
  92189. */
  92190. onDisposeObservable: Observable<IParticleSystem>;
  92191. private _onDisposeObserver;
  92192. /**
  92193. * Sets a callback that will be triggered when the system is disposed
  92194. */
  92195. set onDispose(callback: () => void);
  92196. private _particles;
  92197. private _epsilon;
  92198. private _capacity;
  92199. private _stockParticles;
  92200. private _newPartsExcess;
  92201. private _vertexData;
  92202. private _vertexBuffer;
  92203. private _vertexBuffers;
  92204. private _spriteBuffer;
  92205. private _indexBuffer;
  92206. private _effect;
  92207. private _customEffect;
  92208. private _cachedDefines;
  92209. private _scaledColorStep;
  92210. private _colorDiff;
  92211. private _scaledDirection;
  92212. private _scaledGravity;
  92213. private _currentRenderId;
  92214. private _alive;
  92215. private _useInstancing;
  92216. private _started;
  92217. private _stopped;
  92218. private _actualFrame;
  92219. private _scaledUpdateSpeed;
  92220. private _vertexBufferSize;
  92221. /** @hidden */
  92222. _currentEmitRateGradient: Nullable<FactorGradient>;
  92223. /** @hidden */
  92224. _currentEmitRate1: number;
  92225. /** @hidden */
  92226. _currentEmitRate2: number;
  92227. /** @hidden */
  92228. _currentStartSizeGradient: Nullable<FactorGradient>;
  92229. /** @hidden */
  92230. _currentStartSize1: number;
  92231. /** @hidden */
  92232. _currentStartSize2: number;
  92233. private readonly _rawTextureWidth;
  92234. private _rampGradientsTexture;
  92235. private _useRampGradients;
  92236. /** Gets or sets a matrix to use to compute projection */
  92237. defaultProjectionMatrix: Matrix;
  92238. /** Gets or sets a matrix to use to compute view */
  92239. defaultViewMatrix: Matrix;
  92240. /** Gets or sets a boolean indicating that ramp gradients must be used
  92241. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92242. */
  92243. get useRampGradients(): boolean;
  92244. set useRampGradients(value: boolean);
  92245. /**
  92246. * 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.
  92247. * 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: [])
  92248. */
  92249. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  92250. private _subEmitters;
  92251. /**
  92252. * @hidden
  92253. * If the particle systems emitter should be disposed when the particle system is disposed
  92254. */
  92255. _disposeEmitterOnDispose: boolean;
  92256. /**
  92257. * The current active Sub-systems, this property is used by the root particle system only.
  92258. */
  92259. activeSubSystems: Array<ParticleSystem>;
  92260. /**
  92261. * Specifies if the particles are updated in emitter local space or world space
  92262. */
  92263. isLocal: boolean;
  92264. private _rootParticleSystem;
  92265. /**
  92266. * Gets the current list of active particles
  92267. */
  92268. get particles(): Particle[];
  92269. /**
  92270. * Gets the number of particles active at the same time.
  92271. * @returns The number of active particles.
  92272. */
  92273. getActiveCount(): number;
  92274. /**
  92275. * Returns the string "ParticleSystem"
  92276. * @returns a string containing the class name
  92277. */
  92278. getClassName(): string;
  92279. /**
  92280. * Gets a boolean indicating that the system is stopping
  92281. * @returns true if the system is currently stopping
  92282. */
  92283. isStopping(): boolean;
  92284. /**
  92285. * Gets the custom effect used to render the particles
  92286. * @param blendMode Blend mode for which the effect should be retrieved
  92287. * @returns The effect
  92288. */
  92289. getCustomEffect(blendMode?: number): Nullable<Effect>;
  92290. /**
  92291. * Sets the custom effect used to render the particles
  92292. * @param effect The effect to set
  92293. * @param blendMode Blend mode for which the effect should be set
  92294. */
  92295. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  92296. /** @hidden */
  92297. private _onBeforeDrawParticlesObservable;
  92298. /**
  92299. * Observable that will be called just before the particles are drawn
  92300. */
  92301. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  92302. /**
  92303. * Gets the name of the particle vertex shader
  92304. */
  92305. get vertexShaderName(): string;
  92306. /**
  92307. * Instantiates a particle system.
  92308. * 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.
  92309. * @param name The name of the particle system
  92310. * @param capacity The max number of particles alive at the same time
  92311. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  92312. * @param customEffect a custom effect used to change the way particles are rendered by default
  92313. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  92314. * @param epsilon Offset used to render the particles
  92315. */
  92316. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  92317. private _addFactorGradient;
  92318. private _removeFactorGradient;
  92319. /**
  92320. * Adds a new life time gradient
  92321. * @param gradient defines the gradient to use (between 0 and 1)
  92322. * @param factor defines the life time factor to affect to the specified gradient
  92323. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92324. * @returns the current particle system
  92325. */
  92326. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92327. /**
  92328. * Remove a specific life time gradient
  92329. * @param gradient defines the gradient to remove
  92330. * @returns the current particle system
  92331. */
  92332. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92333. /**
  92334. * Adds a new size gradient
  92335. * @param gradient defines the gradient to use (between 0 and 1)
  92336. * @param factor defines the size factor to affect to the specified gradient
  92337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92338. * @returns the current particle system
  92339. */
  92340. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92341. /**
  92342. * Remove a specific size gradient
  92343. * @param gradient defines the gradient to remove
  92344. * @returns the current particle system
  92345. */
  92346. removeSizeGradient(gradient: number): IParticleSystem;
  92347. /**
  92348. * Adds a new color remap gradient
  92349. * @param gradient defines the gradient to use (between 0 and 1)
  92350. * @param min defines the color remap minimal range
  92351. * @param max defines the color remap maximal range
  92352. * @returns the current particle system
  92353. */
  92354. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92355. /**
  92356. * Remove a specific color remap gradient
  92357. * @param gradient defines the gradient to remove
  92358. * @returns the current particle system
  92359. */
  92360. removeColorRemapGradient(gradient: number): IParticleSystem;
  92361. /**
  92362. * Adds a new alpha remap gradient
  92363. * @param gradient defines the gradient to use (between 0 and 1)
  92364. * @param min defines the alpha remap minimal range
  92365. * @param max defines the alpha remap maximal range
  92366. * @returns the current particle system
  92367. */
  92368. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92369. /**
  92370. * Remove a specific alpha remap gradient
  92371. * @param gradient defines the gradient to remove
  92372. * @returns the current particle system
  92373. */
  92374. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  92375. /**
  92376. * Adds a new angular speed gradient
  92377. * @param gradient defines the gradient to use (between 0 and 1)
  92378. * @param factor defines the angular speed to affect to the specified gradient
  92379. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92380. * @returns the current particle system
  92381. */
  92382. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92383. /**
  92384. * Remove a specific angular speed gradient
  92385. * @param gradient defines the gradient to remove
  92386. * @returns the current particle system
  92387. */
  92388. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92389. /**
  92390. * Adds a new velocity gradient
  92391. * @param gradient defines the gradient to use (between 0 and 1)
  92392. * @param factor defines the velocity to affect to the specified gradient
  92393. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92394. * @returns the current particle system
  92395. */
  92396. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92397. /**
  92398. * Remove a specific velocity gradient
  92399. * @param gradient defines the gradient to remove
  92400. * @returns the current particle system
  92401. */
  92402. removeVelocityGradient(gradient: number): IParticleSystem;
  92403. /**
  92404. * Adds a new limit velocity gradient
  92405. * @param gradient defines the gradient to use (between 0 and 1)
  92406. * @param factor defines the limit velocity value to affect to the specified gradient
  92407. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92408. * @returns the current particle system
  92409. */
  92410. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92411. /**
  92412. * Remove a specific limit velocity gradient
  92413. * @param gradient defines the gradient to remove
  92414. * @returns the current particle system
  92415. */
  92416. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92417. /**
  92418. * Adds a new drag gradient
  92419. * @param gradient defines the gradient to use (between 0 and 1)
  92420. * @param factor defines the drag value to affect to the specified gradient
  92421. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92422. * @returns the current particle system
  92423. */
  92424. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92425. /**
  92426. * Remove a specific drag gradient
  92427. * @param gradient defines the gradient to remove
  92428. * @returns the current particle system
  92429. */
  92430. removeDragGradient(gradient: number): IParticleSystem;
  92431. /**
  92432. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92433. * @param gradient defines the gradient to use (between 0 and 1)
  92434. * @param factor defines the emit rate value to affect to the specified gradient
  92435. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92436. * @returns the current particle system
  92437. */
  92438. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92439. /**
  92440. * Remove a specific emit rate gradient
  92441. * @param gradient defines the gradient to remove
  92442. * @returns the current particle system
  92443. */
  92444. removeEmitRateGradient(gradient: number): IParticleSystem;
  92445. /**
  92446. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92447. * @param gradient defines the gradient to use (between 0 and 1)
  92448. * @param factor defines the start size value to affect to the specified gradient
  92449. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92450. * @returns the current particle system
  92451. */
  92452. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92453. /**
  92454. * Remove a specific start size gradient
  92455. * @param gradient defines the gradient to remove
  92456. * @returns the current particle system
  92457. */
  92458. removeStartSizeGradient(gradient: number): IParticleSystem;
  92459. private _createRampGradientTexture;
  92460. /**
  92461. * Gets the current list of ramp gradients.
  92462. * You must use addRampGradient and removeRampGradient to udpate this list
  92463. * @returns the list of ramp gradients
  92464. */
  92465. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92466. /** Force the system to rebuild all gradients that need to be resync */
  92467. forceRefreshGradients(): void;
  92468. private _syncRampGradientTexture;
  92469. /**
  92470. * Adds a new ramp gradient used to remap particle colors
  92471. * @param gradient defines the gradient to use (between 0 and 1)
  92472. * @param color defines the color to affect to the specified gradient
  92473. * @returns the current particle system
  92474. */
  92475. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  92476. /**
  92477. * Remove a specific ramp gradient
  92478. * @param gradient defines the gradient to remove
  92479. * @returns the current particle system
  92480. */
  92481. removeRampGradient(gradient: number): ParticleSystem;
  92482. /**
  92483. * Adds a new color gradient
  92484. * @param gradient defines the gradient to use (between 0 and 1)
  92485. * @param color1 defines the color to affect to the specified gradient
  92486. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92487. * @returns this particle system
  92488. */
  92489. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92490. /**
  92491. * Remove a specific color gradient
  92492. * @param gradient defines the gradient to remove
  92493. * @returns this particle system
  92494. */
  92495. removeColorGradient(gradient: number): IParticleSystem;
  92496. private _fetchR;
  92497. protected _reset(): void;
  92498. private _resetEffect;
  92499. private _createVertexBuffers;
  92500. private _createIndexBuffer;
  92501. /**
  92502. * Gets the maximum number of particles active at the same time.
  92503. * @returns The max number of active particles.
  92504. */
  92505. getCapacity(): number;
  92506. /**
  92507. * Gets whether there are still active particles in the system.
  92508. * @returns True if it is alive, otherwise false.
  92509. */
  92510. isAlive(): boolean;
  92511. /**
  92512. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92513. * @returns True if it has been started, otherwise false.
  92514. */
  92515. isStarted(): boolean;
  92516. private _prepareSubEmitterInternalArray;
  92517. /**
  92518. * Starts the particle system and begins to emit
  92519. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  92520. */
  92521. start(delay?: number): void;
  92522. /**
  92523. * Stops the particle system.
  92524. * @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.
  92525. */
  92526. stop(stopSubEmitters?: boolean): void;
  92527. /**
  92528. * Remove all active particles
  92529. */
  92530. reset(): void;
  92531. /**
  92532. * @hidden (for internal use only)
  92533. */
  92534. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  92535. /**
  92536. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  92537. * Its lifetime will start back at 0.
  92538. */
  92539. recycleParticle: (particle: Particle) => void;
  92540. private _stopSubEmitters;
  92541. private _createParticle;
  92542. private _removeFromRoot;
  92543. private _emitFromParticle;
  92544. private _update;
  92545. /** @hidden */
  92546. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  92547. /** @hidden */
  92548. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  92549. /**
  92550. * Fill the defines array according to the current settings of the particle system
  92551. * @param defines Array to be updated
  92552. * @param blendMode blend mode to take into account when updating the array
  92553. */
  92554. fillDefines(defines: Array<string>, blendMode: number): void;
  92555. /**
  92556. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  92557. * @param uniforms Uniforms array to fill
  92558. * @param attributes Attributes array to fill
  92559. * @param samplers Samplers array to fill
  92560. */
  92561. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  92562. /** @hidden */
  92563. private _getEffect;
  92564. /**
  92565. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  92566. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  92567. */
  92568. animate(preWarmOnly?: boolean): void;
  92569. private _appendParticleVertices;
  92570. /**
  92571. * Rebuilds the particle system.
  92572. */
  92573. rebuild(): void;
  92574. /**
  92575. * Is this system ready to be used/rendered
  92576. * @return true if the system is ready
  92577. */
  92578. isReady(): boolean;
  92579. private _render;
  92580. /**
  92581. * Renders the particle system in its current state.
  92582. * @returns the current number of particles
  92583. */
  92584. render(): number;
  92585. /**
  92586. * Disposes the particle system and free the associated resources
  92587. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92588. */
  92589. dispose(disposeTexture?: boolean): void;
  92590. /**
  92591. * Clones the particle system.
  92592. * @param name The name of the cloned object
  92593. * @param newEmitter The new emitter to use
  92594. * @returns the cloned particle system
  92595. */
  92596. clone(name: string, newEmitter: any): ParticleSystem;
  92597. /**
  92598. * Serializes the particle system to a JSON object
  92599. * @param serializeTexture defines if the texture must be serialized as well
  92600. * @returns the JSON object
  92601. */
  92602. serialize(serializeTexture?: boolean): any;
  92603. /** @hidden */
  92604. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  92605. /** @hidden */
  92606. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  92607. /**
  92608. * Parses a JSON object to create a particle system.
  92609. * @param parsedParticleSystem The JSON object to parse
  92610. * @param sceneOrEngine The scene or the engine to create the particle system in
  92611. * @param rootUrl The root url to use to load external dependencies like texture
  92612. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  92613. * @returns the Parsed particle system
  92614. */
  92615. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  92616. }
  92617. }
  92618. declare module BABYLON {
  92619. /**
  92620. * A particle represents one of the element emitted by a particle system.
  92621. * This is mainly define by its coordinates, direction, velocity and age.
  92622. */
  92623. export class Particle {
  92624. /**
  92625. * The particle system the particle belongs to.
  92626. */
  92627. particleSystem: ParticleSystem;
  92628. private static _Count;
  92629. /**
  92630. * Unique ID of the particle
  92631. */
  92632. id: number;
  92633. /**
  92634. * The world position of the particle in the scene.
  92635. */
  92636. position: Vector3;
  92637. /**
  92638. * The world direction of the particle in the scene.
  92639. */
  92640. direction: Vector3;
  92641. /**
  92642. * The color of the particle.
  92643. */
  92644. color: Color4;
  92645. /**
  92646. * The color change of the particle per step.
  92647. */
  92648. colorStep: Color4;
  92649. /**
  92650. * Defines how long will the life of the particle be.
  92651. */
  92652. lifeTime: number;
  92653. /**
  92654. * The current age of the particle.
  92655. */
  92656. age: number;
  92657. /**
  92658. * The current size of the particle.
  92659. */
  92660. size: number;
  92661. /**
  92662. * The current scale of the particle.
  92663. */
  92664. scale: Vector2;
  92665. /**
  92666. * The current angle of the particle.
  92667. */
  92668. angle: number;
  92669. /**
  92670. * Defines how fast is the angle changing.
  92671. */
  92672. angularSpeed: number;
  92673. /**
  92674. * Defines the cell index used by the particle to be rendered from a sprite.
  92675. */
  92676. cellIndex: number;
  92677. /**
  92678. * The information required to support color remapping
  92679. */
  92680. remapData: Vector4;
  92681. /** @hidden */
  92682. _randomCellOffset?: number;
  92683. /** @hidden */
  92684. _initialDirection: Nullable<Vector3>;
  92685. /** @hidden */
  92686. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  92687. /** @hidden */
  92688. _initialStartSpriteCellID: number;
  92689. /** @hidden */
  92690. _initialEndSpriteCellID: number;
  92691. /** @hidden */
  92692. _currentColorGradient: Nullable<ColorGradient>;
  92693. /** @hidden */
  92694. _currentColor1: Color4;
  92695. /** @hidden */
  92696. _currentColor2: Color4;
  92697. /** @hidden */
  92698. _currentSizeGradient: Nullable<FactorGradient>;
  92699. /** @hidden */
  92700. _currentSize1: number;
  92701. /** @hidden */
  92702. _currentSize2: number;
  92703. /** @hidden */
  92704. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  92705. /** @hidden */
  92706. _currentAngularSpeed1: number;
  92707. /** @hidden */
  92708. _currentAngularSpeed2: number;
  92709. /** @hidden */
  92710. _currentVelocityGradient: Nullable<FactorGradient>;
  92711. /** @hidden */
  92712. _currentVelocity1: number;
  92713. /** @hidden */
  92714. _currentVelocity2: number;
  92715. /** @hidden */
  92716. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  92717. /** @hidden */
  92718. _currentLimitVelocity1: number;
  92719. /** @hidden */
  92720. _currentLimitVelocity2: number;
  92721. /** @hidden */
  92722. _currentDragGradient: Nullable<FactorGradient>;
  92723. /** @hidden */
  92724. _currentDrag1: number;
  92725. /** @hidden */
  92726. _currentDrag2: number;
  92727. /** @hidden */
  92728. _randomNoiseCoordinates1: Vector3;
  92729. /** @hidden */
  92730. _randomNoiseCoordinates2: Vector3;
  92731. /** @hidden */
  92732. _localPosition?: Vector3;
  92733. /**
  92734. * Creates a new instance Particle
  92735. * @param particleSystem the particle system the particle belongs to
  92736. */
  92737. constructor(
  92738. /**
  92739. * The particle system the particle belongs to.
  92740. */
  92741. particleSystem: ParticleSystem);
  92742. private updateCellInfoFromSystem;
  92743. /**
  92744. * Defines how the sprite cell index is updated for the particle
  92745. */
  92746. updateCellIndex(): void;
  92747. /** @hidden */
  92748. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  92749. /** @hidden */
  92750. _inheritParticleInfoToSubEmitters(): void;
  92751. /** @hidden */
  92752. _reset(): void;
  92753. /**
  92754. * Copy the properties of particle to another one.
  92755. * @param other the particle to copy the information to.
  92756. */
  92757. copyTo(other: Particle): void;
  92758. }
  92759. }
  92760. declare module BABYLON {
  92761. /**
  92762. * Particle emitter represents a volume emitting particles.
  92763. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  92764. */
  92765. export interface IParticleEmitterType {
  92766. /**
  92767. * Called by the particle System when the direction is computed for the created particle.
  92768. * @param worldMatrix is the world matrix of the particle system
  92769. * @param directionToUpdate is the direction vector to update with the result
  92770. * @param particle is the particle we are computed the direction for
  92771. * @param isLocal defines if the direction should be set in local space
  92772. */
  92773. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92774. /**
  92775. * Called by the particle System when the position is computed for the created particle.
  92776. * @param worldMatrix is the world matrix of the particle system
  92777. * @param positionToUpdate is the position vector to update with the result
  92778. * @param particle is the particle we are computed the position for
  92779. * @param isLocal defines if the position should be set in local space
  92780. */
  92781. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92782. /**
  92783. * Clones the current emitter and returns a copy of it
  92784. * @returns the new emitter
  92785. */
  92786. clone(): IParticleEmitterType;
  92787. /**
  92788. * Called by the GPUParticleSystem to setup the update shader
  92789. * @param effect defines the update shader
  92790. */
  92791. applyToShader(effect: Effect): void;
  92792. /**
  92793. * Returns a string to use to update the GPU particles update shader
  92794. * @returns the effect defines string
  92795. */
  92796. getEffectDefines(): string;
  92797. /**
  92798. * Returns a string representing the class name
  92799. * @returns a string containing the class name
  92800. */
  92801. getClassName(): string;
  92802. /**
  92803. * Serializes the particle system to a JSON object.
  92804. * @returns the JSON object
  92805. */
  92806. serialize(): any;
  92807. /**
  92808. * Parse properties from a JSON object
  92809. * @param serializationObject defines the JSON object
  92810. * @param scene defines the hosting scene
  92811. */
  92812. parse(serializationObject: any, scene: Nullable<Scene>): void;
  92813. }
  92814. }
  92815. declare module BABYLON {
  92816. /**
  92817. * Particle emitter emitting particles from the inside of a box.
  92818. * It emits the particles randomly between 2 given directions.
  92819. */
  92820. export class BoxParticleEmitter implements IParticleEmitterType {
  92821. /**
  92822. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92823. */
  92824. direction1: Vector3;
  92825. /**
  92826. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92827. */
  92828. direction2: Vector3;
  92829. /**
  92830. * 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.
  92831. */
  92832. minEmitBox: Vector3;
  92833. /**
  92834. * 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.
  92835. */
  92836. maxEmitBox: Vector3;
  92837. /**
  92838. * Creates a new instance BoxParticleEmitter
  92839. */
  92840. constructor();
  92841. /**
  92842. * Called by the particle System when the direction is computed for the created particle.
  92843. * @param worldMatrix is the world matrix of the particle system
  92844. * @param directionToUpdate is the direction vector to update with the result
  92845. * @param particle is the particle we are computed the direction for
  92846. * @param isLocal defines if the direction should be set in local space
  92847. */
  92848. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92849. /**
  92850. * Called by the particle System when the position is computed for the created particle.
  92851. * @param worldMatrix is the world matrix of the particle system
  92852. * @param positionToUpdate is the position vector to update with the result
  92853. * @param particle is the particle we are computed the position for
  92854. * @param isLocal defines if the position should be set in local space
  92855. */
  92856. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92857. /**
  92858. * Clones the current emitter and returns a copy of it
  92859. * @returns the new emitter
  92860. */
  92861. clone(): BoxParticleEmitter;
  92862. /**
  92863. * Called by the GPUParticleSystem to setup the update shader
  92864. * @param effect defines the update shader
  92865. */
  92866. applyToShader(effect: Effect): void;
  92867. /**
  92868. * Returns a string to use to update the GPU particles update shader
  92869. * @returns a string containng the defines string
  92870. */
  92871. getEffectDefines(): string;
  92872. /**
  92873. * Returns the string "BoxParticleEmitter"
  92874. * @returns a string containing the class name
  92875. */
  92876. getClassName(): string;
  92877. /**
  92878. * Serializes the particle system to a JSON object.
  92879. * @returns the JSON object
  92880. */
  92881. serialize(): any;
  92882. /**
  92883. * Parse properties from a JSON object
  92884. * @param serializationObject defines the JSON object
  92885. */
  92886. parse(serializationObject: any): void;
  92887. }
  92888. }
  92889. declare module BABYLON {
  92890. /**
  92891. * Particle emitter emitting particles from the inside of a cone.
  92892. * It emits the particles alongside the cone volume from the base to the particle.
  92893. * The emission direction might be randomized.
  92894. */
  92895. export class ConeParticleEmitter implements IParticleEmitterType {
  92896. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92897. directionRandomizer: number;
  92898. private _radius;
  92899. private _angle;
  92900. private _height;
  92901. /**
  92902. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  92903. */
  92904. radiusRange: number;
  92905. /**
  92906. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  92907. */
  92908. heightRange: number;
  92909. /**
  92910. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  92911. */
  92912. emitFromSpawnPointOnly: boolean;
  92913. /**
  92914. * Gets or sets the radius of the emission cone
  92915. */
  92916. get radius(): number;
  92917. set radius(value: number);
  92918. /**
  92919. * Gets or sets the angle of the emission cone
  92920. */
  92921. get angle(): number;
  92922. set angle(value: number);
  92923. private _buildHeight;
  92924. /**
  92925. * Creates a new instance ConeParticleEmitter
  92926. * @param radius the radius of the emission cone (1 by default)
  92927. * @param angle the cone base angle (PI by default)
  92928. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  92929. */
  92930. constructor(radius?: number, angle?: number,
  92931. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92932. directionRandomizer?: number);
  92933. /**
  92934. * Called by the particle System when the direction is computed for the created particle.
  92935. * @param worldMatrix is the world matrix of the particle system
  92936. * @param directionToUpdate is the direction vector to update with the result
  92937. * @param particle is the particle we are computed the direction for
  92938. * @param isLocal defines if the direction should be set in local space
  92939. */
  92940. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92941. /**
  92942. * Called by the particle System when the position is computed for the created particle.
  92943. * @param worldMatrix is the world matrix of the particle system
  92944. * @param positionToUpdate is the position vector to update with the result
  92945. * @param particle is the particle we are computed the position for
  92946. * @param isLocal defines if the position should be set in local space
  92947. */
  92948. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92949. /**
  92950. * Clones the current emitter and returns a copy of it
  92951. * @returns the new emitter
  92952. */
  92953. clone(): ConeParticleEmitter;
  92954. /**
  92955. * Called by the GPUParticleSystem to setup the update shader
  92956. * @param effect defines the update shader
  92957. */
  92958. applyToShader(effect: Effect): void;
  92959. /**
  92960. * Returns a string to use to update the GPU particles update shader
  92961. * @returns a string containng the defines string
  92962. */
  92963. getEffectDefines(): string;
  92964. /**
  92965. * Returns the string "ConeParticleEmitter"
  92966. * @returns a string containing the class name
  92967. */
  92968. getClassName(): string;
  92969. /**
  92970. * Serializes the particle system to a JSON object.
  92971. * @returns the JSON object
  92972. */
  92973. serialize(): any;
  92974. /**
  92975. * Parse properties from a JSON object
  92976. * @param serializationObject defines the JSON object
  92977. */
  92978. parse(serializationObject: any): void;
  92979. }
  92980. }
  92981. declare module BABYLON {
  92982. /**
  92983. * Particle emitter emitting particles from the inside of a cylinder.
  92984. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  92985. */
  92986. export class CylinderParticleEmitter implements IParticleEmitterType {
  92987. /**
  92988. * The radius of the emission cylinder.
  92989. */
  92990. radius: number;
  92991. /**
  92992. * The height of the emission cylinder.
  92993. */
  92994. height: number;
  92995. /**
  92996. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92997. */
  92998. radiusRange: number;
  92999. /**
  93000. * How much to randomize the particle direction [0-1].
  93001. */
  93002. directionRandomizer: number;
  93003. /**
  93004. * Creates a new instance CylinderParticleEmitter
  93005. * @param radius the radius of the emission cylinder (1 by default)
  93006. * @param height the height of the emission cylinder (1 by default)
  93007. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93008. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93009. */
  93010. constructor(
  93011. /**
  93012. * The radius of the emission cylinder.
  93013. */
  93014. radius?: number,
  93015. /**
  93016. * The height of the emission cylinder.
  93017. */
  93018. height?: number,
  93019. /**
  93020. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93021. */
  93022. radiusRange?: number,
  93023. /**
  93024. * How much to randomize the particle direction [0-1].
  93025. */
  93026. directionRandomizer?: number);
  93027. /**
  93028. * Called by the particle System when the direction is computed for the created particle.
  93029. * @param worldMatrix is the world matrix of the particle system
  93030. * @param directionToUpdate is the direction vector to update with the result
  93031. * @param particle is the particle we are computed the direction for
  93032. * @param isLocal defines if the direction should be set in local space
  93033. */
  93034. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93035. /**
  93036. * Called by the particle System when the position is computed for the created particle.
  93037. * @param worldMatrix is the world matrix of the particle system
  93038. * @param positionToUpdate is the position vector to update with the result
  93039. * @param particle is the particle we are computed the position for
  93040. * @param isLocal defines if the position should be set in local space
  93041. */
  93042. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93043. /**
  93044. * Clones the current emitter and returns a copy of it
  93045. * @returns the new emitter
  93046. */
  93047. clone(): CylinderParticleEmitter;
  93048. /**
  93049. * Called by the GPUParticleSystem to setup the update shader
  93050. * @param effect defines the update shader
  93051. */
  93052. applyToShader(effect: Effect): void;
  93053. /**
  93054. * Returns a string to use to update the GPU particles update shader
  93055. * @returns a string containng the defines string
  93056. */
  93057. getEffectDefines(): string;
  93058. /**
  93059. * Returns the string "CylinderParticleEmitter"
  93060. * @returns a string containing the class name
  93061. */
  93062. getClassName(): string;
  93063. /**
  93064. * Serializes the particle system to a JSON object.
  93065. * @returns the JSON object
  93066. */
  93067. serialize(): any;
  93068. /**
  93069. * Parse properties from a JSON object
  93070. * @param serializationObject defines the JSON object
  93071. */
  93072. parse(serializationObject: any): void;
  93073. }
  93074. /**
  93075. * Particle emitter emitting particles from the inside of a cylinder.
  93076. * It emits the particles randomly between two vectors.
  93077. */
  93078. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  93079. /**
  93080. * The min limit of the emission direction.
  93081. */
  93082. direction1: Vector3;
  93083. /**
  93084. * The max limit of the emission direction.
  93085. */
  93086. direction2: Vector3;
  93087. /**
  93088. * Creates a new instance CylinderDirectedParticleEmitter
  93089. * @param radius the radius of the emission cylinder (1 by default)
  93090. * @param height the height of the emission cylinder (1 by default)
  93091. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93092. * @param direction1 the min limit of the emission direction (up vector by default)
  93093. * @param direction2 the max limit of the emission direction (up vector by default)
  93094. */
  93095. constructor(radius?: number, height?: number, radiusRange?: number,
  93096. /**
  93097. * The min limit of the emission direction.
  93098. */
  93099. direction1?: Vector3,
  93100. /**
  93101. * The max limit of the emission direction.
  93102. */
  93103. direction2?: Vector3);
  93104. /**
  93105. * Called by the particle System when the direction is computed for the created particle.
  93106. * @param worldMatrix is the world matrix of the particle system
  93107. * @param directionToUpdate is the direction vector to update with the result
  93108. * @param particle is the particle we are computed the direction for
  93109. */
  93110. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93111. /**
  93112. * Clones the current emitter and returns a copy of it
  93113. * @returns the new emitter
  93114. */
  93115. clone(): CylinderDirectedParticleEmitter;
  93116. /**
  93117. * Called by the GPUParticleSystem to setup the update shader
  93118. * @param effect defines the update shader
  93119. */
  93120. applyToShader(effect: Effect): void;
  93121. /**
  93122. * Returns a string to use to update the GPU particles update shader
  93123. * @returns a string containng the defines string
  93124. */
  93125. getEffectDefines(): string;
  93126. /**
  93127. * Returns the string "CylinderDirectedParticleEmitter"
  93128. * @returns a string containing the class name
  93129. */
  93130. getClassName(): string;
  93131. /**
  93132. * Serializes the particle system to a JSON object.
  93133. * @returns the JSON object
  93134. */
  93135. serialize(): any;
  93136. /**
  93137. * Parse properties from a JSON object
  93138. * @param serializationObject defines the JSON object
  93139. */
  93140. parse(serializationObject: any): void;
  93141. }
  93142. }
  93143. declare module BABYLON {
  93144. /**
  93145. * Particle emitter emitting particles from the inside of a hemisphere.
  93146. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  93147. */
  93148. export class HemisphericParticleEmitter implements IParticleEmitterType {
  93149. /**
  93150. * The radius of the emission hemisphere.
  93151. */
  93152. radius: number;
  93153. /**
  93154. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93155. */
  93156. radiusRange: number;
  93157. /**
  93158. * How much to randomize the particle direction [0-1].
  93159. */
  93160. directionRandomizer: number;
  93161. /**
  93162. * Creates a new instance HemisphericParticleEmitter
  93163. * @param radius the radius of the emission hemisphere (1 by default)
  93164. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93165. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93166. */
  93167. constructor(
  93168. /**
  93169. * The radius of the emission hemisphere.
  93170. */
  93171. radius?: number,
  93172. /**
  93173. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93174. */
  93175. radiusRange?: number,
  93176. /**
  93177. * How much to randomize the particle direction [0-1].
  93178. */
  93179. directionRandomizer?: number);
  93180. /**
  93181. * Called by the particle System when the direction is computed for the created particle.
  93182. * @param worldMatrix is the world matrix of the particle system
  93183. * @param directionToUpdate is the direction vector to update with the result
  93184. * @param particle is the particle we are computed the direction for
  93185. * @param isLocal defines if the direction should be set in local space
  93186. */
  93187. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93188. /**
  93189. * Called by the particle System when the position is computed for the created particle.
  93190. * @param worldMatrix is the world matrix of the particle system
  93191. * @param positionToUpdate is the position vector to update with the result
  93192. * @param particle is the particle we are computed the position for
  93193. * @param isLocal defines if the position should be set in local space
  93194. */
  93195. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93196. /**
  93197. * Clones the current emitter and returns a copy of it
  93198. * @returns the new emitter
  93199. */
  93200. clone(): HemisphericParticleEmitter;
  93201. /**
  93202. * Called by the GPUParticleSystem to setup the update shader
  93203. * @param effect defines the update shader
  93204. */
  93205. applyToShader(effect: Effect): void;
  93206. /**
  93207. * Returns a string to use to update the GPU particles update shader
  93208. * @returns a string containng the defines string
  93209. */
  93210. getEffectDefines(): string;
  93211. /**
  93212. * Returns the string "HemisphericParticleEmitter"
  93213. * @returns a string containing the class name
  93214. */
  93215. getClassName(): string;
  93216. /**
  93217. * Serializes the particle system to a JSON object.
  93218. * @returns the JSON object
  93219. */
  93220. serialize(): any;
  93221. /**
  93222. * Parse properties from a JSON object
  93223. * @param serializationObject defines the JSON object
  93224. */
  93225. parse(serializationObject: any): void;
  93226. }
  93227. }
  93228. declare module BABYLON {
  93229. /**
  93230. * Particle emitter emitting particles from a point.
  93231. * It emits the particles randomly between 2 given directions.
  93232. */
  93233. export class PointParticleEmitter implements IParticleEmitterType {
  93234. /**
  93235. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93236. */
  93237. direction1: Vector3;
  93238. /**
  93239. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93240. */
  93241. direction2: Vector3;
  93242. /**
  93243. * Creates a new instance PointParticleEmitter
  93244. */
  93245. constructor();
  93246. /**
  93247. * Called by the particle System when the direction is computed for the created particle.
  93248. * @param worldMatrix is the world matrix of the particle system
  93249. * @param directionToUpdate is the direction vector to update with the result
  93250. * @param particle is the particle we are computed the direction for
  93251. * @param isLocal defines if the direction should be set in local space
  93252. */
  93253. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93254. /**
  93255. * Called by the particle System when the position is computed for the created particle.
  93256. * @param worldMatrix is the world matrix of the particle system
  93257. * @param positionToUpdate is the position vector to update with the result
  93258. * @param particle is the particle we are computed the position for
  93259. * @param isLocal defines if the position should be set in local space
  93260. */
  93261. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93262. /**
  93263. * Clones the current emitter and returns a copy of it
  93264. * @returns the new emitter
  93265. */
  93266. clone(): PointParticleEmitter;
  93267. /**
  93268. * Called by the GPUParticleSystem to setup the update shader
  93269. * @param effect defines the update shader
  93270. */
  93271. applyToShader(effect: Effect): void;
  93272. /**
  93273. * Returns a string to use to update the GPU particles update shader
  93274. * @returns a string containng the defines string
  93275. */
  93276. getEffectDefines(): string;
  93277. /**
  93278. * Returns the string "PointParticleEmitter"
  93279. * @returns a string containing the class name
  93280. */
  93281. getClassName(): string;
  93282. /**
  93283. * Serializes the particle system to a JSON object.
  93284. * @returns the JSON object
  93285. */
  93286. serialize(): any;
  93287. /**
  93288. * Parse properties from a JSON object
  93289. * @param serializationObject defines the JSON object
  93290. */
  93291. parse(serializationObject: any): void;
  93292. }
  93293. }
  93294. declare module BABYLON {
  93295. /**
  93296. * Particle emitter emitting particles from the inside of a sphere.
  93297. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  93298. */
  93299. export class SphereParticleEmitter implements IParticleEmitterType {
  93300. /**
  93301. * The radius of the emission sphere.
  93302. */
  93303. radius: number;
  93304. /**
  93305. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93306. */
  93307. radiusRange: number;
  93308. /**
  93309. * How much to randomize the particle direction [0-1].
  93310. */
  93311. directionRandomizer: number;
  93312. /**
  93313. * Creates a new instance SphereParticleEmitter
  93314. * @param radius the radius of the emission sphere (1 by default)
  93315. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93316. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93317. */
  93318. constructor(
  93319. /**
  93320. * The radius of the emission sphere.
  93321. */
  93322. radius?: number,
  93323. /**
  93324. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93325. */
  93326. radiusRange?: number,
  93327. /**
  93328. * How much to randomize the particle direction [0-1].
  93329. */
  93330. directionRandomizer?: number);
  93331. /**
  93332. * Called by the particle System when the direction is computed for the created particle.
  93333. * @param worldMatrix is the world matrix of the particle system
  93334. * @param directionToUpdate is the direction vector to update with the result
  93335. * @param particle is the particle we are computed the direction for
  93336. * @param isLocal defines if the direction should be set in local space
  93337. */
  93338. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93339. /**
  93340. * Called by the particle System when the position is computed for the created particle.
  93341. * @param worldMatrix is the world matrix of the particle system
  93342. * @param positionToUpdate is the position vector to update with the result
  93343. * @param particle is the particle we are computed the position for
  93344. * @param isLocal defines if the position should be set in local space
  93345. */
  93346. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93347. /**
  93348. * Clones the current emitter and returns a copy of it
  93349. * @returns the new emitter
  93350. */
  93351. clone(): SphereParticleEmitter;
  93352. /**
  93353. * Called by the GPUParticleSystem to setup the update shader
  93354. * @param effect defines the update shader
  93355. */
  93356. applyToShader(effect: Effect): void;
  93357. /**
  93358. * Returns a string to use to update the GPU particles update shader
  93359. * @returns a string containng the defines string
  93360. */
  93361. getEffectDefines(): string;
  93362. /**
  93363. * Returns the string "SphereParticleEmitter"
  93364. * @returns a string containing the class name
  93365. */
  93366. getClassName(): string;
  93367. /**
  93368. * Serializes the particle system to a JSON object.
  93369. * @returns the JSON object
  93370. */
  93371. serialize(): any;
  93372. /**
  93373. * Parse properties from a JSON object
  93374. * @param serializationObject defines the JSON object
  93375. */
  93376. parse(serializationObject: any): void;
  93377. }
  93378. /**
  93379. * Particle emitter emitting particles from the inside of a sphere.
  93380. * It emits the particles randomly between two vectors.
  93381. */
  93382. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  93383. /**
  93384. * The min limit of the emission direction.
  93385. */
  93386. direction1: Vector3;
  93387. /**
  93388. * The max limit of the emission direction.
  93389. */
  93390. direction2: Vector3;
  93391. /**
  93392. * Creates a new instance SphereDirectedParticleEmitter
  93393. * @param radius the radius of the emission sphere (1 by default)
  93394. * @param direction1 the min limit of the emission direction (up vector by default)
  93395. * @param direction2 the max limit of the emission direction (up vector by default)
  93396. */
  93397. constructor(radius?: number,
  93398. /**
  93399. * The min limit of the emission direction.
  93400. */
  93401. direction1?: Vector3,
  93402. /**
  93403. * The max limit of the emission direction.
  93404. */
  93405. direction2?: Vector3);
  93406. /**
  93407. * Called by the particle System when the direction is computed for the created particle.
  93408. * @param worldMatrix is the world matrix of the particle system
  93409. * @param directionToUpdate is the direction vector to update with the result
  93410. * @param particle is the particle we are computed the direction for
  93411. */
  93412. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93413. /**
  93414. * Clones the current emitter and returns a copy of it
  93415. * @returns the new emitter
  93416. */
  93417. clone(): SphereDirectedParticleEmitter;
  93418. /**
  93419. * Called by the GPUParticleSystem to setup the update shader
  93420. * @param effect defines the update shader
  93421. */
  93422. applyToShader(effect: Effect): void;
  93423. /**
  93424. * Returns a string to use to update the GPU particles update shader
  93425. * @returns a string containng the defines string
  93426. */
  93427. getEffectDefines(): string;
  93428. /**
  93429. * Returns the string "SphereDirectedParticleEmitter"
  93430. * @returns a string containing the class name
  93431. */
  93432. getClassName(): string;
  93433. /**
  93434. * Serializes the particle system to a JSON object.
  93435. * @returns the JSON object
  93436. */
  93437. serialize(): any;
  93438. /**
  93439. * Parse properties from a JSON object
  93440. * @param serializationObject defines the JSON object
  93441. */
  93442. parse(serializationObject: any): void;
  93443. }
  93444. }
  93445. declare module BABYLON {
  93446. /**
  93447. * Particle emitter emitting particles from a custom list of positions.
  93448. */
  93449. export class CustomParticleEmitter implements IParticleEmitterType {
  93450. /**
  93451. * Gets or sets the position generator that will create the inital position of each particle.
  93452. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  93453. */
  93454. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  93455. /**
  93456. * Gets or sets the destination generator that will create the final destination of each particle.
  93457. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  93458. */
  93459. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  93460. /**
  93461. * Creates a new instance CustomParticleEmitter
  93462. */
  93463. constructor();
  93464. /**
  93465. * Called by the particle System when the direction is computed for the created particle.
  93466. * @param worldMatrix is the world matrix of the particle system
  93467. * @param directionToUpdate is the direction vector to update with the result
  93468. * @param particle is the particle we are computed the direction for
  93469. * @param isLocal defines if the direction should be set in local space
  93470. */
  93471. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93472. /**
  93473. * Called by the particle System when the position is computed for the created particle.
  93474. * @param worldMatrix is the world matrix of the particle system
  93475. * @param positionToUpdate is the position vector to update with the result
  93476. * @param particle is the particle we are computed the position for
  93477. * @param isLocal defines if the position should be set in local space
  93478. */
  93479. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93480. /**
  93481. * Clones the current emitter and returns a copy of it
  93482. * @returns the new emitter
  93483. */
  93484. clone(): CustomParticleEmitter;
  93485. /**
  93486. * Called by the GPUParticleSystem to setup the update shader
  93487. * @param effect defines the update shader
  93488. */
  93489. applyToShader(effect: Effect): void;
  93490. /**
  93491. * Returns a string to use to update the GPU particles update shader
  93492. * @returns a string containng the defines string
  93493. */
  93494. getEffectDefines(): string;
  93495. /**
  93496. * Returns the string "PointParticleEmitter"
  93497. * @returns a string containing the class name
  93498. */
  93499. getClassName(): string;
  93500. /**
  93501. * Serializes the particle system to a JSON object.
  93502. * @returns the JSON object
  93503. */
  93504. serialize(): any;
  93505. /**
  93506. * Parse properties from a JSON object
  93507. * @param serializationObject defines the JSON object
  93508. */
  93509. parse(serializationObject: any): void;
  93510. }
  93511. }
  93512. declare module BABYLON {
  93513. /**
  93514. * Particle emitter emitting particles from the inside of a box.
  93515. * It emits the particles randomly between 2 given directions.
  93516. */
  93517. export class MeshParticleEmitter implements IParticleEmitterType {
  93518. private _indices;
  93519. private _positions;
  93520. private _normals;
  93521. private _storedNormal;
  93522. private _mesh;
  93523. /**
  93524. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93525. */
  93526. direction1: Vector3;
  93527. /**
  93528. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93529. */
  93530. direction2: Vector3;
  93531. /**
  93532. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  93533. */
  93534. useMeshNormalsForDirection: boolean;
  93535. /** Defines the mesh to use as source */
  93536. get mesh(): Nullable<AbstractMesh>;
  93537. set mesh(value: Nullable<AbstractMesh>);
  93538. /**
  93539. * Creates a new instance MeshParticleEmitter
  93540. * @param mesh defines the mesh to use as source
  93541. */
  93542. constructor(mesh?: Nullable<AbstractMesh>);
  93543. /**
  93544. * Called by the particle System when the direction is computed for the created particle.
  93545. * @param worldMatrix is the world matrix of the particle system
  93546. * @param directionToUpdate is the direction vector to update with the result
  93547. * @param particle is the particle we are computed the direction for
  93548. * @param isLocal defines if the direction should be set in local space
  93549. */
  93550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93551. /**
  93552. * Called by the particle System when the position is computed for the created particle.
  93553. * @param worldMatrix is the world matrix of the particle system
  93554. * @param positionToUpdate is the position vector to update with the result
  93555. * @param particle is the particle we are computed the position for
  93556. * @param isLocal defines if the position should be set in local space
  93557. */
  93558. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93559. /**
  93560. * Clones the current emitter and returns a copy of it
  93561. * @returns the new emitter
  93562. */
  93563. clone(): MeshParticleEmitter;
  93564. /**
  93565. * Called by the GPUParticleSystem to setup the update shader
  93566. * @param effect defines the update shader
  93567. */
  93568. applyToShader(effect: Effect): void;
  93569. /**
  93570. * Returns a string to use to update the GPU particles update shader
  93571. * @returns a string containng the defines string
  93572. */
  93573. getEffectDefines(): string;
  93574. /**
  93575. * Returns the string "BoxParticleEmitter"
  93576. * @returns a string containing the class name
  93577. */
  93578. getClassName(): string;
  93579. /**
  93580. * Serializes the particle system to a JSON object.
  93581. * @returns the JSON object
  93582. */
  93583. serialize(): any;
  93584. /**
  93585. * Parse properties from a JSON object
  93586. * @param serializationObject defines the JSON object
  93587. * @param scene defines the hosting scene
  93588. */
  93589. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93590. }
  93591. }
  93592. declare module BABYLON {
  93593. /**
  93594. * Interface representing a particle system in Babylon.js.
  93595. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  93596. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  93597. */
  93598. export interface IParticleSystem {
  93599. /**
  93600. * List of animations used by the particle system.
  93601. */
  93602. animations: Animation[];
  93603. /**
  93604. * The id of the Particle system.
  93605. */
  93606. id: string;
  93607. /**
  93608. * The name of the Particle system.
  93609. */
  93610. name: string;
  93611. /**
  93612. * The emitter represents the Mesh or position we are attaching the particle system to.
  93613. */
  93614. emitter: Nullable<AbstractMesh | Vector3>;
  93615. /**
  93616. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93617. */
  93618. isBillboardBased: boolean;
  93619. /**
  93620. * The rendering group used by the Particle system to chose when to render.
  93621. */
  93622. renderingGroupId: number;
  93623. /**
  93624. * The layer mask we are rendering the particles through.
  93625. */
  93626. layerMask: number;
  93627. /**
  93628. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  93629. */
  93630. updateSpeed: number;
  93631. /**
  93632. * The amount of time the particle system is running (depends of the overall update speed).
  93633. */
  93634. targetStopDuration: number;
  93635. /**
  93636. * The texture used to render each particle. (this can be a spritesheet)
  93637. */
  93638. particleTexture: Nullable<BaseTexture>;
  93639. /**
  93640. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  93641. */
  93642. blendMode: number;
  93643. /**
  93644. * Minimum life time of emitting particles.
  93645. */
  93646. minLifeTime: number;
  93647. /**
  93648. * Maximum life time of emitting particles.
  93649. */
  93650. maxLifeTime: number;
  93651. /**
  93652. * Minimum Size of emitting particles.
  93653. */
  93654. minSize: number;
  93655. /**
  93656. * Maximum Size of emitting particles.
  93657. */
  93658. maxSize: number;
  93659. /**
  93660. * Minimum scale of emitting particles on X axis.
  93661. */
  93662. minScaleX: number;
  93663. /**
  93664. * Maximum scale of emitting particles on X axis.
  93665. */
  93666. maxScaleX: number;
  93667. /**
  93668. * Minimum scale of emitting particles on Y axis.
  93669. */
  93670. minScaleY: number;
  93671. /**
  93672. * Maximum scale of emitting particles on Y axis.
  93673. */
  93674. maxScaleY: number;
  93675. /**
  93676. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93677. */
  93678. color1: Color4;
  93679. /**
  93680. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93681. */
  93682. color2: Color4;
  93683. /**
  93684. * Color the particle will have at the end of its lifetime.
  93685. */
  93686. colorDead: Color4;
  93687. /**
  93688. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  93689. */
  93690. emitRate: number;
  93691. /**
  93692. * You can use gravity if you want to give an orientation to your particles.
  93693. */
  93694. gravity: Vector3;
  93695. /**
  93696. * Minimum power of emitting particles.
  93697. */
  93698. minEmitPower: number;
  93699. /**
  93700. * Maximum power of emitting particles.
  93701. */
  93702. maxEmitPower: number;
  93703. /**
  93704. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  93705. */
  93706. minAngularSpeed: number;
  93707. /**
  93708. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  93709. */
  93710. maxAngularSpeed: number;
  93711. /**
  93712. * Gets or sets the minimal initial rotation in radians.
  93713. */
  93714. minInitialRotation: number;
  93715. /**
  93716. * Gets or sets the maximal initial rotation in radians.
  93717. */
  93718. maxInitialRotation: number;
  93719. /**
  93720. * The particle emitter type defines the emitter used by the particle system.
  93721. * It can be for example box, sphere, or cone...
  93722. */
  93723. particleEmitterType: Nullable<IParticleEmitterType>;
  93724. /**
  93725. * Defines the delay in milliseconds before starting the system (0 by default)
  93726. */
  93727. startDelay: number;
  93728. /**
  93729. * 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
  93730. */
  93731. preWarmCycles: number;
  93732. /**
  93733. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  93734. */
  93735. preWarmStepOffset: number;
  93736. /**
  93737. * 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)
  93738. */
  93739. spriteCellChangeSpeed: number;
  93740. /**
  93741. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  93742. */
  93743. startSpriteCellID: number;
  93744. /**
  93745. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  93746. */
  93747. endSpriteCellID: number;
  93748. /**
  93749. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  93750. */
  93751. spriteCellWidth: number;
  93752. /**
  93753. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  93754. */
  93755. spriteCellHeight: number;
  93756. /**
  93757. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  93758. */
  93759. spriteRandomStartCell: boolean;
  93760. /**
  93761. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  93762. */
  93763. isAnimationSheetEnabled: boolean;
  93764. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  93765. translationPivot: Vector2;
  93766. /**
  93767. * Gets or sets a texture used to add random noise to particle positions
  93768. */
  93769. noiseTexture: Nullable<BaseTexture>;
  93770. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  93771. noiseStrength: Vector3;
  93772. /**
  93773. * Gets or sets the billboard mode to use when isBillboardBased = true.
  93774. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  93775. */
  93776. billboardMode: number;
  93777. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  93778. limitVelocityDamping: number;
  93779. /**
  93780. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  93781. */
  93782. beginAnimationOnStart: boolean;
  93783. /**
  93784. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  93785. */
  93786. beginAnimationFrom: number;
  93787. /**
  93788. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  93789. */
  93790. beginAnimationTo: number;
  93791. /**
  93792. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  93793. */
  93794. beginAnimationLoop: boolean;
  93795. /**
  93796. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  93797. */
  93798. disposeOnStop: boolean;
  93799. /**
  93800. * Specifies if the particles are updated in emitter local space or world space
  93801. */
  93802. isLocal: boolean;
  93803. /** Snippet ID if the particle system was created from the snippet server */
  93804. snippetId: string;
  93805. /** Gets or sets a matrix to use to compute projection */
  93806. defaultProjectionMatrix: Matrix;
  93807. /**
  93808. * Gets the maximum number of particles active at the same time.
  93809. * @returns The max number of active particles.
  93810. */
  93811. getCapacity(): number;
  93812. /**
  93813. * Gets the number of particles active at the same time.
  93814. * @returns The number of active particles.
  93815. */
  93816. getActiveCount(): number;
  93817. /**
  93818. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93819. * @returns True if it has been started, otherwise false.
  93820. */
  93821. isStarted(): boolean;
  93822. /**
  93823. * Animates the particle system for this frame.
  93824. */
  93825. animate(): void;
  93826. /**
  93827. * Renders the particle system in its current state.
  93828. * @returns the current number of particles
  93829. */
  93830. render(): number;
  93831. /**
  93832. * Dispose the particle system and frees its associated resources.
  93833. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93834. */
  93835. dispose(disposeTexture?: boolean): void;
  93836. /**
  93837. * An event triggered when the system is disposed
  93838. */
  93839. onDisposeObservable: Observable<IParticleSystem>;
  93840. /**
  93841. * Clones the particle system.
  93842. * @param name The name of the cloned object
  93843. * @param newEmitter The new emitter to use
  93844. * @returns the cloned particle system
  93845. */
  93846. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  93847. /**
  93848. * Serializes the particle system to a JSON object
  93849. * @param serializeTexture defines if the texture must be serialized as well
  93850. * @returns the JSON object
  93851. */
  93852. serialize(serializeTexture: boolean): any;
  93853. /**
  93854. * Rebuild the particle system
  93855. */
  93856. rebuild(): void;
  93857. /** Force the system to rebuild all gradients that need to be resync */
  93858. forceRefreshGradients(): void;
  93859. /**
  93860. * Starts the particle system and begins to emit
  93861. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  93862. */
  93863. start(delay?: number): void;
  93864. /**
  93865. * Stops the particle system.
  93866. */
  93867. stop(): void;
  93868. /**
  93869. * Remove all active particles
  93870. */
  93871. reset(): void;
  93872. /**
  93873. * Gets a boolean indicating that the system is stopping
  93874. * @returns true if the system is currently stopping
  93875. */
  93876. isStopping(): boolean;
  93877. /**
  93878. * Is this system ready to be used/rendered
  93879. * @return true if the system is ready
  93880. */
  93881. isReady(): boolean;
  93882. /**
  93883. * Returns the string "ParticleSystem"
  93884. * @returns a string containing the class name
  93885. */
  93886. getClassName(): string;
  93887. /**
  93888. * Gets the custom effect used to render the particles
  93889. * @param blendMode Blend mode for which the effect should be retrieved
  93890. * @returns The effect
  93891. */
  93892. getCustomEffect(blendMode: number): Nullable<Effect>;
  93893. /**
  93894. * Sets the custom effect used to render the particles
  93895. * @param effect The effect to set
  93896. * @param blendMode Blend mode for which the effect should be set
  93897. */
  93898. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  93899. /**
  93900. * Fill the defines array according to the current settings of the particle system
  93901. * @param defines Array to be updated
  93902. * @param blendMode blend mode to take into account when updating the array
  93903. */
  93904. fillDefines(defines: Array<string>, blendMode: number): void;
  93905. /**
  93906. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93907. * @param uniforms Uniforms array to fill
  93908. * @param attributes Attributes array to fill
  93909. * @param samplers Samplers array to fill
  93910. */
  93911. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93912. /**
  93913. * Observable that will be called just before the particles are drawn
  93914. */
  93915. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  93916. /**
  93917. * Gets the name of the particle vertex shader
  93918. */
  93919. vertexShaderName: string;
  93920. /**
  93921. * Adds a new color gradient
  93922. * @param gradient defines the gradient to use (between 0 and 1)
  93923. * @param color1 defines the color to affect to the specified gradient
  93924. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93925. * @returns the current particle system
  93926. */
  93927. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93928. /**
  93929. * Remove a specific color gradient
  93930. * @param gradient defines the gradient to remove
  93931. * @returns the current particle system
  93932. */
  93933. removeColorGradient(gradient: number): IParticleSystem;
  93934. /**
  93935. * Adds a new size gradient
  93936. * @param gradient defines the gradient to use (between 0 and 1)
  93937. * @param factor defines the size factor to affect to the specified gradient
  93938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93939. * @returns the current particle system
  93940. */
  93941. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93942. /**
  93943. * Remove a specific size gradient
  93944. * @param gradient defines the gradient to remove
  93945. * @returns the current particle system
  93946. */
  93947. removeSizeGradient(gradient: number): IParticleSystem;
  93948. /**
  93949. * Gets the current list of color gradients.
  93950. * You must use addColorGradient and removeColorGradient to udpate this list
  93951. * @returns the list of color gradients
  93952. */
  93953. getColorGradients(): Nullable<Array<ColorGradient>>;
  93954. /**
  93955. * Gets the current list of size gradients.
  93956. * You must use addSizeGradient and removeSizeGradient to udpate this list
  93957. * @returns the list of size gradients
  93958. */
  93959. getSizeGradients(): Nullable<Array<FactorGradient>>;
  93960. /**
  93961. * Gets the current list of angular speed gradients.
  93962. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  93963. * @returns the list of angular speed gradients
  93964. */
  93965. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  93966. /**
  93967. * Adds a new angular speed gradient
  93968. * @param gradient defines the gradient to use (between 0 and 1)
  93969. * @param factor defines the angular speed to affect to the specified gradient
  93970. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93971. * @returns the current particle system
  93972. */
  93973. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93974. /**
  93975. * Remove a specific angular speed gradient
  93976. * @param gradient defines the gradient to remove
  93977. * @returns the current particle system
  93978. */
  93979. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93980. /**
  93981. * Gets the current list of velocity gradients.
  93982. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  93983. * @returns the list of velocity gradients
  93984. */
  93985. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  93986. /**
  93987. * Adds a new velocity gradient
  93988. * @param gradient defines the gradient to use (between 0 and 1)
  93989. * @param factor defines the velocity to affect to the specified gradient
  93990. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93991. * @returns the current particle system
  93992. */
  93993. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93994. /**
  93995. * Remove a specific velocity gradient
  93996. * @param gradient defines the gradient to remove
  93997. * @returns the current particle system
  93998. */
  93999. removeVelocityGradient(gradient: number): IParticleSystem;
  94000. /**
  94001. * Gets the current list of limit velocity gradients.
  94002. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  94003. * @returns the list of limit velocity gradients
  94004. */
  94005. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  94006. /**
  94007. * Adds a new limit velocity gradient
  94008. * @param gradient defines the gradient to use (between 0 and 1)
  94009. * @param factor defines the limit velocity to affect to the specified gradient
  94010. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94011. * @returns the current particle system
  94012. */
  94013. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94014. /**
  94015. * Remove a specific limit velocity gradient
  94016. * @param gradient defines the gradient to remove
  94017. * @returns the current particle system
  94018. */
  94019. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94020. /**
  94021. * Adds a new drag gradient
  94022. * @param gradient defines the gradient to use (between 0 and 1)
  94023. * @param factor defines the drag to affect to the specified gradient
  94024. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94025. * @returns the current particle system
  94026. */
  94027. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94028. /**
  94029. * Remove a specific drag gradient
  94030. * @param gradient defines the gradient to remove
  94031. * @returns the current particle system
  94032. */
  94033. removeDragGradient(gradient: number): IParticleSystem;
  94034. /**
  94035. * Gets the current list of drag gradients.
  94036. * You must use addDragGradient and removeDragGradient to udpate this list
  94037. * @returns the list of drag gradients
  94038. */
  94039. getDragGradients(): Nullable<Array<FactorGradient>>;
  94040. /**
  94041. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94042. * @param gradient defines the gradient to use (between 0 and 1)
  94043. * @param factor defines the emit rate to affect to the specified gradient
  94044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94045. * @returns the current particle system
  94046. */
  94047. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94048. /**
  94049. * Remove a specific emit rate gradient
  94050. * @param gradient defines the gradient to remove
  94051. * @returns the current particle system
  94052. */
  94053. removeEmitRateGradient(gradient: number): IParticleSystem;
  94054. /**
  94055. * Gets the current list of emit rate gradients.
  94056. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  94057. * @returns the list of emit rate gradients
  94058. */
  94059. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  94060. /**
  94061. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94062. * @param gradient defines the gradient to use (between 0 and 1)
  94063. * @param factor defines the start size to affect to the specified gradient
  94064. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94065. * @returns the current particle system
  94066. */
  94067. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94068. /**
  94069. * Remove a specific start size gradient
  94070. * @param gradient defines the gradient to remove
  94071. * @returns the current particle system
  94072. */
  94073. removeStartSizeGradient(gradient: number): IParticleSystem;
  94074. /**
  94075. * Gets the current list of start size gradients.
  94076. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  94077. * @returns the list of start size gradients
  94078. */
  94079. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  94080. /**
  94081. * Adds a new life time gradient
  94082. * @param gradient defines the gradient to use (between 0 and 1)
  94083. * @param factor defines the life time factor to affect to the specified gradient
  94084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94085. * @returns the current particle system
  94086. */
  94087. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94088. /**
  94089. * Remove a specific life time gradient
  94090. * @param gradient defines the gradient to remove
  94091. * @returns the current particle system
  94092. */
  94093. removeLifeTimeGradient(gradient: number): IParticleSystem;
  94094. /**
  94095. * Gets the current list of life time gradients.
  94096. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  94097. * @returns the list of life time gradients
  94098. */
  94099. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  94100. /**
  94101. * Gets the current list of color gradients.
  94102. * You must use addColorGradient and removeColorGradient to udpate this list
  94103. * @returns the list of color gradients
  94104. */
  94105. getColorGradients(): Nullable<Array<ColorGradient>>;
  94106. /**
  94107. * Adds a new ramp gradient used to remap particle colors
  94108. * @param gradient defines the gradient to use (between 0 and 1)
  94109. * @param color defines the color to affect to the specified gradient
  94110. * @returns the current particle system
  94111. */
  94112. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  94113. /**
  94114. * Gets the current list of ramp gradients.
  94115. * You must use addRampGradient and removeRampGradient to udpate this list
  94116. * @returns the list of ramp gradients
  94117. */
  94118. getRampGradients(): Nullable<Array<Color3Gradient>>;
  94119. /** Gets or sets a boolean indicating that ramp gradients must be used
  94120. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  94121. */
  94122. useRampGradients: boolean;
  94123. /**
  94124. * Adds a new color remap gradient
  94125. * @param gradient defines the gradient to use (between 0 and 1)
  94126. * @param min defines the color remap minimal range
  94127. * @param max defines the color remap maximal range
  94128. * @returns the current particle system
  94129. */
  94130. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94131. /**
  94132. * Gets the current list of color remap gradients.
  94133. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  94134. * @returns the list of color remap gradients
  94135. */
  94136. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  94137. /**
  94138. * Adds a new alpha remap gradient
  94139. * @param gradient defines the gradient to use (between 0 and 1)
  94140. * @param min defines the alpha remap minimal range
  94141. * @param max defines the alpha remap maximal range
  94142. * @returns the current particle system
  94143. */
  94144. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94145. /**
  94146. * Gets the current list of alpha remap gradients.
  94147. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  94148. * @returns the list of alpha remap gradients
  94149. */
  94150. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  94151. /**
  94152. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  94153. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94154. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94155. * @returns the emitter
  94156. */
  94157. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  94158. /**
  94159. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  94160. * @param radius The radius of the hemisphere to emit from
  94161. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94162. * @returns the emitter
  94163. */
  94164. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  94165. /**
  94166. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  94167. * @param radius The radius of the sphere to emit from
  94168. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94169. * @returns the emitter
  94170. */
  94171. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  94172. /**
  94173. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  94174. * @param radius The radius of the sphere to emit from
  94175. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  94176. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  94177. * @returns the emitter
  94178. */
  94179. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94180. /**
  94181. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  94182. * @param radius The radius of the emission cylinder
  94183. * @param height The height of the emission cylinder
  94184. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  94185. * @param directionRandomizer How much to randomize the particle direction [0-1]
  94186. * @returns the emitter
  94187. */
  94188. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  94189. /**
  94190. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  94191. * @param radius The radius of the cylinder to emit from
  94192. * @param height The height of the emission cylinder
  94193. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94194. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  94195. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  94196. * @returns the emitter
  94197. */
  94198. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94199. /**
  94200. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  94201. * @param radius The radius of the cone to emit from
  94202. * @param angle The base angle of the cone
  94203. * @returns the emitter
  94204. */
  94205. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  94206. /**
  94207. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  94208. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94209. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94210. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94211. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94212. * @returns the emitter
  94213. */
  94214. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  94215. /**
  94216. * Get hosting scene
  94217. * @returns the scene
  94218. */
  94219. getScene(): Nullable<Scene>;
  94220. }
  94221. }
  94222. declare module BABYLON {
  94223. /**
  94224. * 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.
  94225. * @see https://doc.babylonjs.com/how_to/transformnode
  94226. */
  94227. export class TransformNode extends Node {
  94228. /**
  94229. * Object will not rotate to face the camera
  94230. */
  94231. static BILLBOARDMODE_NONE: number;
  94232. /**
  94233. * Object will rotate to face the camera but only on the x axis
  94234. */
  94235. static BILLBOARDMODE_X: number;
  94236. /**
  94237. * Object will rotate to face the camera but only on the y axis
  94238. */
  94239. static BILLBOARDMODE_Y: number;
  94240. /**
  94241. * Object will rotate to face the camera but only on the z axis
  94242. */
  94243. static BILLBOARDMODE_Z: number;
  94244. /**
  94245. * Object will rotate to face the camera
  94246. */
  94247. static BILLBOARDMODE_ALL: number;
  94248. /**
  94249. * Object will rotate to face the camera's position instead of orientation
  94250. */
  94251. static BILLBOARDMODE_USE_POSITION: number;
  94252. private static _TmpRotation;
  94253. private static _TmpScaling;
  94254. private static _TmpTranslation;
  94255. private _forward;
  94256. private _forwardInverted;
  94257. private _up;
  94258. private _right;
  94259. private _rightInverted;
  94260. private _position;
  94261. private _rotation;
  94262. private _rotationQuaternion;
  94263. protected _scaling: Vector3;
  94264. protected _isDirty: boolean;
  94265. private _transformToBoneReferal;
  94266. private _isAbsoluteSynced;
  94267. private _billboardMode;
  94268. /**
  94269. * Gets or sets the billboard mode. Default is 0.
  94270. *
  94271. * | Value | Type | Description |
  94272. * | --- | --- | --- |
  94273. * | 0 | BILLBOARDMODE_NONE | |
  94274. * | 1 | BILLBOARDMODE_X | |
  94275. * | 2 | BILLBOARDMODE_Y | |
  94276. * | 4 | BILLBOARDMODE_Z | |
  94277. * | 7 | BILLBOARDMODE_ALL | |
  94278. *
  94279. */
  94280. get billboardMode(): number;
  94281. set billboardMode(value: number);
  94282. private _preserveParentRotationForBillboard;
  94283. /**
  94284. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  94285. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  94286. */
  94287. get preserveParentRotationForBillboard(): boolean;
  94288. set preserveParentRotationForBillboard(value: boolean);
  94289. /**
  94290. * 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
  94291. */
  94292. scalingDeterminant: number;
  94293. private _infiniteDistance;
  94294. /**
  94295. * Gets or sets the distance of the object to max, often used by skybox
  94296. */
  94297. get infiniteDistance(): boolean;
  94298. set infiniteDistance(value: boolean);
  94299. /**
  94300. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  94301. * By default the system will update normals to compensate
  94302. */
  94303. ignoreNonUniformScaling: boolean;
  94304. /**
  94305. * 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
  94306. */
  94307. reIntegrateRotationIntoRotationQuaternion: boolean;
  94308. /** @hidden */
  94309. _poseMatrix: Nullable<Matrix>;
  94310. /** @hidden */
  94311. _localMatrix: Matrix;
  94312. private _usePivotMatrix;
  94313. private _absolutePosition;
  94314. private _absoluteScaling;
  94315. private _absoluteRotationQuaternion;
  94316. private _pivotMatrix;
  94317. private _pivotMatrixInverse;
  94318. protected _postMultiplyPivotMatrix: boolean;
  94319. protected _isWorldMatrixFrozen: boolean;
  94320. /** @hidden */
  94321. _indexInSceneTransformNodesArray: number;
  94322. /**
  94323. * An event triggered after the world matrix is updated
  94324. */
  94325. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  94326. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  94327. /**
  94328. * Gets a string identifying the name of the class
  94329. * @returns "TransformNode" string
  94330. */
  94331. getClassName(): string;
  94332. /**
  94333. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  94334. */
  94335. get position(): Vector3;
  94336. set position(newPosition: Vector3);
  94337. /**
  94338. * 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)).
  94339. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  94340. */
  94341. get rotation(): Vector3;
  94342. set rotation(newRotation: Vector3);
  94343. /**
  94344. * 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)).
  94345. */
  94346. get scaling(): Vector3;
  94347. set scaling(newScaling: Vector3);
  94348. /**
  94349. * 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).
  94350. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  94351. */
  94352. get rotationQuaternion(): Nullable<Quaternion>;
  94353. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  94354. /**
  94355. * The forward direction of that transform in world space.
  94356. */
  94357. get forward(): Vector3;
  94358. /**
  94359. * The up direction of that transform in world space.
  94360. */
  94361. get up(): Vector3;
  94362. /**
  94363. * The right direction of that transform in world space.
  94364. */
  94365. get right(): Vector3;
  94366. /**
  94367. * Copies the parameter passed Matrix into the mesh Pose matrix.
  94368. * @param matrix the matrix to copy the pose from
  94369. * @returns this TransformNode.
  94370. */
  94371. updatePoseMatrix(matrix: Matrix): TransformNode;
  94372. /**
  94373. * Returns the mesh Pose matrix.
  94374. * @returns the pose matrix
  94375. */
  94376. getPoseMatrix(): Matrix;
  94377. /** @hidden */
  94378. _isSynchronized(): boolean;
  94379. /** @hidden */
  94380. _initCache(): void;
  94381. /**
  94382. * Flag the transform node as dirty (Forcing it to update everything)
  94383. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  94384. * @returns this transform node
  94385. */
  94386. markAsDirty(property: string): TransformNode;
  94387. /**
  94388. * Returns the current mesh absolute position.
  94389. * Returns a Vector3.
  94390. */
  94391. get absolutePosition(): Vector3;
  94392. /**
  94393. * Returns the current mesh absolute scaling.
  94394. * Returns a Vector3.
  94395. */
  94396. get absoluteScaling(): Vector3;
  94397. /**
  94398. * Returns the current mesh absolute rotation.
  94399. * Returns a Quaternion.
  94400. */
  94401. get absoluteRotationQuaternion(): Quaternion;
  94402. /**
  94403. * Sets a new matrix to apply before all other transformation
  94404. * @param matrix defines the transform matrix
  94405. * @returns the current TransformNode
  94406. */
  94407. setPreTransformMatrix(matrix: Matrix): TransformNode;
  94408. /**
  94409. * Sets a new pivot matrix to the current node
  94410. * @param matrix defines the new pivot matrix to use
  94411. * @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
  94412. * @returns the current TransformNode
  94413. */
  94414. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  94415. /**
  94416. * Returns the mesh pivot matrix.
  94417. * Default : Identity.
  94418. * @returns the matrix
  94419. */
  94420. getPivotMatrix(): Matrix;
  94421. /**
  94422. * Instantiate (when possible) or clone that node with its hierarchy
  94423. * @param newParent defines the new parent to use for the instance (or clone)
  94424. * @param options defines options to configure how copy is done
  94425. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  94426. * @returns an instance (or a clone) of the current node with its hiearchy
  94427. */
  94428. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  94429. doNotInstantiate: boolean;
  94430. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  94431. /**
  94432. * Prevents the World matrix to be computed any longer
  94433. * @param newWorldMatrix defines an optional matrix to use as world matrix
  94434. * @returns the TransformNode.
  94435. */
  94436. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  94437. /**
  94438. * Allows back the World matrix computation.
  94439. * @returns the TransformNode.
  94440. */
  94441. unfreezeWorldMatrix(): this;
  94442. /**
  94443. * True if the World matrix has been frozen.
  94444. */
  94445. get isWorldMatrixFrozen(): boolean;
  94446. /**
  94447. * Retuns the mesh absolute position in the World.
  94448. * @returns a Vector3.
  94449. */
  94450. getAbsolutePosition(): Vector3;
  94451. /**
  94452. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  94453. * @param absolutePosition the absolute position to set
  94454. * @returns the TransformNode.
  94455. */
  94456. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94457. /**
  94458. * Sets the mesh position in its local space.
  94459. * @param vector3 the position to set in localspace
  94460. * @returns the TransformNode.
  94461. */
  94462. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  94463. /**
  94464. * Returns the mesh position in the local space from the current World matrix values.
  94465. * @returns a new Vector3.
  94466. */
  94467. getPositionExpressedInLocalSpace(): Vector3;
  94468. /**
  94469. * Translates the mesh along the passed Vector3 in its local space.
  94470. * @param vector3 the distance to translate in localspace
  94471. * @returns the TransformNode.
  94472. */
  94473. locallyTranslate(vector3: Vector3): TransformNode;
  94474. private static _lookAtVectorCache;
  94475. /**
  94476. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  94477. * @param targetPoint the position (must be in same space as current mesh) to look at
  94478. * @param yawCor optional yaw (y-axis) correction in radians
  94479. * @param pitchCor optional pitch (x-axis) correction in radians
  94480. * @param rollCor optional roll (z-axis) correction in radians
  94481. * @param space the choosen space of the target
  94482. * @returns the TransformNode.
  94483. */
  94484. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  94485. /**
  94486. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94487. * This Vector3 is expressed in the World space.
  94488. * @param localAxis axis to rotate
  94489. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94490. */
  94491. getDirection(localAxis: Vector3): Vector3;
  94492. /**
  94493. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  94494. * localAxis is expressed in the mesh local space.
  94495. * result is computed in the Wordl space from the mesh World matrix.
  94496. * @param localAxis axis to rotate
  94497. * @param result the resulting transformnode
  94498. * @returns this TransformNode.
  94499. */
  94500. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  94501. /**
  94502. * Sets this transform node rotation to the given local axis.
  94503. * @param localAxis the axis in local space
  94504. * @param yawCor optional yaw (y-axis) correction in radians
  94505. * @param pitchCor optional pitch (x-axis) correction in radians
  94506. * @param rollCor optional roll (z-axis) correction in radians
  94507. * @returns this TransformNode
  94508. */
  94509. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  94510. /**
  94511. * Sets a new pivot point to the current node
  94512. * @param point defines the new pivot point to use
  94513. * @param space defines if the point is in world or local space (local by default)
  94514. * @returns the current TransformNode
  94515. */
  94516. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  94517. /**
  94518. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  94519. * @returns the pivot point
  94520. */
  94521. getPivotPoint(): Vector3;
  94522. /**
  94523. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  94524. * @param result the vector3 to store the result
  94525. * @returns this TransformNode.
  94526. */
  94527. getPivotPointToRef(result: Vector3): TransformNode;
  94528. /**
  94529. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  94530. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  94531. */
  94532. getAbsolutePivotPoint(): Vector3;
  94533. /**
  94534. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  94535. * @param result vector3 to store the result
  94536. * @returns this TransformNode.
  94537. */
  94538. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  94539. /**
  94540. * Defines the passed node as the parent of the current node.
  94541. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  94542. * @see https://doc.babylonjs.com/how_to/parenting
  94543. * @param node the node ot set as the parent
  94544. * @returns this TransformNode.
  94545. */
  94546. setParent(node: Nullable<Node>): TransformNode;
  94547. private _nonUniformScaling;
  94548. /**
  94549. * True if the scaling property of this object is non uniform eg. (1,2,1)
  94550. */
  94551. get nonUniformScaling(): boolean;
  94552. /** @hidden */
  94553. _updateNonUniformScalingState(value: boolean): boolean;
  94554. /**
  94555. * Attach the current TransformNode to another TransformNode associated with a bone
  94556. * @param bone Bone affecting the TransformNode
  94557. * @param affectedTransformNode TransformNode associated with the bone
  94558. * @returns this object
  94559. */
  94560. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  94561. /**
  94562. * Detach the transform node if its associated with a bone
  94563. * @returns this object
  94564. */
  94565. detachFromBone(): TransformNode;
  94566. private static _rotationAxisCache;
  94567. /**
  94568. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  94569. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94570. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94571. * The passed axis is also normalized.
  94572. * @param axis the axis to rotate around
  94573. * @param amount the amount to rotate in radians
  94574. * @param space Space to rotate in (Default: local)
  94575. * @returns the TransformNode.
  94576. */
  94577. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94578. /**
  94579. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  94580. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94581. * The passed axis is also normalized. .
  94582. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  94583. * @param point the point to rotate around
  94584. * @param axis the axis to rotate around
  94585. * @param amount the amount to rotate in radians
  94586. * @returns the TransformNode
  94587. */
  94588. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  94589. /**
  94590. * Translates the mesh along the axis vector for the passed distance in the given space.
  94591. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94592. * @param axis the axis to translate in
  94593. * @param distance the distance to translate
  94594. * @param space Space to rotate in (Default: local)
  94595. * @returns the TransformNode.
  94596. */
  94597. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94598. /**
  94599. * Adds a rotation step to the mesh current rotation.
  94600. * x, y, z are Euler angles expressed in radians.
  94601. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  94602. * This means this rotation is made in the mesh local space only.
  94603. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  94604. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  94605. * ```javascript
  94606. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  94607. * ```
  94608. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  94609. * 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.
  94610. * @param x Rotation to add
  94611. * @param y Rotation to add
  94612. * @param z Rotation to add
  94613. * @returns the TransformNode.
  94614. */
  94615. addRotation(x: number, y: number, z: number): TransformNode;
  94616. /**
  94617. * @hidden
  94618. */
  94619. protected _getEffectiveParent(): Nullable<Node>;
  94620. /**
  94621. * Computes the world matrix of the node
  94622. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94623. * @returns the world matrix
  94624. */
  94625. computeWorldMatrix(force?: boolean): Matrix;
  94626. /**
  94627. * Resets this nodeTransform's local matrix to Matrix.Identity().
  94628. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  94629. */
  94630. resetLocalMatrix(independentOfChildren?: boolean): void;
  94631. protected _afterComputeWorldMatrix(): void;
  94632. /**
  94633. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  94634. * @param func callback function to add
  94635. *
  94636. * @returns the TransformNode.
  94637. */
  94638. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94639. /**
  94640. * Removes a registered callback function.
  94641. * @param func callback function to remove
  94642. * @returns the TransformNode.
  94643. */
  94644. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94645. /**
  94646. * Gets the position of the current mesh in camera space
  94647. * @param camera defines the camera to use
  94648. * @returns a position
  94649. */
  94650. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  94651. /**
  94652. * Returns the distance from the mesh to the active camera
  94653. * @param camera defines the camera to use
  94654. * @returns the distance
  94655. */
  94656. getDistanceToCamera(camera?: Nullable<Camera>): number;
  94657. /**
  94658. * Clone the current transform node
  94659. * @param name Name of the new clone
  94660. * @param newParent New parent for the clone
  94661. * @param doNotCloneChildren Do not clone children hierarchy
  94662. * @returns the new transform node
  94663. */
  94664. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  94665. /**
  94666. * Serializes the objects information.
  94667. * @param currentSerializationObject defines the object to serialize in
  94668. * @returns the serialized object
  94669. */
  94670. serialize(currentSerializationObject?: any): any;
  94671. /**
  94672. * Returns a new TransformNode object parsed from the source provided.
  94673. * @param parsedTransformNode is the source.
  94674. * @param scene the scne the object belongs to
  94675. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  94676. * @returns a new TransformNode object parsed from the source provided.
  94677. */
  94678. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  94679. /**
  94680. * Get all child-transformNodes of this node
  94681. * @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
  94682. * @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
  94683. * @returns an array of TransformNode
  94684. */
  94685. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  94686. /**
  94687. * Releases resources associated with this transform node.
  94688. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94689. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94690. */
  94691. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94692. /**
  94693. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94694. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94695. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94696. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94697. * @returns the current mesh
  94698. */
  94699. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  94700. private _syncAbsoluteScalingAndRotation;
  94701. }
  94702. }
  94703. declare module BABYLON {
  94704. /**
  94705. * Class used to override all child animations of a given target
  94706. */
  94707. export class AnimationPropertiesOverride {
  94708. /**
  94709. * Gets or sets a value indicating if animation blending must be used
  94710. */
  94711. enableBlending: boolean;
  94712. /**
  94713. * Gets or sets the blending speed to use when enableBlending is true
  94714. */
  94715. blendingSpeed: number;
  94716. /**
  94717. * Gets or sets the default loop mode to use
  94718. */
  94719. loopMode: number;
  94720. }
  94721. }
  94722. declare module BABYLON {
  94723. /**
  94724. * Class used to store bone information
  94725. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94726. */
  94727. export class Bone extends Node {
  94728. /**
  94729. * defines the bone name
  94730. */
  94731. name: string;
  94732. private static _tmpVecs;
  94733. private static _tmpQuat;
  94734. private static _tmpMats;
  94735. /**
  94736. * Gets the list of child bones
  94737. */
  94738. children: Bone[];
  94739. /** Gets the animations associated with this bone */
  94740. animations: Animation[];
  94741. /**
  94742. * Gets or sets bone length
  94743. */
  94744. length: number;
  94745. /**
  94746. * @hidden Internal only
  94747. * Set this value to map this bone to a different index in the transform matrices
  94748. * Set this value to -1 to exclude the bone from the transform matrices
  94749. */
  94750. _index: Nullable<number>;
  94751. private _skeleton;
  94752. private _localMatrix;
  94753. private _restPose;
  94754. private _bindPose;
  94755. private _baseMatrix;
  94756. private _absoluteTransform;
  94757. private _invertedAbsoluteTransform;
  94758. private _parent;
  94759. private _scalingDeterminant;
  94760. private _worldTransform;
  94761. private _localScaling;
  94762. private _localRotation;
  94763. private _localPosition;
  94764. private _needToDecompose;
  94765. private _needToCompose;
  94766. /** @hidden */
  94767. _linkedTransformNode: Nullable<TransformNode>;
  94768. /** @hidden */
  94769. _waitingTransformNodeId: Nullable<string>;
  94770. /** @hidden */
  94771. get _matrix(): Matrix;
  94772. /** @hidden */
  94773. set _matrix(value: Matrix);
  94774. /**
  94775. * Create a new bone
  94776. * @param name defines the bone name
  94777. * @param skeleton defines the parent skeleton
  94778. * @param parentBone defines the parent (can be null if the bone is the root)
  94779. * @param localMatrix defines the local matrix
  94780. * @param restPose defines the rest pose matrix
  94781. * @param baseMatrix defines the base matrix
  94782. * @param index defines index of the bone in the hiearchy
  94783. */
  94784. constructor(
  94785. /**
  94786. * defines the bone name
  94787. */
  94788. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  94789. /**
  94790. * Gets the current object class name.
  94791. * @return the class name
  94792. */
  94793. getClassName(): string;
  94794. /**
  94795. * Gets the parent skeleton
  94796. * @returns a skeleton
  94797. */
  94798. getSkeleton(): Skeleton;
  94799. /**
  94800. * Gets parent bone
  94801. * @returns a bone or null if the bone is the root of the bone hierarchy
  94802. */
  94803. getParent(): Nullable<Bone>;
  94804. /**
  94805. * Returns an array containing the root bones
  94806. * @returns an array containing the root bones
  94807. */
  94808. getChildren(): Array<Bone>;
  94809. /**
  94810. * Gets the node index in matrix array generated for rendering
  94811. * @returns the node index
  94812. */
  94813. getIndex(): number;
  94814. /**
  94815. * Sets the parent bone
  94816. * @param parent defines the parent (can be null if the bone is the root)
  94817. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94818. */
  94819. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  94820. /**
  94821. * Gets the local matrix
  94822. * @returns a matrix
  94823. */
  94824. getLocalMatrix(): Matrix;
  94825. /**
  94826. * Gets the base matrix (initial matrix which remains unchanged)
  94827. * @returns a matrix
  94828. */
  94829. getBaseMatrix(): Matrix;
  94830. /**
  94831. * Gets the rest pose matrix
  94832. * @returns a matrix
  94833. */
  94834. getRestPose(): Matrix;
  94835. /**
  94836. * Sets the rest pose matrix
  94837. * @param matrix the local-space rest pose to set for this bone
  94838. */
  94839. setRestPose(matrix: Matrix): void;
  94840. /**
  94841. * Gets the bind pose matrix
  94842. * @returns the bind pose matrix
  94843. */
  94844. getBindPose(): Matrix;
  94845. /**
  94846. * Sets the bind pose matrix
  94847. * @param matrix the local-space bind pose to set for this bone
  94848. */
  94849. setBindPose(matrix: Matrix): void;
  94850. /**
  94851. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  94852. */
  94853. getWorldMatrix(): Matrix;
  94854. /**
  94855. * Sets the local matrix to rest pose matrix
  94856. */
  94857. returnToRest(): void;
  94858. /**
  94859. * Gets the inverse of the absolute transform matrix.
  94860. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  94861. * @returns a matrix
  94862. */
  94863. getInvertedAbsoluteTransform(): Matrix;
  94864. /**
  94865. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  94866. * @returns a matrix
  94867. */
  94868. getAbsoluteTransform(): Matrix;
  94869. /**
  94870. * Links with the given transform node.
  94871. * The local matrix of this bone is copied from the transform node every frame.
  94872. * @param transformNode defines the transform node to link to
  94873. */
  94874. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  94875. /**
  94876. * Gets the node used to drive the bone's transformation
  94877. * @returns a transform node or null
  94878. */
  94879. getTransformNode(): Nullable<TransformNode>;
  94880. /** Gets or sets current position (in local space) */
  94881. get position(): Vector3;
  94882. set position(newPosition: Vector3);
  94883. /** Gets or sets current rotation (in local space) */
  94884. get rotation(): Vector3;
  94885. set rotation(newRotation: Vector3);
  94886. /** Gets or sets current rotation quaternion (in local space) */
  94887. get rotationQuaternion(): Quaternion;
  94888. set rotationQuaternion(newRotation: Quaternion);
  94889. /** Gets or sets current scaling (in local space) */
  94890. get scaling(): Vector3;
  94891. set scaling(newScaling: Vector3);
  94892. /**
  94893. * Gets the animation properties override
  94894. */
  94895. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94896. private _decompose;
  94897. private _compose;
  94898. /**
  94899. * Update the base and local matrices
  94900. * @param matrix defines the new base or local matrix
  94901. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94902. * @param updateLocalMatrix defines if the local matrix should be updated
  94903. */
  94904. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  94905. /** @hidden */
  94906. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  94907. /**
  94908. * Flag the bone as dirty (Forcing it to update everything)
  94909. */
  94910. markAsDirty(): void;
  94911. /** @hidden */
  94912. _markAsDirtyAndCompose(): void;
  94913. private _markAsDirtyAndDecompose;
  94914. /**
  94915. * Translate the bone in local or world space
  94916. * @param vec The amount to translate the bone
  94917. * @param space The space that the translation is in
  94918. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94919. */
  94920. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94921. /**
  94922. * Set the postion of the bone in local or world space
  94923. * @param position The position to set the bone
  94924. * @param space The space that the position is in
  94925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94926. */
  94927. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94928. /**
  94929. * Set the absolute position of the bone (world space)
  94930. * @param position The position to set the bone
  94931. * @param mesh The mesh that this bone is attached to
  94932. */
  94933. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  94934. /**
  94935. * Scale the bone on the x, y and z axes (in local space)
  94936. * @param x The amount to scale the bone on the x axis
  94937. * @param y The amount to scale the bone on the y axis
  94938. * @param z The amount to scale the bone on the z axis
  94939. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  94940. */
  94941. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  94942. /**
  94943. * Set the bone scaling in local space
  94944. * @param scale defines the scaling vector
  94945. */
  94946. setScale(scale: Vector3): void;
  94947. /**
  94948. * Gets the current scaling in local space
  94949. * @returns the current scaling vector
  94950. */
  94951. getScale(): Vector3;
  94952. /**
  94953. * Gets the current scaling in local space and stores it in a target vector
  94954. * @param result defines the target vector
  94955. */
  94956. getScaleToRef(result: Vector3): void;
  94957. /**
  94958. * Set the yaw, pitch, and roll of the bone in local or world space
  94959. * @param yaw The rotation of the bone on the y axis
  94960. * @param pitch The rotation of the bone on the x axis
  94961. * @param roll The rotation of the bone on the z axis
  94962. * @param space The space that the axes of rotation are in
  94963. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94964. */
  94965. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  94966. /**
  94967. * Add a rotation to the bone on an axis in local or world space
  94968. * @param axis The axis to rotate the bone on
  94969. * @param amount The amount to rotate the bone
  94970. * @param space The space that the axis is in
  94971. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94972. */
  94973. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  94974. /**
  94975. * Set the rotation of the bone to a particular axis angle in local or world space
  94976. * @param axis The axis to rotate the bone on
  94977. * @param angle The angle that the bone should be rotated to
  94978. * @param space The space that the axis is in
  94979. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94980. */
  94981. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  94982. /**
  94983. * Set the euler rotation of the bone in local of world space
  94984. * @param rotation The euler rotation that the bone should be set to
  94985. * @param space The space that the rotation is in
  94986. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94987. */
  94988. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94989. /**
  94990. * Set the quaternion rotation of the bone in local of world space
  94991. * @param quat The quaternion rotation that the bone should be set to
  94992. * @param space The space that the rotation is in
  94993. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94994. */
  94995. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  94996. /**
  94997. * Set the rotation matrix of the bone in local of world space
  94998. * @param rotMat The rotation matrix that the bone should be set to
  94999. * @param space The space that the rotation is in
  95000. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95001. */
  95002. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  95003. private _rotateWithMatrix;
  95004. private _getNegativeRotationToRef;
  95005. /**
  95006. * Get the position of the bone in local or world space
  95007. * @param space The space that the returned position is in
  95008. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95009. * @returns The position of the bone
  95010. */
  95011. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95012. /**
  95013. * Copy the position of the bone to a vector3 in local or world space
  95014. * @param space The space that the returned position is in
  95015. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95016. * @param result The vector3 to copy the position to
  95017. */
  95018. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  95019. /**
  95020. * Get the absolute position of the bone (world space)
  95021. * @param mesh The mesh that this bone is attached to
  95022. * @returns The absolute position of the bone
  95023. */
  95024. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  95025. /**
  95026. * Copy the absolute position of the bone (world space) to the result param
  95027. * @param mesh The mesh that this bone is attached to
  95028. * @param result The vector3 to copy the absolute position to
  95029. */
  95030. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  95031. /**
  95032. * Compute the absolute transforms of this bone and its children
  95033. */
  95034. computeAbsoluteTransforms(): void;
  95035. /**
  95036. * Get the world direction from an axis that is in the local space of the bone
  95037. * @param localAxis The local direction that is used to compute the world direction
  95038. * @param mesh The mesh that this bone is attached to
  95039. * @returns The world direction
  95040. */
  95041. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95042. /**
  95043. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  95044. * @param localAxis The local direction that is used to compute the world direction
  95045. * @param mesh The mesh that this bone is attached to
  95046. * @param result The vector3 that the world direction will be copied to
  95047. */
  95048. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95049. /**
  95050. * Get the euler rotation of the bone in local or world space
  95051. * @param space The space that the rotation should be in
  95052. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95053. * @returns The euler rotation
  95054. */
  95055. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95056. /**
  95057. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  95058. * @param space The space that the rotation should be in
  95059. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95060. * @param result The vector3 that the rotation should be copied to
  95061. */
  95062. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95063. /**
  95064. * Get the quaternion rotation of the bone in either local or world space
  95065. * @param space The space that the rotation should be in
  95066. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95067. * @returns The quaternion rotation
  95068. */
  95069. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  95070. /**
  95071. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  95072. * @param space The space that the rotation should be in
  95073. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95074. * @param result The quaternion that the rotation should be copied to
  95075. */
  95076. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  95077. /**
  95078. * Get the rotation matrix of the bone in local or world space
  95079. * @param space The space that the rotation should be in
  95080. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95081. * @returns The rotation matrix
  95082. */
  95083. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  95084. /**
  95085. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  95086. * @param space The space that the rotation should be in
  95087. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95088. * @param result The quaternion that the rotation should be copied to
  95089. */
  95090. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  95091. /**
  95092. * Get the world position of a point that is in the local space of the bone
  95093. * @param position The local position
  95094. * @param mesh The mesh that this bone is attached to
  95095. * @returns The world position
  95096. */
  95097. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95098. /**
  95099. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  95100. * @param position The local position
  95101. * @param mesh The mesh that this bone is attached to
  95102. * @param result The vector3 that the world position should be copied to
  95103. */
  95104. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95105. /**
  95106. * Get the local position of a point that is in world space
  95107. * @param position The world position
  95108. * @param mesh The mesh that this bone is attached to
  95109. * @returns The local position
  95110. */
  95111. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95112. /**
  95113. * Get the local position of a point that is in world space and copy it to the result param
  95114. * @param position The world position
  95115. * @param mesh The mesh that this bone is attached to
  95116. * @param result The vector3 that the local position should be copied to
  95117. */
  95118. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95119. }
  95120. }
  95121. declare module BABYLON {
  95122. /**
  95123. * Defines a runtime animation
  95124. */
  95125. export class RuntimeAnimation {
  95126. private _events;
  95127. /**
  95128. * The current frame of the runtime animation
  95129. */
  95130. private _currentFrame;
  95131. /**
  95132. * The animation used by the runtime animation
  95133. */
  95134. private _animation;
  95135. /**
  95136. * The target of the runtime animation
  95137. */
  95138. private _target;
  95139. /**
  95140. * The initiating animatable
  95141. */
  95142. private _host;
  95143. /**
  95144. * The original value of the runtime animation
  95145. */
  95146. private _originalValue;
  95147. /**
  95148. * The original blend value of the runtime animation
  95149. */
  95150. private _originalBlendValue;
  95151. /**
  95152. * The offsets cache of the runtime animation
  95153. */
  95154. private _offsetsCache;
  95155. /**
  95156. * The high limits cache of the runtime animation
  95157. */
  95158. private _highLimitsCache;
  95159. /**
  95160. * Specifies if the runtime animation has been stopped
  95161. */
  95162. private _stopped;
  95163. /**
  95164. * The blending factor of the runtime animation
  95165. */
  95166. private _blendingFactor;
  95167. /**
  95168. * The BabylonJS scene
  95169. */
  95170. private _scene;
  95171. /**
  95172. * The current value of the runtime animation
  95173. */
  95174. private _currentValue;
  95175. /** @hidden */
  95176. _animationState: _IAnimationState;
  95177. /**
  95178. * The active target of the runtime animation
  95179. */
  95180. private _activeTargets;
  95181. private _currentActiveTarget;
  95182. private _directTarget;
  95183. /**
  95184. * The target path of the runtime animation
  95185. */
  95186. private _targetPath;
  95187. /**
  95188. * The weight of the runtime animation
  95189. */
  95190. private _weight;
  95191. /**
  95192. * The ratio offset of the runtime animation
  95193. */
  95194. private _ratioOffset;
  95195. /**
  95196. * The previous delay of the runtime animation
  95197. */
  95198. private _previousDelay;
  95199. /**
  95200. * The previous ratio of the runtime animation
  95201. */
  95202. private _previousRatio;
  95203. private _enableBlending;
  95204. private _keys;
  95205. private _minFrame;
  95206. private _maxFrame;
  95207. private _minValue;
  95208. private _maxValue;
  95209. private _targetIsArray;
  95210. /**
  95211. * Gets the current frame of the runtime animation
  95212. */
  95213. get currentFrame(): number;
  95214. /**
  95215. * Gets the weight of the runtime animation
  95216. */
  95217. get weight(): number;
  95218. /**
  95219. * Gets the current value of the runtime animation
  95220. */
  95221. get currentValue(): any;
  95222. /**
  95223. * Gets the target path of the runtime animation
  95224. */
  95225. get targetPath(): string;
  95226. /**
  95227. * Gets the actual target of the runtime animation
  95228. */
  95229. get target(): any;
  95230. /**
  95231. * Gets the additive state of the runtime animation
  95232. */
  95233. get isAdditive(): boolean;
  95234. /** @hidden */
  95235. _onLoop: () => void;
  95236. /**
  95237. * Create a new RuntimeAnimation object
  95238. * @param target defines the target of the animation
  95239. * @param animation defines the source animation object
  95240. * @param scene defines the hosting scene
  95241. * @param host defines the initiating Animatable
  95242. */
  95243. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  95244. private _preparePath;
  95245. /**
  95246. * Gets the animation from the runtime animation
  95247. */
  95248. get animation(): Animation;
  95249. /**
  95250. * Resets the runtime animation to the beginning
  95251. * @param restoreOriginal defines whether to restore the target property to the original value
  95252. */
  95253. reset(restoreOriginal?: boolean): void;
  95254. /**
  95255. * Specifies if the runtime animation is stopped
  95256. * @returns Boolean specifying if the runtime animation is stopped
  95257. */
  95258. isStopped(): boolean;
  95259. /**
  95260. * Disposes of the runtime animation
  95261. */
  95262. dispose(): void;
  95263. /**
  95264. * Apply the interpolated value to the target
  95265. * @param currentValue defines the value computed by the animation
  95266. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  95267. */
  95268. setValue(currentValue: any, weight: number): void;
  95269. private _getOriginalValues;
  95270. private _setValue;
  95271. /**
  95272. * Gets the loop pmode of the runtime animation
  95273. * @returns Loop Mode
  95274. */
  95275. private _getCorrectLoopMode;
  95276. /**
  95277. * Move the current animation to a given frame
  95278. * @param frame defines the frame to move to
  95279. */
  95280. goToFrame(frame: number): void;
  95281. /**
  95282. * @hidden Internal use only
  95283. */
  95284. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  95285. /**
  95286. * Execute the current animation
  95287. * @param delay defines the delay to add to the current frame
  95288. * @param from defines the lower bound of the animation range
  95289. * @param to defines the upper bound of the animation range
  95290. * @param loop defines if the current animation must loop
  95291. * @param speedRatio defines the current speed ratio
  95292. * @param weight defines the weight of the animation (default is -1 so no weight)
  95293. * @param onLoop optional callback called when animation loops
  95294. * @returns a boolean indicating if the animation is running
  95295. */
  95296. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  95297. }
  95298. }
  95299. declare module BABYLON {
  95300. /**
  95301. * Class used to store an actual running animation
  95302. */
  95303. export class Animatable {
  95304. /** defines the target object */
  95305. target: any;
  95306. /** defines the starting frame number (default is 0) */
  95307. fromFrame: number;
  95308. /** defines the ending frame number (default is 100) */
  95309. toFrame: number;
  95310. /** defines if the animation must loop (default is false) */
  95311. loopAnimation: boolean;
  95312. /** defines a callback to call when animation ends if it is not looping */
  95313. onAnimationEnd?: (() => void) | null | undefined;
  95314. /** defines a callback to call when animation loops */
  95315. onAnimationLoop?: (() => void) | null | undefined;
  95316. /** defines whether the animation should be evaluated additively */
  95317. isAdditive: boolean;
  95318. private _localDelayOffset;
  95319. private _pausedDelay;
  95320. private _runtimeAnimations;
  95321. private _paused;
  95322. private _scene;
  95323. private _speedRatio;
  95324. private _weight;
  95325. private _syncRoot;
  95326. /**
  95327. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  95328. * This will only apply for non looping animation (default is true)
  95329. */
  95330. disposeOnEnd: boolean;
  95331. /**
  95332. * Gets a boolean indicating if the animation has started
  95333. */
  95334. animationStarted: boolean;
  95335. /**
  95336. * Observer raised when the animation ends
  95337. */
  95338. onAnimationEndObservable: Observable<Animatable>;
  95339. /**
  95340. * Observer raised when the animation loops
  95341. */
  95342. onAnimationLoopObservable: Observable<Animatable>;
  95343. /**
  95344. * Gets the root Animatable used to synchronize and normalize animations
  95345. */
  95346. get syncRoot(): Nullable<Animatable>;
  95347. /**
  95348. * Gets the current frame of the first RuntimeAnimation
  95349. * Used to synchronize Animatables
  95350. */
  95351. get masterFrame(): number;
  95352. /**
  95353. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  95354. */
  95355. get weight(): number;
  95356. set weight(value: number);
  95357. /**
  95358. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  95359. */
  95360. get speedRatio(): number;
  95361. set speedRatio(value: number);
  95362. /**
  95363. * Creates a new Animatable
  95364. * @param scene defines the hosting scene
  95365. * @param target defines the target object
  95366. * @param fromFrame defines the starting frame number (default is 0)
  95367. * @param toFrame defines the ending frame number (default is 100)
  95368. * @param loopAnimation defines if the animation must loop (default is false)
  95369. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  95370. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  95371. * @param animations defines a group of animation to add to the new Animatable
  95372. * @param onAnimationLoop defines a callback to call when animation loops
  95373. * @param isAdditive defines whether the animation should be evaluated additively
  95374. */
  95375. constructor(scene: Scene,
  95376. /** defines the target object */
  95377. target: any,
  95378. /** defines the starting frame number (default is 0) */
  95379. fromFrame?: number,
  95380. /** defines the ending frame number (default is 100) */
  95381. toFrame?: number,
  95382. /** defines if the animation must loop (default is false) */
  95383. loopAnimation?: boolean, speedRatio?: number,
  95384. /** defines a callback to call when animation ends if it is not looping */
  95385. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  95386. /** defines a callback to call when animation loops */
  95387. onAnimationLoop?: (() => void) | null | undefined,
  95388. /** defines whether the animation should be evaluated additively */
  95389. isAdditive?: boolean);
  95390. /**
  95391. * Synchronize and normalize current Animatable with a source Animatable
  95392. * This is useful when using animation weights and when animations are not of the same length
  95393. * @param root defines the root Animatable to synchronize with
  95394. * @returns the current Animatable
  95395. */
  95396. syncWith(root: Animatable): Animatable;
  95397. /**
  95398. * Gets the list of runtime animations
  95399. * @returns an array of RuntimeAnimation
  95400. */
  95401. getAnimations(): RuntimeAnimation[];
  95402. /**
  95403. * Adds more animations to the current animatable
  95404. * @param target defines the target of the animations
  95405. * @param animations defines the new animations to add
  95406. */
  95407. appendAnimations(target: any, animations: Animation[]): void;
  95408. /**
  95409. * Gets the source animation for a specific property
  95410. * @param property defines the propertyu to look for
  95411. * @returns null or the source animation for the given property
  95412. */
  95413. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  95414. /**
  95415. * Gets the runtime animation for a specific property
  95416. * @param property defines the propertyu to look for
  95417. * @returns null or the runtime animation for the given property
  95418. */
  95419. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  95420. /**
  95421. * Resets the animatable to its original state
  95422. */
  95423. reset(): void;
  95424. /**
  95425. * Allows the animatable to blend with current running animations
  95426. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95427. * @param blendingSpeed defines the blending speed to use
  95428. */
  95429. enableBlending(blendingSpeed: number): void;
  95430. /**
  95431. * Disable animation blending
  95432. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95433. */
  95434. disableBlending(): void;
  95435. /**
  95436. * Jump directly to a given frame
  95437. * @param frame defines the frame to jump to
  95438. */
  95439. goToFrame(frame: number): void;
  95440. /**
  95441. * Pause the animation
  95442. */
  95443. pause(): void;
  95444. /**
  95445. * Restart the animation
  95446. */
  95447. restart(): void;
  95448. private _raiseOnAnimationEnd;
  95449. /**
  95450. * Stop and delete the current animation
  95451. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  95452. * @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)
  95453. */
  95454. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  95455. /**
  95456. * Wait asynchronously for the animation to end
  95457. * @returns a promise which will be fullfilled when the animation ends
  95458. */
  95459. waitAsync(): Promise<Animatable>;
  95460. /** @hidden */
  95461. _animate(delay: number): boolean;
  95462. }
  95463. interface Scene {
  95464. /** @hidden */
  95465. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  95466. /** @hidden */
  95467. _processLateAnimationBindingsForMatrices(holder: {
  95468. totalWeight: number;
  95469. totalAdditiveWeight: number;
  95470. animations: RuntimeAnimation[];
  95471. additiveAnimations: RuntimeAnimation[];
  95472. originalValue: Matrix;
  95473. }): any;
  95474. /** @hidden */
  95475. _processLateAnimationBindingsForQuaternions(holder: {
  95476. totalWeight: number;
  95477. totalAdditiveWeight: number;
  95478. animations: RuntimeAnimation[];
  95479. additiveAnimations: RuntimeAnimation[];
  95480. originalValue: Quaternion;
  95481. }, refQuaternion: Quaternion): Quaternion;
  95482. /** @hidden */
  95483. _processLateAnimationBindings(): void;
  95484. /**
  95485. * Will start the animation sequence of a given target
  95486. * @param target defines the target
  95487. * @param from defines from which frame should animation start
  95488. * @param to defines until which frame should animation run.
  95489. * @param weight defines the weight to apply to the animation (1.0 by default)
  95490. * @param loop defines if the animation loops
  95491. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95492. * @param onAnimationEnd defines the function to be executed when the animation ends
  95493. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95494. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  95495. * @param onAnimationLoop defines the callback to call when an animation loops
  95496. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95497. * @returns the animatable object created for this animation
  95498. */
  95499. 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;
  95500. /**
  95501. * Will start the animation sequence of a given target
  95502. * @param target defines the target
  95503. * @param from defines from which frame should animation start
  95504. * @param to defines until which frame should animation run.
  95505. * @param loop defines if the animation loops
  95506. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95507. * @param onAnimationEnd defines the function to be executed when the animation ends
  95508. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95509. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  95510. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  95511. * @param onAnimationLoop defines the callback to call when an animation loops
  95512. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95513. * @returns the animatable object created for this animation
  95514. */
  95515. 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;
  95516. /**
  95517. * Will start the animation sequence of a given target and its hierarchy
  95518. * @param target defines the target
  95519. * @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.
  95520. * @param from defines from which frame should animation start
  95521. * @param to defines until which frame should animation run.
  95522. * @param loop defines if the animation loops
  95523. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95524. * @param onAnimationEnd defines the function to be executed when the animation ends
  95525. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95526. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  95527. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  95528. * @param onAnimationLoop defines the callback to call when an animation loops
  95529. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95530. * @returns the list of created animatables
  95531. */
  95532. 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[];
  95533. /**
  95534. * Begin a new animation on a given node
  95535. * @param target defines the target where the animation will take place
  95536. * @param animations defines the list of animations to start
  95537. * @param from defines the initial value
  95538. * @param to defines the final value
  95539. * @param loop defines if you want animation to loop (off by default)
  95540. * @param speedRatio defines the speed ratio to apply to all animations
  95541. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95542. * @param onAnimationLoop defines the callback to call when an animation loops
  95543. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95544. * @returns the list of created animatables
  95545. */
  95546. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  95547. /**
  95548. * Begin a new animation on a given node and its hierarchy
  95549. * @param target defines the root node where the animation will take place
  95550. * @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.
  95551. * @param animations defines the list of animations to start
  95552. * @param from defines the initial value
  95553. * @param to defines the final value
  95554. * @param loop defines if you want animation to loop (off by default)
  95555. * @param speedRatio defines the speed ratio to apply to all animations
  95556. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95557. * @param onAnimationLoop defines the callback to call when an animation loops
  95558. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95559. * @returns the list of animatables created for all nodes
  95560. */
  95561. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  95562. /**
  95563. * Gets the animatable associated with a specific target
  95564. * @param target defines the target of the animatable
  95565. * @returns the required animatable if found
  95566. */
  95567. getAnimatableByTarget(target: any): Nullable<Animatable>;
  95568. /**
  95569. * Gets all animatables associated with a given target
  95570. * @param target defines the target to look animatables for
  95571. * @returns an array of Animatables
  95572. */
  95573. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  95574. /**
  95575. * Stops and removes all animations that have been applied to the scene
  95576. */
  95577. stopAllAnimations(): void;
  95578. /**
  95579. * Gets the current delta time used by animation engine
  95580. */
  95581. deltaTime: number;
  95582. }
  95583. interface Bone {
  95584. /**
  95585. * Copy an animation range from another bone
  95586. * @param source defines the source bone
  95587. * @param rangeName defines the range name to copy
  95588. * @param frameOffset defines the frame offset
  95589. * @param rescaleAsRequired defines if rescaling must be applied if required
  95590. * @param skelDimensionsRatio defines the scaling ratio
  95591. * @returns true if operation was successful
  95592. */
  95593. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  95594. }
  95595. }
  95596. declare module BABYLON {
  95597. /**
  95598. * Class used to handle skinning animations
  95599. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95600. */
  95601. export class Skeleton implements IAnimatable {
  95602. /** defines the skeleton name */
  95603. name: string;
  95604. /** defines the skeleton Id */
  95605. id: string;
  95606. /**
  95607. * Defines the list of child bones
  95608. */
  95609. bones: Bone[];
  95610. /**
  95611. * Defines an estimate of the dimension of the skeleton at rest
  95612. */
  95613. dimensionsAtRest: Vector3;
  95614. /**
  95615. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  95616. */
  95617. needInitialSkinMatrix: boolean;
  95618. /**
  95619. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  95620. */
  95621. overrideMesh: Nullable<AbstractMesh>;
  95622. /**
  95623. * Gets the list of animations attached to this skeleton
  95624. */
  95625. animations: Array<Animation>;
  95626. private _scene;
  95627. private _isDirty;
  95628. private _transformMatrices;
  95629. private _transformMatrixTexture;
  95630. private _meshesWithPoseMatrix;
  95631. private _animatables;
  95632. private _identity;
  95633. private _synchronizedWithMesh;
  95634. private _ranges;
  95635. private _lastAbsoluteTransformsUpdateId;
  95636. private _canUseTextureForBones;
  95637. private _uniqueId;
  95638. /** @hidden */
  95639. _numBonesWithLinkedTransformNode: number;
  95640. /** @hidden */
  95641. _hasWaitingData: Nullable<boolean>;
  95642. /**
  95643. * Specifies if the skeleton should be serialized
  95644. */
  95645. doNotSerialize: boolean;
  95646. private _useTextureToStoreBoneMatrices;
  95647. /**
  95648. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  95649. * Please note that this option is not available if the hardware does not support it
  95650. */
  95651. get useTextureToStoreBoneMatrices(): boolean;
  95652. set useTextureToStoreBoneMatrices(value: boolean);
  95653. private _animationPropertiesOverride;
  95654. /**
  95655. * Gets or sets the animation properties override
  95656. */
  95657. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95658. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95659. /**
  95660. * List of inspectable custom properties (used by the Inspector)
  95661. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95662. */
  95663. inspectableCustomProperties: IInspectable[];
  95664. /**
  95665. * An observable triggered before computing the skeleton's matrices
  95666. */
  95667. onBeforeComputeObservable: Observable<Skeleton>;
  95668. /**
  95669. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  95670. */
  95671. get isUsingTextureForMatrices(): boolean;
  95672. /**
  95673. * Gets the unique ID of this skeleton
  95674. */
  95675. get uniqueId(): number;
  95676. /**
  95677. * Creates a new skeleton
  95678. * @param name defines the skeleton name
  95679. * @param id defines the skeleton Id
  95680. * @param scene defines the hosting scene
  95681. */
  95682. constructor(
  95683. /** defines the skeleton name */
  95684. name: string,
  95685. /** defines the skeleton Id */
  95686. id: string, scene: Scene);
  95687. /**
  95688. * Gets the current object class name.
  95689. * @return the class name
  95690. */
  95691. getClassName(): string;
  95692. /**
  95693. * Returns an array containing the root bones
  95694. * @returns an array containing the root bones
  95695. */
  95696. getChildren(): Array<Bone>;
  95697. /**
  95698. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  95699. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  95700. * @returns a Float32Array containing matrices data
  95701. */
  95702. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  95703. /**
  95704. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  95705. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  95706. * @returns a raw texture containing the data
  95707. */
  95708. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  95709. /**
  95710. * Gets the current hosting scene
  95711. * @returns a scene object
  95712. */
  95713. getScene(): Scene;
  95714. /**
  95715. * Gets a string representing the current skeleton data
  95716. * @param fullDetails defines a boolean indicating if we want a verbose version
  95717. * @returns a string representing the current skeleton data
  95718. */
  95719. toString(fullDetails?: boolean): string;
  95720. /**
  95721. * Get bone's index searching by name
  95722. * @param name defines bone's name to search for
  95723. * @return the indice of the bone. Returns -1 if not found
  95724. */
  95725. getBoneIndexByName(name: string): number;
  95726. /**
  95727. * Creater a new animation range
  95728. * @param name defines the name of the range
  95729. * @param from defines the start key
  95730. * @param to defines the end key
  95731. */
  95732. createAnimationRange(name: string, from: number, to: number): void;
  95733. /**
  95734. * Delete a specific animation range
  95735. * @param name defines the name of the range
  95736. * @param deleteFrames defines if frames must be removed as well
  95737. */
  95738. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95739. /**
  95740. * Gets a specific animation range
  95741. * @param name defines the name of the range to look for
  95742. * @returns the requested animation range or null if not found
  95743. */
  95744. getAnimationRange(name: string): Nullable<AnimationRange>;
  95745. /**
  95746. * Gets the list of all animation ranges defined on this skeleton
  95747. * @returns an array
  95748. */
  95749. getAnimationRanges(): Nullable<AnimationRange>[];
  95750. /**
  95751. * Copy animation range from a source skeleton.
  95752. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  95753. * @param source defines the source skeleton
  95754. * @param name defines the name of the range to copy
  95755. * @param rescaleAsRequired defines if rescaling must be applied if required
  95756. * @returns true if operation was successful
  95757. */
  95758. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  95759. /**
  95760. * Forces the skeleton to go to rest pose
  95761. */
  95762. returnToRest(): void;
  95763. private _getHighestAnimationFrame;
  95764. /**
  95765. * Begin a specific animation range
  95766. * @param name defines the name of the range to start
  95767. * @param loop defines if looping must be turned on (false by default)
  95768. * @param speedRatio defines the speed ratio to apply (1 by default)
  95769. * @param onAnimationEnd defines a callback which will be called when animation will end
  95770. * @returns a new animatable
  95771. */
  95772. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95773. /**
  95774. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  95775. * @param skeleton defines the Skeleton containing the animation range to convert
  95776. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  95777. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  95778. * @returns the original skeleton
  95779. */
  95780. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  95781. /** @hidden */
  95782. _markAsDirty(): void;
  95783. /** @hidden */
  95784. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  95785. /** @hidden */
  95786. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  95787. private _computeTransformMatrices;
  95788. /**
  95789. * Build all resources required to render a skeleton
  95790. */
  95791. prepare(): void;
  95792. /**
  95793. * Gets the list of animatables currently running for this skeleton
  95794. * @returns an array of animatables
  95795. */
  95796. getAnimatables(): IAnimatable[];
  95797. /**
  95798. * Clone the current skeleton
  95799. * @param name defines the name of the new skeleton
  95800. * @param id defines the id of the new skeleton
  95801. * @returns the new skeleton
  95802. */
  95803. clone(name: string, id?: string): Skeleton;
  95804. /**
  95805. * Enable animation blending for this skeleton
  95806. * @param blendingSpeed defines the blending speed to apply
  95807. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95808. */
  95809. enableBlending(blendingSpeed?: number): void;
  95810. /**
  95811. * Releases all resources associated with the current skeleton
  95812. */
  95813. dispose(): void;
  95814. /**
  95815. * Serialize the skeleton in a JSON object
  95816. * @returns a JSON object
  95817. */
  95818. serialize(): any;
  95819. /**
  95820. * Creates a new skeleton from serialized data
  95821. * @param parsedSkeleton defines the serialized data
  95822. * @param scene defines the hosting scene
  95823. * @returns a new skeleton
  95824. */
  95825. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  95826. /**
  95827. * Compute all node absolute transforms
  95828. * @param forceUpdate defines if computation must be done even if cache is up to date
  95829. */
  95830. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  95831. /**
  95832. * Gets the root pose matrix
  95833. * @returns a matrix
  95834. */
  95835. getPoseMatrix(): Nullable<Matrix>;
  95836. /**
  95837. * Sorts bones per internal index
  95838. */
  95839. sortBones(): void;
  95840. private _sortBones;
  95841. }
  95842. }
  95843. declare module BABYLON {
  95844. /**
  95845. * Creates an instance based on a source mesh.
  95846. */
  95847. export class InstancedMesh extends AbstractMesh {
  95848. private _sourceMesh;
  95849. private _currentLOD;
  95850. /** @hidden */
  95851. _indexInSourceMeshInstanceArray: number;
  95852. constructor(name: string, source: Mesh);
  95853. /**
  95854. * Returns the string "InstancedMesh".
  95855. */
  95856. getClassName(): string;
  95857. /** Gets the list of lights affecting that mesh */
  95858. get lightSources(): Light[];
  95859. _resyncLightSources(): void;
  95860. _resyncLightSource(light: Light): void;
  95861. _removeLightSource(light: Light, dispose: boolean): void;
  95862. /**
  95863. * If the source mesh receives shadows
  95864. */
  95865. get receiveShadows(): boolean;
  95866. /**
  95867. * The material of the source mesh
  95868. */
  95869. get material(): Nullable<Material>;
  95870. /**
  95871. * Visibility of the source mesh
  95872. */
  95873. get visibility(): number;
  95874. /**
  95875. * Skeleton of the source mesh
  95876. */
  95877. get skeleton(): Nullable<Skeleton>;
  95878. /**
  95879. * Rendering ground id of the source mesh
  95880. */
  95881. get renderingGroupId(): number;
  95882. set renderingGroupId(value: number);
  95883. /**
  95884. * Returns the total number of vertices (integer).
  95885. */
  95886. getTotalVertices(): number;
  95887. /**
  95888. * Returns a positive integer : the total number of indices in this mesh geometry.
  95889. * @returns the numner of indices or zero if the mesh has no geometry.
  95890. */
  95891. getTotalIndices(): number;
  95892. /**
  95893. * The source mesh of the instance
  95894. */
  95895. get sourceMesh(): Mesh;
  95896. /**
  95897. * Creates a new InstancedMesh object from the mesh model.
  95898. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95899. * @param name defines the name of the new instance
  95900. * @returns a new InstancedMesh
  95901. */
  95902. createInstance(name: string): InstancedMesh;
  95903. /**
  95904. * Is this node ready to be used/rendered
  95905. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95906. * @return {boolean} is it ready
  95907. */
  95908. isReady(completeCheck?: boolean): boolean;
  95909. /**
  95910. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95911. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  95912. * @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.
  95913. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  95914. */
  95915. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  95916. /**
  95917. * Sets the vertex data of the mesh geometry for the requested `kind`.
  95918. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  95919. * The `data` are either a numeric array either a Float32Array.
  95920. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  95921. * 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).
  95922. * Note that a new underlying VertexBuffer object is created each call.
  95923. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  95924. *
  95925. * Possible `kind` values :
  95926. * - VertexBuffer.PositionKind
  95927. * - VertexBuffer.UVKind
  95928. * - VertexBuffer.UV2Kind
  95929. * - VertexBuffer.UV3Kind
  95930. * - VertexBuffer.UV4Kind
  95931. * - VertexBuffer.UV5Kind
  95932. * - VertexBuffer.UV6Kind
  95933. * - VertexBuffer.ColorKind
  95934. * - VertexBuffer.MatricesIndicesKind
  95935. * - VertexBuffer.MatricesIndicesExtraKind
  95936. * - VertexBuffer.MatricesWeightsKind
  95937. * - VertexBuffer.MatricesWeightsExtraKind
  95938. *
  95939. * Returns the Mesh.
  95940. */
  95941. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95942. /**
  95943. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  95944. * If the mesh has no geometry, it is simply returned as it is.
  95945. * The `data` are either a numeric array either a Float32Array.
  95946. * No new underlying VertexBuffer object is created.
  95947. * 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.
  95948. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  95949. *
  95950. * Possible `kind` values :
  95951. * - VertexBuffer.PositionKind
  95952. * - VertexBuffer.UVKind
  95953. * - VertexBuffer.UV2Kind
  95954. * - VertexBuffer.UV3Kind
  95955. * - VertexBuffer.UV4Kind
  95956. * - VertexBuffer.UV5Kind
  95957. * - VertexBuffer.UV6Kind
  95958. * - VertexBuffer.ColorKind
  95959. * - VertexBuffer.MatricesIndicesKind
  95960. * - VertexBuffer.MatricesIndicesExtraKind
  95961. * - VertexBuffer.MatricesWeightsKind
  95962. * - VertexBuffer.MatricesWeightsExtraKind
  95963. *
  95964. * Returns the Mesh.
  95965. */
  95966. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  95967. /**
  95968. * Sets the mesh indices.
  95969. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  95970. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  95971. * This method creates a new index buffer each call.
  95972. * Returns the Mesh.
  95973. */
  95974. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  95975. /**
  95976. * Boolean : True if the mesh owns the requested kind of data.
  95977. */
  95978. isVerticesDataPresent(kind: string): boolean;
  95979. /**
  95980. * Returns an array of indices (IndicesArray).
  95981. */
  95982. getIndices(): Nullable<IndicesArray>;
  95983. get _positions(): Nullable<Vector3[]>;
  95984. /**
  95985. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95986. * This means the mesh underlying bounding box and sphere are recomputed.
  95987. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95988. * @returns the current mesh
  95989. */
  95990. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  95991. /** @hidden */
  95992. _preActivate(): InstancedMesh;
  95993. /** @hidden */
  95994. _activate(renderId: number, intermediateRendering: boolean): boolean;
  95995. /** @hidden */
  95996. _postActivate(): void;
  95997. getWorldMatrix(): Matrix;
  95998. get isAnInstance(): boolean;
  95999. /**
  96000. * Returns the current associated LOD AbstractMesh.
  96001. */
  96002. getLOD(camera: Camera): AbstractMesh;
  96003. /** @hidden */
  96004. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96005. /** @hidden */
  96006. _syncSubMeshes(): InstancedMesh;
  96007. /** @hidden */
  96008. _generatePointsArray(): boolean;
  96009. /** @hidden */
  96010. _updateBoundingInfo(): AbstractMesh;
  96011. /**
  96012. * Creates a new InstancedMesh from the current mesh.
  96013. * - name (string) : the cloned mesh name
  96014. * - newParent (optional Node) : the optional Node to parent the clone to.
  96015. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  96016. *
  96017. * Returns the clone.
  96018. */
  96019. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  96020. /**
  96021. * Disposes the InstancedMesh.
  96022. * Returns nothing.
  96023. */
  96024. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96025. }
  96026. interface Mesh {
  96027. /**
  96028. * Register a custom buffer that will be instanced
  96029. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96030. * @param kind defines the buffer kind
  96031. * @param stride defines the stride in floats
  96032. */
  96033. registerInstancedBuffer(kind: string, stride: number): void;
  96034. /**
  96035. * true to use the edge renderer for all instances of this mesh
  96036. */
  96037. edgesShareWithInstances: boolean;
  96038. /** @hidden */
  96039. _userInstancedBuffersStorage: {
  96040. data: {
  96041. [key: string]: Float32Array;
  96042. };
  96043. sizes: {
  96044. [key: string]: number;
  96045. };
  96046. vertexBuffers: {
  96047. [key: string]: Nullable<VertexBuffer>;
  96048. };
  96049. strides: {
  96050. [key: string]: number;
  96051. };
  96052. };
  96053. }
  96054. interface AbstractMesh {
  96055. /**
  96056. * Object used to store instanced buffers defined by user
  96057. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96058. */
  96059. instancedBuffers: {
  96060. [key: string]: any;
  96061. };
  96062. }
  96063. }
  96064. declare module BABYLON {
  96065. /**
  96066. * Defines the options associated with the creation of a shader material.
  96067. */
  96068. export interface IShaderMaterialOptions {
  96069. /**
  96070. * Does the material work in alpha blend mode
  96071. */
  96072. needAlphaBlending: boolean;
  96073. /**
  96074. * Does the material work in alpha test mode
  96075. */
  96076. needAlphaTesting: boolean;
  96077. /**
  96078. * The list of attribute names used in the shader
  96079. */
  96080. attributes: string[];
  96081. /**
  96082. * The list of unifrom names used in the shader
  96083. */
  96084. uniforms: string[];
  96085. /**
  96086. * The list of UBO names used in the shader
  96087. */
  96088. uniformBuffers: string[];
  96089. /**
  96090. * The list of sampler names used in the shader
  96091. */
  96092. samplers: string[];
  96093. /**
  96094. * The list of defines used in the shader
  96095. */
  96096. defines: string[];
  96097. }
  96098. /**
  96099. * 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.
  96100. *
  96101. * This returned material effects how the mesh will look based on the code in the shaders.
  96102. *
  96103. * @see https://doc.babylonjs.com/how_to/shader_material
  96104. */
  96105. export class ShaderMaterial extends Material {
  96106. private _shaderPath;
  96107. private _options;
  96108. private _textures;
  96109. private _textureArrays;
  96110. private _floats;
  96111. private _ints;
  96112. private _floatsArrays;
  96113. private _colors3;
  96114. private _colors3Arrays;
  96115. private _colors4;
  96116. private _colors4Arrays;
  96117. private _vectors2;
  96118. private _vectors3;
  96119. private _vectors4;
  96120. private _matrices;
  96121. private _matrixArrays;
  96122. private _matrices3x3;
  96123. private _matrices2x2;
  96124. private _vectors2Arrays;
  96125. private _vectors3Arrays;
  96126. private _vectors4Arrays;
  96127. private _cachedWorldViewMatrix;
  96128. private _cachedWorldViewProjectionMatrix;
  96129. private _renderId;
  96130. private _multiview;
  96131. private _cachedDefines;
  96132. /** Define the Url to load snippets */
  96133. static SnippetUrl: string;
  96134. /** Snippet ID if the material was created from the snippet server */
  96135. snippetId: string;
  96136. /**
  96137. * Instantiate a new shader material.
  96138. * 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.
  96139. * This returned material effects how the mesh will look based on the code in the shaders.
  96140. * @see https://doc.babylonjs.com/how_to/shader_material
  96141. * @param name Define the name of the material in the scene
  96142. * @param scene Define the scene the material belongs to
  96143. * @param shaderPath Defines the route to the shader code in one of three ways:
  96144. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  96145. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  96146. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  96147. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  96148. * @param options Define the options used to create the shader
  96149. */
  96150. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  96151. /**
  96152. * Gets the shader path used to define the shader code
  96153. * It can be modified to trigger a new compilation
  96154. */
  96155. get shaderPath(): any;
  96156. /**
  96157. * Sets the shader path used to define the shader code
  96158. * It can be modified to trigger a new compilation
  96159. */
  96160. set shaderPath(shaderPath: any);
  96161. /**
  96162. * Gets the options used to compile the shader.
  96163. * They can be modified to trigger a new compilation
  96164. */
  96165. get options(): IShaderMaterialOptions;
  96166. /**
  96167. * Gets the current class name of the material e.g. "ShaderMaterial"
  96168. * Mainly use in serialization.
  96169. * @returns the class name
  96170. */
  96171. getClassName(): string;
  96172. /**
  96173. * Specifies if the material will require alpha blending
  96174. * @returns a boolean specifying if alpha blending is needed
  96175. */
  96176. needAlphaBlending(): boolean;
  96177. /**
  96178. * Specifies if this material should be rendered in alpha test mode
  96179. * @returns a boolean specifying if an alpha test is needed.
  96180. */
  96181. needAlphaTesting(): boolean;
  96182. private _checkUniform;
  96183. /**
  96184. * Set a texture in the shader.
  96185. * @param name Define the name of the uniform samplers as defined in the shader
  96186. * @param texture Define the texture to bind to this sampler
  96187. * @return the material itself allowing "fluent" like uniform updates
  96188. */
  96189. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  96190. /**
  96191. * Set a texture array in the shader.
  96192. * @param name Define the name of the uniform sampler array as defined in the shader
  96193. * @param textures Define the list of textures to bind to this sampler
  96194. * @return the material itself allowing "fluent" like uniform updates
  96195. */
  96196. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  96197. /**
  96198. * Set a float in the shader.
  96199. * @param name Define the name of the uniform as defined in the shader
  96200. * @param value Define the value to give to the uniform
  96201. * @return the material itself allowing "fluent" like uniform updates
  96202. */
  96203. setFloat(name: string, value: number): ShaderMaterial;
  96204. /**
  96205. * Set a int in the shader.
  96206. * @param name Define the name of the uniform as defined in the shader
  96207. * @param value Define the value to give to the uniform
  96208. * @return the material itself allowing "fluent" like uniform updates
  96209. */
  96210. setInt(name: string, value: number): ShaderMaterial;
  96211. /**
  96212. * Set an array of floats in the shader.
  96213. * @param name Define the name of the uniform as defined in the shader
  96214. * @param value Define the value to give to the uniform
  96215. * @return the material itself allowing "fluent" like uniform updates
  96216. */
  96217. setFloats(name: string, value: number[]): ShaderMaterial;
  96218. /**
  96219. * Set a vec3 in the shader from a Color3.
  96220. * @param name Define the name of the uniform as defined in the shader
  96221. * @param value Define the value to give to the uniform
  96222. * @return the material itself allowing "fluent" like uniform updates
  96223. */
  96224. setColor3(name: string, value: Color3): ShaderMaterial;
  96225. /**
  96226. * Set a vec3 array in the shader from a Color3 array.
  96227. * @param name Define the name of the uniform as defined in the shader
  96228. * @param value Define the value to give to the uniform
  96229. * @return the material itself allowing "fluent" like uniform updates
  96230. */
  96231. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  96232. /**
  96233. * Set a vec4 in the shader from a Color4.
  96234. * @param name Define the name of the uniform as defined in the shader
  96235. * @param value Define the value to give to the uniform
  96236. * @return the material itself allowing "fluent" like uniform updates
  96237. */
  96238. setColor4(name: string, value: Color4): ShaderMaterial;
  96239. /**
  96240. * Set a vec4 array in the shader from a Color4 array.
  96241. * @param name Define the name of the uniform as defined in the shader
  96242. * @param value Define the value to give to the uniform
  96243. * @return the material itself allowing "fluent" like uniform updates
  96244. */
  96245. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  96246. /**
  96247. * Set a vec2 in the shader from a Vector2.
  96248. * @param name Define the name of the uniform as defined in the shader
  96249. * @param value Define the value to give to the uniform
  96250. * @return the material itself allowing "fluent" like uniform updates
  96251. */
  96252. setVector2(name: string, value: Vector2): ShaderMaterial;
  96253. /**
  96254. * Set a vec3 in the shader from a Vector3.
  96255. * @param name Define the name of the uniform as defined in the shader
  96256. * @param value Define the value to give to the uniform
  96257. * @return the material itself allowing "fluent" like uniform updates
  96258. */
  96259. setVector3(name: string, value: Vector3): ShaderMaterial;
  96260. /**
  96261. * Set a vec4 in the shader from a Vector4.
  96262. * @param name Define the name of the uniform as defined in the shader
  96263. * @param value Define the value to give to the uniform
  96264. * @return the material itself allowing "fluent" like uniform updates
  96265. */
  96266. setVector4(name: string, value: Vector4): ShaderMaterial;
  96267. /**
  96268. * Set a mat4 in the shader from a Matrix.
  96269. * @param name Define the name of the uniform as defined in the shader
  96270. * @param value Define the value to give to the uniform
  96271. * @return the material itself allowing "fluent" like uniform updates
  96272. */
  96273. setMatrix(name: string, value: Matrix): ShaderMaterial;
  96274. /**
  96275. * Set a float32Array in the shader from a matrix array.
  96276. * @param name Define the name of the uniform as defined in the shader
  96277. * @param value Define the value to give to the uniform
  96278. * @return the material itself allowing "fluent" like uniform updates
  96279. */
  96280. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  96281. /**
  96282. * Set a mat3 in the shader from a Float32Array.
  96283. * @param name Define the name of the uniform as defined in the shader
  96284. * @param value Define the value to give to the uniform
  96285. * @return the material itself allowing "fluent" like uniform updates
  96286. */
  96287. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  96288. /**
  96289. * Set a mat2 in the shader from a Float32Array.
  96290. * @param name Define the name of the uniform as defined in the shader
  96291. * @param value Define the value to give to the uniform
  96292. * @return the material itself allowing "fluent" like uniform updates
  96293. */
  96294. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  96295. /**
  96296. * Set a vec2 array in the shader from a number array.
  96297. * @param name Define the name of the uniform as defined in the shader
  96298. * @param value Define the value to give to the uniform
  96299. * @return the material itself allowing "fluent" like uniform updates
  96300. */
  96301. setArray2(name: string, value: number[]): ShaderMaterial;
  96302. /**
  96303. * Set a vec3 array in the shader from a number array.
  96304. * @param name Define the name of the uniform as defined in the shader
  96305. * @param value Define the value to give to the uniform
  96306. * @return the material itself allowing "fluent" like uniform updates
  96307. */
  96308. setArray3(name: string, value: number[]): ShaderMaterial;
  96309. /**
  96310. * Set a vec4 array in the shader from a number array.
  96311. * @param name Define the name of the uniform as defined in the shader
  96312. * @param value Define the value to give to the uniform
  96313. * @return the material itself allowing "fluent" like uniform updates
  96314. */
  96315. setArray4(name: string, value: number[]): ShaderMaterial;
  96316. private _checkCache;
  96317. /**
  96318. * Specifies that the submesh is ready to be used
  96319. * @param mesh defines the mesh to check
  96320. * @param subMesh defines which submesh to check
  96321. * @param useInstances specifies that instances should be used
  96322. * @returns a boolean indicating that the submesh is ready or not
  96323. */
  96324. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  96325. /**
  96326. * Checks if the material is ready to render the requested mesh
  96327. * @param mesh Define the mesh to render
  96328. * @param useInstances Define whether or not the material is used with instances
  96329. * @returns true if ready, otherwise false
  96330. */
  96331. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96332. /**
  96333. * Binds the world matrix to the material
  96334. * @param world defines the world transformation matrix
  96335. * @param effectOverride - If provided, use this effect instead of internal effect
  96336. */
  96337. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  96338. /**
  96339. * Binds the submesh to this material by preparing the effect and shader to draw
  96340. * @param world defines the world transformation matrix
  96341. * @param mesh defines the mesh containing the submesh
  96342. * @param subMesh defines the submesh to bind the material to
  96343. */
  96344. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  96345. /**
  96346. * Binds the material to the mesh
  96347. * @param world defines the world transformation matrix
  96348. * @param mesh defines the mesh to bind the material to
  96349. * @param effectOverride - If provided, use this effect instead of internal effect
  96350. */
  96351. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  96352. protected _afterBind(mesh?: Mesh): void;
  96353. /**
  96354. * Gets the active textures from the material
  96355. * @returns an array of textures
  96356. */
  96357. getActiveTextures(): BaseTexture[];
  96358. /**
  96359. * Specifies if the material uses a texture
  96360. * @param texture defines the texture to check against the material
  96361. * @returns a boolean specifying if the material uses the texture
  96362. */
  96363. hasTexture(texture: BaseTexture): boolean;
  96364. /**
  96365. * Makes a duplicate of the material, and gives it a new name
  96366. * @param name defines the new name for the duplicated material
  96367. * @returns the cloned material
  96368. */
  96369. clone(name: string): ShaderMaterial;
  96370. /**
  96371. * Disposes the material
  96372. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  96373. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  96374. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  96375. */
  96376. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  96377. /**
  96378. * Serializes this material in a JSON representation
  96379. * @returns the serialized material object
  96380. */
  96381. serialize(): any;
  96382. /**
  96383. * Creates a shader material from parsed shader material data
  96384. * @param source defines the JSON represnetation of the material
  96385. * @param scene defines the hosting scene
  96386. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96387. * @returns a new material
  96388. */
  96389. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  96390. /**
  96391. * Creates a new ShaderMaterial from a snippet saved in a remote file
  96392. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  96393. * @param url defines the url to load from
  96394. * @param scene defines the hosting scene
  96395. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96396. * @returns a promise that will resolve to the new ShaderMaterial
  96397. */
  96398. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  96399. /**
  96400. * Creates a ShaderMaterial from a snippet saved by the Inspector
  96401. * @param snippetId defines the snippet to load
  96402. * @param scene defines the hosting scene
  96403. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96404. * @returns a promise that will resolve to the new ShaderMaterial
  96405. */
  96406. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  96407. }
  96408. }
  96409. declare module BABYLON {
  96410. /** @hidden */
  96411. export var colorPixelShader: {
  96412. name: string;
  96413. shader: string;
  96414. };
  96415. }
  96416. declare module BABYLON {
  96417. /** @hidden */
  96418. export var colorVertexShader: {
  96419. name: string;
  96420. shader: string;
  96421. };
  96422. }
  96423. declare module BABYLON {
  96424. /**
  96425. * Line mesh
  96426. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  96427. */
  96428. export class LinesMesh extends Mesh {
  96429. /**
  96430. * If vertex color should be applied to the mesh
  96431. */
  96432. readonly useVertexColor?: boolean | undefined;
  96433. /**
  96434. * If vertex alpha should be applied to the mesh
  96435. */
  96436. readonly useVertexAlpha?: boolean | undefined;
  96437. /**
  96438. * Color of the line (Default: White)
  96439. */
  96440. color: Color3;
  96441. /**
  96442. * Alpha of the line (Default: 1)
  96443. */
  96444. alpha: number;
  96445. /**
  96446. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  96447. * This margin is expressed in world space coordinates, so its value may vary.
  96448. * Default value is 0.1
  96449. */
  96450. intersectionThreshold: number;
  96451. private _colorShader;
  96452. private color4;
  96453. /**
  96454. * Creates a new LinesMesh
  96455. * @param name defines the name
  96456. * @param scene defines the hosting scene
  96457. * @param parent defines the parent mesh if any
  96458. * @param source defines the optional source LinesMesh used to clone data from
  96459. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  96460. * When false, achieved by calling a clone(), also passing False.
  96461. * This will make creation of children, recursive.
  96462. * @param useVertexColor defines if this LinesMesh supports vertex color
  96463. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  96464. */
  96465. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  96466. /**
  96467. * If vertex color should be applied to the mesh
  96468. */
  96469. useVertexColor?: boolean | undefined,
  96470. /**
  96471. * If vertex alpha should be applied to the mesh
  96472. */
  96473. useVertexAlpha?: boolean | undefined);
  96474. private _addClipPlaneDefine;
  96475. private _removeClipPlaneDefine;
  96476. isReady(): boolean;
  96477. /**
  96478. * Returns the string "LineMesh"
  96479. */
  96480. getClassName(): string;
  96481. /**
  96482. * @hidden
  96483. */
  96484. get material(): Material;
  96485. /**
  96486. * @hidden
  96487. */
  96488. set material(value: Material);
  96489. /**
  96490. * @hidden
  96491. */
  96492. get checkCollisions(): boolean;
  96493. /** @hidden */
  96494. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  96495. /** @hidden */
  96496. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  96497. /**
  96498. * Disposes of the line mesh
  96499. * @param doNotRecurse If children should be disposed
  96500. */
  96501. dispose(doNotRecurse?: boolean): void;
  96502. /**
  96503. * Returns a new LineMesh object cloned from the current one.
  96504. */
  96505. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  96506. /**
  96507. * Creates a new InstancedLinesMesh object from the mesh model.
  96508. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96509. * @param name defines the name of the new instance
  96510. * @returns a new InstancedLinesMesh
  96511. */
  96512. createInstance(name: string): InstancedLinesMesh;
  96513. }
  96514. /**
  96515. * Creates an instance based on a source LinesMesh
  96516. */
  96517. export class InstancedLinesMesh extends InstancedMesh {
  96518. /**
  96519. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  96520. * This margin is expressed in world space coordinates, so its value may vary.
  96521. * Initilized with the intersectionThreshold value of the source LinesMesh
  96522. */
  96523. intersectionThreshold: number;
  96524. constructor(name: string, source: LinesMesh);
  96525. /**
  96526. * Returns the string "InstancedLinesMesh".
  96527. */
  96528. getClassName(): string;
  96529. }
  96530. }
  96531. declare module BABYLON {
  96532. /** @hidden */
  96533. export var linePixelShader: {
  96534. name: string;
  96535. shader: string;
  96536. };
  96537. }
  96538. declare module BABYLON {
  96539. /** @hidden */
  96540. export var lineVertexShader: {
  96541. name: string;
  96542. shader: string;
  96543. };
  96544. }
  96545. declare module BABYLON {
  96546. interface Scene {
  96547. /** @hidden */
  96548. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  96549. }
  96550. interface AbstractMesh {
  96551. /**
  96552. * Gets the edgesRenderer associated with the mesh
  96553. */
  96554. edgesRenderer: Nullable<EdgesRenderer>;
  96555. }
  96556. interface LinesMesh {
  96557. /**
  96558. * Enables the edge rendering mode on the mesh.
  96559. * This mode makes the mesh edges visible
  96560. * @param epsilon defines the maximal distance between two angles to detect a face
  96561. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96562. * @returns the currentAbstractMesh
  96563. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96564. */
  96565. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  96566. }
  96567. interface InstancedLinesMesh {
  96568. /**
  96569. * Enables the edge rendering mode on the mesh.
  96570. * This mode makes the mesh edges visible
  96571. * @param epsilon defines the maximal distance between two angles to detect a face
  96572. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96573. * @returns the current InstancedLinesMesh
  96574. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96575. */
  96576. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  96577. }
  96578. /**
  96579. * Defines the minimum contract an Edges renderer should follow.
  96580. */
  96581. export interface IEdgesRenderer extends IDisposable {
  96582. /**
  96583. * Gets or sets a boolean indicating if the edgesRenderer is active
  96584. */
  96585. isEnabled: boolean;
  96586. /**
  96587. * Renders the edges of the attached mesh,
  96588. */
  96589. render(): void;
  96590. /**
  96591. * Checks wether or not the edges renderer is ready to render.
  96592. * @return true if ready, otherwise false.
  96593. */
  96594. isReady(): boolean;
  96595. /**
  96596. * List of instances to render in case the source mesh has instances
  96597. */
  96598. customInstances: SmartArray<Matrix>;
  96599. }
  96600. /**
  96601. * Defines the additional options of the edges renderer
  96602. */
  96603. export interface IEdgesRendererOptions {
  96604. /**
  96605. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  96606. * If not defined, the default value is true
  96607. */
  96608. useAlternateEdgeFinder?: boolean;
  96609. /**
  96610. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  96611. * If not defined, the default value is true.
  96612. * 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)
  96613. * This option is used only if useAlternateEdgeFinder = true
  96614. */
  96615. useFastVertexMerger?: boolean;
  96616. /**
  96617. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  96618. * The default value is 1e-6
  96619. * This option is used only if useAlternateEdgeFinder = true
  96620. */
  96621. epsilonVertexMerge?: number;
  96622. /**
  96623. * 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
  96624. * 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.
  96625. * This option is used only if useAlternateEdgeFinder = true
  96626. */
  96627. applyTessellation?: boolean;
  96628. /**
  96629. * 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
  96630. * The default value is 1e-6
  96631. * This option is used only if useAlternateEdgeFinder = true
  96632. */
  96633. epsilonVertexAligned?: number;
  96634. }
  96635. /**
  96636. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  96637. */
  96638. export class EdgesRenderer implements IEdgesRenderer {
  96639. /**
  96640. * Define the size of the edges with an orthographic camera
  96641. */
  96642. edgesWidthScalerForOrthographic: number;
  96643. /**
  96644. * Define the size of the edges with a perspective camera
  96645. */
  96646. edgesWidthScalerForPerspective: number;
  96647. protected _source: AbstractMesh;
  96648. protected _linesPositions: number[];
  96649. protected _linesNormals: number[];
  96650. protected _linesIndices: number[];
  96651. protected _epsilon: number;
  96652. protected _indicesCount: number;
  96653. protected _lineShader: ShaderMaterial;
  96654. protected _ib: DataBuffer;
  96655. protected _buffers: {
  96656. [key: string]: Nullable<VertexBuffer>;
  96657. };
  96658. protected _buffersForInstances: {
  96659. [key: string]: Nullable<VertexBuffer>;
  96660. };
  96661. protected _checkVerticesInsteadOfIndices: boolean;
  96662. protected _options: Nullable<IEdgesRendererOptions>;
  96663. private _meshRebuildObserver;
  96664. private _meshDisposeObserver;
  96665. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  96666. isEnabled: boolean;
  96667. /**
  96668. * List of instances to render in case the source mesh has instances
  96669. */
  96670. customInstances: SmartArray<Matrix>;
  96671. private static GetShader;
  96672. /**
  96673. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  96674. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  96675. * @param source Mesh used to create edges
  96676. * @param epsilon sum of angles in adjacency to check for edge
  96677. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  96678. * @param generateEdgesLines - should generate Lines or only prepare resources.
  96679. * @param options The options to apply when generating the edges
  96680. */
  96681. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  96682. protected _prepareRessources(): void;
  96683. /** @hidden */
  96684. _rebuild(): void;
  96685. /**
  96686. * Releases the required resources for the edges renderer
  96687. */
  96688. dispose(): void;
  96689. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  96690. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  96691. /**
  96692. * Checks if the pair of p0 and p1 is en edge
  96693. * @param faceIndex
  96694. * @param edge
  96695. * @param faceNormals
  96696. * @param p0
  96697. * @param p1
  96698. * @private
  96699. */
  96700. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  96701. /**
  96702. * push line into the position, normal and index buffer
  96703. * @protected
  96704. */
  96705. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  96706. /**
  96707. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  96708. */
  96709. private _tessellateTriangle;
  96710. private _generateEdgesLinesAlternate;
  96711. /**
  96712. * Generates lines edges from adjacencjes
  96713. * @private
  96714. */
  96715. _generateEdgesLines(): void;
  96716. /**
  96717. * Checks wether or not the edges renderer is ready to render.
  96718. * @return true if ready, otherwise false.
  96719. */
  96720. isReady(): boolean;
  96721. /**
  96722. * Renders the edges of the attached mesh,
  96723. */
  96724. render(): void;
  96725. }
  96726. /**
  96727. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  96728. */
  96729. export class LineEdgesRenderer extends EdgesRenderer {
  96730. /**
  96731. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  96732. * @param source LineMesh used to generate edges
  96733. * @param epsilon not important (specified angle for edge detection)
  96734. * @param checkVerticesInsteadOfIndices not important for LineMesh
  96735. */
  96736. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  96737. /**
  96738. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  96739. */
  96740. _generateEdgesLines(): void;
  96741. }
  96742. }
  96743. declare module BABYLON {
  96744. /**
  96745. * This represents the object necessary to create a rendering group.
  96746. * This is exclusively used and created by the rendering manager.
  96747. * To modify the behavior, you use the available helpers in your scene or meshes.
  96748. * @hidden
  96749. */
  96750. export class RenderingGroup {
  96751. index: number;
  96752. private static _zeroVector;
  96753. private _scene;
  96754. private _opaqueSubMeshes;
  96755. private _transparentSubMeshes;
  96756. private _alphaTestSubMeshes;
  96757. private _depthOnlySubMeshes;
  96758. private _particleSystems;
  96759. private _spriteManagers;
  96760. private _opaqueSortCompareFn;
  96761. private _alphaTestSortCompareFn;
  96762. private _transparentSortCompareFn;
  96763. private _renderOpaque;
  96764. private _renderAlphaTest;
  96765. private _renderTransparent;
  96766. /** @hidden */
  96767. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  96768. onBeforeTransparentRendering: () => void;
  96769. /**
  96770. * Set the opaque sort comparison function.
  96771. * If null the sub meshes will be render in the order they were created
  96772. */
  96773. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96774. /**
  96775. * Set the alpha test sort comparison function.
  96776. * If null the sub meshes will be render in the order they were created
  96777. */
  96778. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96779. /**
  96780. * Set the transparent sort comparison function.
  96781. * If null the sub meshes will be render in the order they were created
  96782. */
  96783. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96784. /**
  96785. * Creates a new rendering group.
  96786. * @param index The rendering group index
  96787. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  96788. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  96789. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  96790. */
  96791. 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>);
  96792. /**
  96793. * Render all the sub meshes contained in the group.
  96794. * @param customRenderFunction Used to override the default render behaviour of the group.
  96795. * @returns true if rendered some submeshes.
  96796. */
  96797. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  96798. /**
  96799. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  96800. * @param subMeshes The submeshes to render
  96801. */
  96802. private renderOpaqueSorted;
  96803. /**
  96804. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  96805. * @param subMeshes The submeshes to render
  96806. */
  96807. private renderAlphaTestSorted;
  96808. /**
  96809. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  96810. * @param subMeshes The submeshes to render
  96811. */
  96812. private renderTransparentSorted;
  96813. /**
  96814. * Renders the submeshes in a specified order.
  96815. * @param subMeshes The submeshes to sort before render
  96816. * @param sortCompareFn The comparison function use to sort
  96817. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  96818. * @param transparent Specifies to activate blending if true
  96819. */
  96820. private static renderSorted;
  96821. /**
  96822. * Renders the submeshes in the order they were dispatched (no sort applied).
  96823. * @param subMeshes The submeshes to render
  96824. */
  96825. private static renderUnsorted;
  96826. /**
  96827. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96828. * are rendered back to front if in the same alpha index.
  96829. *
  96830. * @param a The first submesh
  96831. * @param b The second submesh
  96832. * @returns The result of the comparison
  96833. */
  96834. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  96835. /**
  96836. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96837. * are rendered back to front.
  96838. *
  96839. * @param a The first submesh
  96840. * @param b The second submesh
  96841. * @returns The result of the comparison
  96842. */
  96843. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  96844. /**
  96845. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96846. * are rendered front to back (prevent overdraw).
  96847. *
  96848. * @param a The first submesh
  96849. * @param b The second submesh
  96850. * @returns The result of the comparison
  96851. */
  96852. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  96853. /**
  96854. * Resets the different lists of submeshes to prepare a new frame.
  96855. */
  96856. prepare(): void;
  96857. dispose(): void;
  96858. /**
  96859. * Inserts the submesh in its correct queue depending on its material.
  96860. * @param subMesh The submesh to dispatch
  96861. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  96862. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  96863. */
  96864. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  96865. dispatchSprites(spriteManager: ISpriteManager): void;
  96866. dispatchParticles(particleSystem: IParticleSystem): void;
  96867. private _renderParticles;
  96868. private _renderSprites;
  96869. }
  96870. }
  96871. declare module BABYLON {
  96872. /**
  96873. * Interface describing the different options available in the rendering manager
  96874. * regarding Auto Clear between groups.
  96875. */
  96876. export interface IRenderingManagerAutoClearSetup {
  96877. /**
  96878. * Defines whether or not autoclear is enable.
  96879. */
  96880. autoClear: boolean;
  96881. /**
  96882. * Defines whether or not to autoclear the depth buffer.
  96883. */
  96884. depth: boolean;
  96885. /**
  96886. * Defines whether or not to autoclear the stencil buffer.
  96887. */
  96888. stencil: boolean;
  96889. }
  96890. /**
  96891. * This class is used by the onRenderingGroupObservable
  96892. */
  96893. export class RenderingGroupInfo {
  96894. /**
  96895. * The Scene that being rendered
  96896. */
  96897. scene: Scene;
  96898. /**
  96899. * The camera currently used for the rendering pass
  96900. */
  96901. camera: Nullable<Camera>;
  96902. /**
  96903. * The ID of the renderingGroup being processed
  96904. */
  96905. renderingGroupId: number;
  96906. }
  96907. /**
  96908. * This is the manager responsible of all the rendering for meshes sprites and particles.
  96909. * It is enable to manage the different groups as well as the different necessary sort functions.
  96910. * This should not be used directly aside of the few static configurations
  96911. */
  96912. export class RenderingManager {
  96913. /**
  96914. * The max id used for rendering groups (not included)
  96915. */
  96916. static MAX_RENDERINGGROUPS: number;
  96917. /**
  96918. * The min id used for rendering groups (included)
  96919. */
  96920. static MIN_RENDERINGGROUPS: number;
  96921. /**
  96922. * Used to globally prevent autoclearing scenes.
  96923. */
  96924. static AUTOCLEAR: boolean;
  96925. /**
  96926. * @hidden
  96927. */
  96928. _useSceneAutoClearSetup: boolean;
  96929. private _scene;
  96930. private _renderingGroups;
  96931. private _depthStencilBufferAlreadyCleaned;
  96932. private _autoClearDepthStencil;
  96933. private _customOpaqueSortCompareFn;
  96934. private _customAlphaTestSortCompareFn;
  96935. private _customTransparentSortCompareFn;
  96936. private _renderingGroupInfo;
  96937. /**
  96938. * Instantiates a new rendering group for a particular scene
  96939. * @param scene Defines the scene the groups belongs to
  96940. */
  96941. constructor(scene: Scene);
  96942. private _clearDepthStencilBuffer;
  96943. /**
  96944. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  96945. * @hidden
  96946. */
  96947. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  96948. /**
  96949. * Resets the different information of the group to prepare a new frame
  96950. * @hidden
  96951. */
  96952. reset(): void;
  96953. /**
  96954. * Dispose and release the group and its associated resources.
  96955. * @hidden
  96956. */
  96957. dispose(): void;
  96958. /**
  96959. * Clear the info related to rendering groups preventing retention points during dispose.
  96960. */
  96961. freeRenderingGroups(): void;
  96962. private _prepareRenderingGroup;
  96963. /**
  96964. * Add a sprite manager to the rendering manager in order to render it this frame.
  96965. * @param spriteManager Define the sprite manager to render
  96966. */
  96967. dispatchSprites(spriteManager: ISpriteManager): void;
  96968. /**
  96969. * Add a particle system to the rendering manager in order to render it this frame.
  96970. * @param particleSystem Define the particle system to render
  96971. */
  96972. dispatchParticles(particleSystem: IParticleSystem): void;
  96973. /**
  96974. * Add a submesh to the manager in order to render it this frame
  96975. * @param subMesh The submesh to dispatch
  96976. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  96977. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  96978. */
  96979. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  96980. /**
  96981. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96982. * This allowed control for front to back rendering or reversly depending of the special needs.
  96983. *
  96984. * @param renderingGroupId The rendering group id corresponding to its index
  96985. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96986. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96987. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96988. */
  96989. 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;
  96990. /**
  96991. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96992. *
  96993. * @param renderingGroupId The rendering group id corresponding to its index
  96994. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96995. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96996. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96997. */
  96998. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96999. /**
  97000. * Gets the current auto clear configuration for one rendering group of the rendering
  97001. * manager.
  97002. * @param index the rendering group index to get the information for
  97003. * @returns The auto clear setup for the requested rendering group
  97004. */
  97005. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97006. }
  97007. }
  97008. declare module BABYLON {
  97009. /**
  97010. * Defines the options associated with the creation of a custom shader for a shadow generator.
  97011. */
  97012. export interface ICustomShaderOptions {
  97013. /**
  97014. * Gets or sets the custom shader name to use
  97015. */
  97016. shaderName: string;
  97017. /**
  97018. * The list of attribute names used in the shader
  97019. */
  97020. attributes?: string[];
  97021. /**
  97022. * The list of unifrom names used in the shader
  97023. */
  97024. uniforms?: string[];
  97025. /**
  97026. * The list of sampler names used in the shader
  97027. */
  97028. samplers?: string[];
  97029. /**
  97030. * The list of defines used in the shader
  97031. */
  97032. defines?: string[];
  97033. }
  97034. /**
  97035. * Interface to implement to create a shadow generator compatible with BJS.
  97036. */
  97037. export interface IShadowGenerator {
  97038. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97039. id: string;
  97040. /**
  97041. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97042. * @returns The render target texture if present otherwise, null
  97043. */
  97044. getShadowMap(): Nullable<RenderTargetTexture>;
  97045. /**
  97046. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97047. * @param subMesh The submesh we want to render in the shadow map
  97048. * @param useInstances Defines wether will draw in the map using instances
  97049. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97050. * @returns true if ready otherwise, false
  97051. */
  97052. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97053. /**
  97054. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97055. * @param defines Defines of the material we want to update
  97056. * @param lightIndex Index of the light in the enabled light list of the material
  97057. */
  97058. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  97059. /**
  97060. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97061. * defined in the generator but impacting the effect).
  97062. * It implies the unifroms available on the materials are the standard BJS ones.
  97063. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97064. * @param effect The effect we are binfing the information for
  97065. */
  97066. bindShadowLight(lightIndex: string, effect: Effect): void;
  97067. /**
  97068. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97069. * (eq to shadow prjection matrix * light transform matrix)
  97070. * @returns The transform matrix used to create the shadow map
  97071. */
  97072. getTransformMatrix(): Matrix;
  97073. /**
  97074. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97075. * Cube and 2D textures for instance.
  97076. */
  97077. recreateShadowMap(): void;
  97078. /**
  97079. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97080. * @param onCompiled Callback triggered at the and of the effects compilation
  97081. * @param options Sets of optional options forcing the compilation with different modes
  97082. */
  97083. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97084. useInstances: boolean;
  97085. }>): void;
  97086. /**
  97087. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97088. * @param options Sets of optional options forcing the compilation with different modes
  97089. * @returns A promise that resolves when the compilation completes
  97090. */
  97091. forceCompilationAsync(options?: Partial<{
  97092. useInstances: boolean;
  97093. }>): Promise<void>;
  97094. /**
  97095. * Serializes the shadow generator setup to a json object.
  97096. * @returns The serialized JSON object
  97097. */
  97098. serialize(): any;
  97099. /**
  97100. * Disposes the Shadow map and related Textures and effects.
  97101. */
  97102. dispose(): void;
  97103. }
  97104. /**
  97105. * Default implementation IShadowGenerator.
  97106. * This is the main object responsible of generating shadows in the framework.
  97107. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  97108. */
  97109. export class ShadowGenerator implements IShadowGenerator {
  97110. /**
  97111. * Name of the shadow generator class
  97112. */
  97113. static CLASSNAME: string;
  97114. /**
  97115. * Shadow generator mode None: no filtering applied.
  97116. */
  97117. static readonly FILTER_NONE: number;
  97118. /**
  97119. * Shadow generator mode ESM: Exponential Shadow Mapping.
  97120. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97121. */
  97122. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  97123. /**
  97124. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  97125. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  97126. */
  97127. static readonly FILTER_POISSONSAMPLING: number;
  97128. /**
  97129. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  97130. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97131. */
  97132. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  97133. /**
  97134. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  97135. * edge artifacts on steep falloff.
  97136. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97137. */
  97138. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  97139. /**
  97140. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  97141. * edge artifacts on steep falloff.
  97142. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97143. */
  97144. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  97145. /**
  97146. * Shadow generator mode PCF: Percentage Closer Filtering
  97147. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97148. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  97149. */
  97150. static readonly FILTER_PCF: number;
  97151. /**
  97152. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  97153. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97154. * Contact Hardening
  97155. */
  97156. static readonly FILTER_PCSS: number;
  97157. /**
  97158. * Reserved for PCF and PCSS
  97159. * Highest Quality.
  97160. *
  97161. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  97162. *
  97163. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  97164. */
  97165. static readonly QUALITY_HIGH: number;
  97166. /**
  97167. * Reserved for PCF and PCSS
  97168. * Good tradeoff for quality/perf cross devices
  97169. *
  97170. * Execute PCF on a 3*3 kernel.
  97171. *
  97172. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  97173. */
  97174. static readonly QUALITY_MEDIUM: number;
  97175. /**
  97176. * Reserved for PCF and PCSS
  97177. * The lowest quality but the fastest.
  97178. *
  97179. * Execute PCF on a 1*1 kernel.
  97180. *
  97181. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  97182. */
  97183. static readonly QUALITY_LOW: number;
  97184. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97185. id: string;
  97186. /** Gets or sets the custom shader name to use */
  97187. customShaderOptions: ICustomShaderOptions;
  97188. /**
  97189. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  97190. */
  97191. onBeforeShadowMapRenderObservable: Observable<Effect>;
  97192. /**
  97193. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  97194. */
  97195. onAfterShadowMapRenderObservable: Observable<Effect>;
  97196. /**
  97197. * Observable triggered before a mesh is rendered in the shadow map.
  97198. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  97199. */
  97200. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  97201. /**
  97202. * Observable triggered after a mesh is rendered in the shadow map.
  97203. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  97204. */
  97205. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  97206. protected _bias: number;
  97207. /**
  97208. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  97209. */
  97210. get bias(): number;
  97211. /**
  97212. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  97213. */
  97214. set bias(bias: number);
  97215. protected _normalBias: number;
  97216. /**
  97217. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97218. */
  97219. get normalBias(): number;
  97220. /**
  97221. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97222. */
  97223. set normalBias(normalBias: number);
  97224. protected _blurBoxOffset: number;
  97225. /**
  97226. * Gets the blur box offset: offset applied during the blur pass.
  97227. * Only useful if useKernelBlur = false
  97228. */
  97229. get blurBoxOffset(): number;
  97230. /**
  97231. * Sets the blur box offset: offset applied during the blur pass.
  97232. * Only useful if useKernelBlur = false
  97233. */
  97234. set blurBoxOffset(value: number);
  97235. protected _blurScale: number;
  97236. /**
  97237. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  97238. * 2 means half of the size.
  97239. */
  97240. get blurScale(): number;
  97241. /**
  97242. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  97243. * 2 means half of the size.
  97244. */
  97245. set blurScale(value: number);
  97246. protected _blurKernel: number;
  97247. /**
  97248. * Gets the blur kernel: kernel size of the blur pass.
  97249. * Only useful if useKernelBlur = true
  97250. */
  97251. get blurKernel(): number;
  97252. /**
  97253. * Sets the blur kernel: kernel size of the blur pass.
  97254. * Only useful if useKernelBlur = true
  97255. */
  97256. set blurKernel(value: number);
  97257. protected _useKernelBlur: boolean;
  97258. /**
  97259. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  97260. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97261. */
  97262. get useKernelBlur(): boolean;
  97263. /**
  97264. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  97265. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97266. */
  97267. set useKernelBlur(value: boolean);
  97268. protected _depthScale: number;
  97269. /**
  97270. * Gets the depth scale used in ESM mode.
  97271. */
  97272. get depthScale(): number;
  97273. /**
  97274. * Sets the depth scale used in ESM mode.
  97275. * This can override the scale stored on the light.
  97276. */
  97277. set depthScale(value: number);
  97278. protected _validateFilter(filter: number): number;
  97279. protected _filter: number;
  97280. /**
  97281. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  97282. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  97283. */
  97284. get filter(): number;
  97285. /**
  97286. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  97287. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  97288. */
  97289. set filter(value: number);
  97290. /**
  97291. * Gets if the current filter is set to Poisson Sampling.
  97292. */
  97293. get usePoissonSampling(): boolean;
  97294. /**
  97295. * Sets the current filter to Poisson Sampling.
  97296. */
  97297. set usePoissonSampling(value: boolean);
  97298. /**
  97299. * Gets if the current filter is set to ESM.
  97300. */
  97301. get useExponentialShadowMap(): boolean;
  97302. /**
  97303. * Sets the current filter is to ESM.
  97304. */
  97305. set useExponentialShadowMap(value: boolean);
  97306. /**
  97307. * Gets if the current filter is set to filtered ESM.
  97308. */
  97309. get useBlurExponentialShadowMap(): boolean;
  97310. /**
  97311. * Gets if the current filter is set to filtered ESM.
  97312. */
  97313. set useBlurExponentialShadowMap(value: boolean);
  97314. /**
  97315. * Gets if the current filter is set to "close ESM" (using the inverse of the
  97316. * exponential to prevent steep falloff artifacts).
  97317. */
  97318. get useCloseExponentialShadowMap(): boolean;
  97319. /**
  97320. * Sets the current filter to "close ESM" (using the inverse of the
  97321. * exponential to prevent steep falloff artifacts).
  97322. */
  97323. set useCloseExponentialShadowMap(value: boolean);
  97324. /**
  97325. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  97326. * exponential to prevent steep falloff artifacts).
  97327. */
  97328. get useBlurCloseExponentialShadowMap(): boolean;
  97329. /**
  97330. * Sets the current filter to filtered "close ESM" (using the inverse of the
  97331. * exponential to prevent steep falloff artifacts).
  97332. */
  97333. set useBlurCloseExponentialShadowMap(value: boolean);
  97334. /**
  97335. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  97336. */
  97337. get usePercentageCloserFiltering(): boolean;
  97338. /**
  97339. * Sets the current filter to "PCF" (percentage closer filtering).
  97340. */
  97341. set usePercentageCloserFiltering(value: boolean);
  97342. protected _filteringQuality: number;
  97343. /**
  97344. * Gets the PCF or PCSS Quality.
  97345. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  97346. */
  97347. get filteringQuality(): number;
  97348. /**
  97349. * Sets the PCF or PCSS Quality.
  97350. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  97351. */
  97352. set filteringQuality(filteringQuality: number);
  97353. /**
  97354. * Gets if the current filter is set to "PCSS" (contact hardening).
  97355. */
  97356. get useContactHardeningShadow(): boolean;
  97357. /**
  97358. * Sets the current filter to "PCSS" (contact hardening).
  97359. */
  97360. set useContactHardeningShadow(value: boolean);
  97361. protected _contactHardeningLightSizeUVRatio: number;
  97362. /**
  97363. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  97364. * Using a ratio helps keeping shape stability independently of the map size.
  97365. *
  97366. * It does not account for the light projection as it was having too much
  97367. * instability during the light setup or during light position changes.
  97368. *
  97369. * Only valid if useContactHardeningShadow is true.
  97370. */
  97371. get contactHardeningLightSizeUVRatio(): number;
  97372. /**
  97373. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  97374. * Using a ratio helps keeping shape stability independently of the map size.
  97375. *
  97376. * It does not account for the light projection as it was having too much
  97377. * instability during the light setup or during light position changes.
  97378. *
  97379. * Only valid if useContactHardeningShadow is true.
  97380. */
  97381. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  97382. protected _darkness: number;
  97383. /** Gets or sets the actual darkness of a shadow */
  97384. get darkness(): number;
  97385. set darkness(value: number);
  97386. /**
  97387. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  97388. * 0 means strongest and 1 would means no shadow.
  97389. * @returns the darkness.
  97390. */
  97391. getDarkness(): number;
  97392. /**
  97393. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  97394. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  97395. * @returns the shadow generator allowing fluent coding.
  97396. */
  97397. setDarkness(darkness: number): ShadowGenerator;
  97398. protected _transparencyShadow: boolean;
  97399. /** Gets or sets the ability to have transparent shadow */
  97400. get transparencyShadow(): boolean;
  97401. set transparencyShadow(value: boolean);
  97402. /**
  97403. * Sets the ability to have transparent shadow (boolean).
  97404. * @param transparent True if transparent else False
  97405. * @returns the shadow generator allowing fluent coding
  97406. */
  97407. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  97408. /**
  97409. * Enables or disables shadows with varying strength based on the transparency
  97410. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  97411. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  97412. * mesh.visibility * alphaTexture.a
  97413. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  97414. */
  97415. enableSoftTransparentShadow: boolean;
  97416. protected _shadowMap: Nullable<RenderTargetTexture>;
  97417. protected _shadowMap2: Nullable<RenderTargetTexture>;
  97418. /**
  97419. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97420. * @returns The render target texture if present otherwise, null
  97421. */
  97422. getShadowMap(): Nullable<RenderTargetTexture>;
  97423. /**
  97424. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  97425. * @returns The render target texture if the shadow map is present otherwise, null
  97426. */
  97427. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  97428. /**
  97429. * Gets the class name of that object
  97430. * @returns "ShadowGenerator"
  97431. */
  97432. getClassName(): string;
  97433. /**
  97434. * Helper function to add a mesh and its descendants to the list of shadow casters.
  97435. * @param mesh Mesh to add
  97436. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  97437. * @returns the Shadow Generator itself
  97438. */
  97439. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  97440. /**
  97441. * Helper function to remove a mesh and its descendants from the list of shadow casters
  97442. * @param mesh Mesh to remove
  97443. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  97444. * @returns the Shadow Generator itself
  97445. */
  97446. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  97447. /**
  97448. * Controls the extent to which the shadows fade out at the edge of the frustum
  97449. */
  97450. frustumEdgeFalloff: number;
  97451. protected _light: IShadowLight;
  97452. /**
  97453. * Returns the associated light object.
  97454. * @returns the light generating the shadow
  97455. */
  97456. getLight(): IShadowLight;
  97457. /**
  97458. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  97459. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  97460. * It might on the other hand introduce peter panning.
  97461. */
  97462. forceBackFacesOnly: boolean;
  97463. protected _scene: Scene;
  97464. protected _lightDirection: Vector3;
  97465. protected _effect: Effect;
  97466. protected _viewMatrix: Matrix;
  97467. protected _projectionMatrix: Matrix;
  97468. protected _transformMatrix: Matrix;
  97469. protected _cachedPosition: Vector3;
  97470. protected _cachedDirection: Vector3;
  97471. protected _cachedDefines: string;
  97472. protected _currentRenderID: number;
  97473. protected _boxBlurPostprocess: Nullable<PostProcess>;
  97474. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  97475. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  97476. protected _blurPostProcesses: PostProcess[];
  97477. protected _mapSize: number;
  97478. protected _currentFaceIndex: number;
  97479. protected _currentFaceIndexCache: number;
  97480. protected _textureType: number;
  97481. protected _defaultTextureMatrix: Matrix;
  97482. protected _storedUniqueId: Nullable<number>;
  97483. /** @hidden */
  97484. static _SceneComponentInitialization: (scene: Scene) => void;
  97485. /**
  97486. * Creates a ShadowGenerator object.
  97487. * A ShadowGenerator is the required tool to use the shadows.
  97488. * Each light casting shadows needs to use its own ShadowGenerator.
  97489. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  97490. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  97491. * @param light The light object generating the shadows.
  97492. * @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.
  97493. */
  97494. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  97495. protected _initializeGenerator(): void;
  97496. protected _createTargetRenderTexture(): void;
  97497. protected _initializeShadowMap(): void;
  97498. protected _initializeBlurRTTAndPostProcesses(): void;
  97499. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  97500. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  97501. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  97502. protected _applyFilterValues(): void;
  97503. /**
  97504. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97505. * @param onCompiled Callback triggered at the and of the effects compilation
  97506. * @param options Sets of optional options forcing the compilation with different modes
  97507. */
  97508. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97509. useInstances: boolean;
  97510. }>): void;
  97511. /**
  97512. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97513. * @param options Sets of optional options forcing the compilation with different modes
  97514. * @returns A promise that resolves when the compilation completes
  97515. */
  97516. forceCompilationAsync(options?: Partial<{
  97517. useInstances: boolean;
  97518. }>): Promise<void>;
  97519. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  97520. private _prepareShadowDefines;
  97521. /**
  97522. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97523. * @param subMesh The submesh we want to render in the shadow map
  97524. * @param useInstances Defines wether will draw in the map using instances
  97525. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97526. * @returns true if ready otherwise, false
  97527. */
  97528. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97529. /**
  97530. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97531. * @param defines Defines of the material we want to update
  97532. * @param lightIndex Index of the light in the enabled light list of the material
  97533. */
  97534. prepareDefines(defines: any, lightIndex: number): void;
  97535. /**
  97536. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97537. * defined in the generator but impacting the effect).
  97538. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97539. * @param effect The effect we are binfing the information for
  97540. */
  97541. bindShadowLight(lightIndex: string, effect: Effect): void;
  97542. /**
  97543. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97544. * (eq to shadow prjection matrix * light transform matrix)
  97545. * @returns The transform matrix used to create the shadow map
  97546. */
  97547. getTransformMatrix(): Matrix;
  97548. /**
  97549. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97550. * Cube and 2D textures for instance.
  97551. */
  97552. recreateShadowMap(): void;
  97553. protected _disposeBlurPostProcesses(): void;
  97554. protected _disposeRTTandPostProcesses(): void;
  97555. /**
  97556. * Disposes the ShadowGenerator.
  97557. * Returns nothing.
  97558. */
  97559. dispose(): void;
  97560. /**
  97561. * Serializes the shadow generator setup to a json object.
  97562. * @returns The serialized JSON object
  97563. */
  97564. serialize(): any;
  97565. /**
  97566. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  97567. * @param parsedShadowGenerator The JSON object to parse
  97568. * @param scene The scene to create the shadow map for
  97569. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  97570. * @returns The parsed shadow generator
  97571. */
  97572. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  97573. }
  97574. }
  97575. declare module BABYLON {
  97576. /**
  97577. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  97578. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  97579. * 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.
  97580. */
  97581. export abstract class Light extends Node {
  97582. /**
  97583. * Falloff Default: light is falling off following the material specification:
  97584. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  97585. */
  97586. static readonly FALLOFF_DEFAULT: number;
  97587. /**
  97588. * Falloff Physical: light is falling off following the inverse squared distance law.
  97589. */
  97590. static readonly FALLOFF_PHYSICAL: number;
  97591. /**
  97592. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  97593. * to enhance interoperability with other engines.
  97594. */
  97595. static readonly FALLOFF_GLTF: number;
  97596. /**
  97597. * Falloff Standard: light is falling off like in the standard material
  97598. * to enhance interoperability with other materials.
  97599. */
  97600. static readonly FALLOFF_STANDARD: number;
  97601. /**
  97602. * If every light affecting the material is in this lightmapMode,
  97603. * material.lightmapTexture adds or multiplies
  97604. * (depends on material.useLightmapAsShadowmap)
  97605. * after every other light calculations.
  97606. */
  97607. static readonly LIGHTMAP_DEFAULT: number;
  97608. /**
  97609. * material.lightmapTexture as only diffuse lighting from this light
  97610. * adds only specular lighting from this light
  97611. * adds dynamic shadows
  97612. */
  97613. static readonly LIGHTMAP_SPECULAR: number;
  97614. /**
  97615. * material.lightmapTexture as only lighting
  97616. * no light calculation from this light
  97617. * only adds dynamic shadows from this light
  97618. */
  97619. static readonly LIGHTMAP_SHADOWSONLY: number;
  97620. /**
  97621. * Each light type uses the default quantity according to its type:
  97622. * point/spot lights use luminous intensity
  97623. * directional lights use illuminance
  97624. */
  97625. static readonly INTENSITYMODE_AUTOMATIC: number;
  97626. /**
  97627. * lumen (lm)
  97628. */
  97629. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  97630. /**
  97631. * candela (lm/sr)
  97632. */
  97633. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  97634. /**
  97635. * lux (lm/m^2)
  97636. */
  97637. static readonly INTENSITYMODE_ILLUMINANCE: number;
  97638. /**
  97639. * nit (cd/m^2)
  97640. */
  97641. static readonly INTENSITYMODE_LUMINANCE: number;
  97642. /**
  97643. * Light type const id of the point light.
  97644. */
  97645. static readonly LIGHTTYPEID_POINTLIGHT: number;
  97646. /**
  97647. * Light type const id of the directional light.
  97648. */
  97649. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  97650. /**
  97651. * Light type const id of the spot light.
  97652. */
  97653. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  97654. /**
  97655. * Light type const id of the hemispheric light.
  97656. */
  97657. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  97658. /**
  97659. * Diffuse gives the basic color to an object.
  97660. */
  97661. diffuse: Color3;
  97662. /**
  97663. * Specular produces a highlight color on an object.
  97664. * Note: This is note affecting PBR materials.
  97665. */
  97666. specular: Color3;
  97667. /**
  97668. * Defines the falloff type for this light. This lets overrriding how punctual light are
  97669. * falling off base on range or angle.
  97670. * This can be set to any values in Light.FALLOFF_x.
  97671. *
  97672. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  97673. * other types of materials.
  97674. */
  97675. falloffType: number;
  97676. /**
  97677. * Strength of the light.
  97678. * Note: By default it is define in the framework own unit.
  97679. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  97680. */
  97681. intensity: number;
  97682. private _range;
  97683. protected _inverseSquaredRange: number;
  97684. /**
  97685. * Defines how far from the source the light is impacting in scene units.
  97686. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  97687. */
  97688. get range(): number;
  97689. /**
  97690. * Defines how far from the source the light is impacting in scene units.
  97691. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  97692. */
  97693. set range(value: number);
  97694. /**
  97695. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  97696. * of light.
  97697. */
  97698. private _photometricScale;
  97699. private _intensityMode;
  97700. /**
  97701. * Gets the photometric scale used to interpret the intensity.
  97702. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  97703. */
  97704. get intensityMode(): number;
  97705. /**
  97706. * Sets the photometric scale used to interpret the intensity.
  97707. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  97708. */
  97709. set intensityMode(value: number);
  97710. private _radius;
  97711. /**
  97712. * Gets the light radius used by PBR Materials to simulate soft area lights.
  97713. */
  97714. get radius(): number;
  97715. /**
  97716. * sets the light radius used by PBR Materials to simulate soft area lights.
  97717. */
  97718. set radius(value: number);
  97719. private _renderPriority;
  97720. /**
  97721. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  97722. * exceeding the number allowed of the materials.
  97723. */
  97724. renderPriority: number;
  97725. private _shadowEnabled;
  97726. /**
  97727. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  97728. * the current shadow generator.
  97729. */
  97730. get shadowEnabled(): boolean;
  97731. /**
  97732. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  97733. * the current shadow generator.
  97734. */
  97735. set shadowEnabled(value: boolean);
  97736. private _includedOnlyMeshes;
  97737. /**
  97738. * Gets the only meshes impacted by this light.
  97739. */
  97740. get includedOnlyMeshes(): AbstractMesh[];
  97741. /**
  97742. * Sets the only meshes impacted by this light.
  97743. */
  97744. set includedOnlyMeshes(value: AbstractMesh[]);
  97745. private _excludedMeshes;
  97746. /**
  97747. * Gets the meshes not impacted by this light.
  97748. */
  97749. get excludedMeshes(): AbstractMesh[];
  97750. /**
  97751. * Sets the meshes not impacted by this light.
  97752. */
  97753. set excludedMeshes(value: AbstractMesh[]);
  97754. private _excludeWithLayerMask;
  97755. /**
  97756. * Gets the layer id use to find what meshes are not impacted by the light.
  97757. * Inactive if 0
  97758. */
  97759. get excludeWithLayerMask(): number;
  97760. /**
  97761. * Sets the layer id use to find what meshes are not impacted by the light.
  97762. * Inactive if 0
  97763. */
  97764. set excludeWithLayerMask(value: number);
  97765. private _includeOnlyWithLayerMask;
  97766. /**
  97767. * Gets the layer id use to find what meshes are impacted by the light.
  97768. * Inactive if 0
  97769. */
  97770. get includeOnlyWithLayerMask(): number;
  97771. /**
  97772. * Sets the layer id use to find what meshes are impacted by the light.
  97773. * Inactive if 0
  97774. */
  97775. set includeOnlyWithLayerMask(value: number);
  97776. private _lightmapMode;
  97777. /**
  97778. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  97779. */
  97780. get lightmapMode(): number;
  97781. /**
  97782. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  97783. */
  97784. set lightmapMode(value: number);
  97785. /**
  97786. * Shadow generator associted to the light.
  97787. * @hidden Internal use only.
  97788. */
  97789. _shadowGenerator: Nullable<IShadowGenerator>;
  97790. /**
  97791. * @hidden Internal use only.
  97792. */
  97793. _excludedMeshesIds: string[];
  97794. /**
  97795. * @hidden Internal use only.
  97796. */
  97797. _includedOnlyMeshesIds: string[];
  97798. /**
  97799. * The current light unifom buffer.
  97800. * @hidden Internal use only.
  97801. */
  97802. _uniformBuffer: UniformBuffer;
  97803. /** @hidden */
  97804. _renderId: number;
  97805. /**
  97806. * Creates a Light object in the scene.
  97807. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97808. * @param name The firendly name of the light
  97809. * @param scene The scene the light belongs too
  97810. */
  97811. constructor(name: string, scene: Scene);
  97812. protected abstract _buildUniformLayout(): void;
  97813. /**
  97814. * Sets the passed Effect "effect" with the Light information.
  97815. * @param effect The effect to update
  97816. * @param lightIndex The index of the light in the effect to update
  97817. * @returns The light
  97818. */
  97819. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  97820. /**
  97821. * Sets the passed Effect "effect" with the Light textures.
  97822. * @param effect The effect to update
  97823. * @param lightIndex The index of the light in the effect to update
  97824. * @returns The light
  97825. */
  97826. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  97827. /**
  97828. * Binds the lights information from the scene to the effect for the given mesh.
  97829. * @param lightIndex Light index
  97830. * @param scene The scene where the light belongs to
  97831. * @param effect The effect we are binding the data to
  97832. * @param useSpecular Defines if specular is supported
  97833. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97834. */
  97835. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97836. /**
  97837. * Sets the passed Effect "effect" with the Light information.
  97838. * @param effect The effect to update
  97839. * @param lightDataUniformName The uniform used to store light data (position or direction)
  97840. * @returns The light
  97841. */
  97842. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  97843. /**
  97844. * Returns the string "Light".
  97845. * @returns the class name
  97846. */
  97847. getClassName(): string;
  97848. /** @hidden */
  97849. readonly _isLight: boolean;
  97850. /**
  97851. * Converts the light information to a readable string for debug purpose.
  97852. * @param fullDetails Supports for multiple levels of logging within scene loading
  97853. * @returns the human readable light info
  97854. */
  97855. toString(fullDetails?: boolean): string;
  97856. /** @hidden */
  97857. protected _syncParentEnabledState(): void;
  97858. /**
  97859. * Set the enabled state of this node.
  97860. * @param value - the new enabled state
  97861. */
  97862. setEnabled(value: boolean): void;
  97863. /**
  97864. * Returns the Light associated shadow generator if any.
  97865. * @return the associated shadow generator.
  97866. */
  97867. getShadowGenerator(): Nullable<IShadowGenerator>;
  97868. /**
  97869. * Returns a Vector3, the absolute light position in the World.
  97870. * @returns the world space position of the light
  97871. */
  97872. getAbsolutePosition(): Vector3;
  97873. /**
  97874. * Specifies if the light will affect the passed mesh.
  97875. * @param mesh The mesh to test against the light
  97876. * @return true the mesh is affected otherwise, false.
  97877. */
  97878. canAffectMesh(mesh: AbstractMesh): boolean;
  97879. /**
  97880. * Sort function to order lights for rendering.
  97881. * @param a First Light object to compare to second.
  97882. * @param b Second Light object to compare first.
  97883. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  97884. */
  97885. static CompareLightsPriority(a: Light, b: Light): number;
  97886. /**
  97887. * Releases resources associated with this node.
  97888. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97889. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97890. */
  97891. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97892. /**
  97893. * Returns the light type ID (integer).
  97894. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97895. */
  97896. getTypeID(): number;
  97897. /**
  97898. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  97899. * @returns the scaled intensity in intensity mode unit
  97900. */
  97901. getScaledIntensity(): number;
  97902. /**
  97903. * Returns a new Light object, named "name", from the current one.
  97904. * @param name The name of the cloned light
  97905. * @param newParent The parent of this light, if it has one
  97906. * @returns the new created light
  97907. */
  97908. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  97909. /**
  97910. * Serializes the current light into a Serialization object.
  97911. * @returns the serialized object.
  97912. */
  97913. serialize(): any;
  97914. /**
  97915. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  97916. * This new light is named "name" and added to the passed scene.
  97917. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  97918. * @param name The friendly name of the light
  97919. * @param scene The scene the new light will belong to
  97920. * @returns the constructor function
  97921. */
  97922. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  97923. /**
  97924. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  97925. * @param parsedLight The JSON representation of the light
  97926. * @param scene The scene to create the parsed light in
  97927. * @returns the created light after parsing
  97928. */
  97929. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  97930. private _hookArrayForExcluded;
  97931. private _hookArrayForIncludedOnly;
  97932. private _resyncMeshes;
  97933. /**
  97934. * Forces the meshes to update their light related information in their rendering used effects
  97935. * @hidden Internal Use Only
  97936. */
  97937. _markMeshesAsLightDirty(): void;
  97938. /**
  97939. * Recomputes the cached photometric scale if needed.
  97940. */
  97941. private _computePhotometricScale;
  97942. /**
  97943. * Returns the Photometric Scale according to the light type and intensity mode.
  97944. */
  97945. private _getPhotometricScale;
  97946. /**
  97947. * Reorder the light in the scene according to their defined priority.
  97948. * @hidden Internal Use Only
  97949. */
  97950. _reorderLightsInScene(): void;
  97951. /**
  97952. * Prepares the list of defines specific to the light type.
  97953. * @param defines the list of defines
  97954. * @param lightIndex defines the index of the light for the effect
  97955. */
  97956. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97957. }
  97958. }
  97959. declare module BABYLON {
  97960. /**
  97961. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  97962. * This is the base of the follow, arc rotate cameras and Free camera
  97963. * @see https://doc.babylonjs.com/features/cameras
  97964. */
  97965. export class TargetCamera extends Camera {
  97966. private static _RigCamTransformMatrix;
  97967. private static _TargetTransformMatrix;
  97968. private static _TargetFocalPoint;
  97969. private _tmpUpVector;
  97970. private _tmpTargetVector;
  97971. /**
  97972. * Define the current direction the camera is moving to
  97973. */
  97974. cameraDirection: Vector3;
  97975. /**
  97976. * Define the current rotation the camera is rotating to
  97977. */
  97978. cameraRotation: Vector2;
  97979. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  97980. ignoreParentScaling: boolean;
  97981. /**
  97982. * When set, the up vector of the camera will be updated by the rotation of the camera
  97983. */
  97984. updateUpVectorFromRotation: boolean;
  97985. private _tmpQuaternion;
  97986. /**
  97987. * Define the current rotation of the camera
  97988. */
  97989. rotation: Vector3;
  97990. /**
  97991. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  97992. */
  97993. rotationQuaternion: Quaternion;
  97994. /**
  97995. * Define the current speed of the camera
  97996. */
  97997. speed: number;
  97998. /**
  97999. * Add constraint to the camera to prevent it to move freely in all directions and
  98000. * around all axis.
  98001. */
  98002. noRotationConstraint: boolean;
  98003. /**
  98004. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  98005. * panning
  98006. */
  98007. invertRotation: boolean;
  98008. /**
  98009. * Speed multiplier for inverse camera panning
  98010. */
  98011. inverseRotationSpeed: number;
  98012. /**
  98013. * Define the current target of the camera as an object or a position.
  98014. */
  98015. lockedTarget: any;
  98016. /** @hidden */
  98017. _currentTarget: Vector3;
  98018. /** @hidden */
  98019. _initialFocalDistance: number;
  98020. /** @hidden */
  98021. _viewMatrix: Matrix;
  98022. /** @hidden */
  98023. _camMatrix: Matrix;
  98024. /** @hidden */
  98025. _cameraTransformMatrix: Matrix;
  98026. /** @hidden */
  98027. _cameraRotationMatrix: Matrix;
  98028. /** @hidden */
  98029. _referencePoint: Vector3;
  98030. /** @hidden */
  98031. _transformedReferencePoint: Vector3;
  98032. /** @hidden */
  98033. _reset: () => void;
  98034. private _defaultUp;
  98035. /**
  98036. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  98037. * This is the base of the follow, arc rotate cameras and Free camera
  98038. * @see https://doc.babylonjs.com/features/cameras
  98039. * @param name Defines the name of the camera in the scene
  98040. * @param position Defines the start position of the camera in the scene
  98041. * @param scene Defines the scene the camera belongs to
  98042. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98043. */
  98044. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98045. /**
  98046. * Gets the position in front of the camera at a given distance.
  98047. * @param distance The distance from the camera we want the position to be
  98048. * @returns the position
  98049. */
  98050. getFrontPosition(distance: number): Vector3;
  98051. /** @hidden */
  98052. _getLockedTargetPosition(): Nullable<Vector3>;
  98053. private _storedPosition;
  98054. private _storedRotation;
  98055. private _storedRotationQuaternion;
  98056. /**
  98057. * Store current camera state of the camera (fov, position, rotation, etc..)
  98058. * @returns the camera
  98059. */
  98060. storeState(): Camera;
  98061. /**
  98062. * Restored camera state. You must call storeState() first
  98063. * @returns whether it was successful or not
  98064. * @hidden
  98065. */
  98066. _restoreStateValues(): boolean;
  98067. /** @hidden */
  98068. _initCache(): void;
  98069. /** @hidden */
  98070. _updateCache(ignoreParentClass?: boolean): void;
  98071. /** @hidden */
  98072. _isSynchronizedViewMatrix(): boolean;
  98073. /** @hidden */
  98074. _computeLocalCameraSpeed(): number;
  98075. /**
  98076. * Defines the target the camera should look at.
  98077. * @param target Defines the new target as a Vector or a mesh
  98078. */
  98079. setTarget(target: Vector3): void;
  98080. /**
  98081. * Defines the target point of the camera.
  98082. * The camera looks towards it form the radius distance.
  98083. */
  98084. get target(): Vector3;
  98085. set target(value: Vector3);
  98086. /**
  98087. * Return the current target position of the camera. This value is expressed in local space.
  98088. * @returns the target position
  98089. */
  98090. getTarget(): Vector3;
  98091. /** @hidden */
  98092. _decideIfNeedsToMove(): boolean;
  98093. /** @hidden */
  98094. _updatePosition(): void;
  98095. /** @hidden */
  98096. _checkInputs(): void;
  98097. protected _updateCameraRotationMatrix(): void;
  98098. /**
  98099. * 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)
  98100. * @returns the current camera
  98101. */
  98102. private _rotateUpVectorWithCameraRotationMatrix;
  98103. private _cachedRotationZ;
  98104. private _cachedQuaternionRotationZ;
  98105. /** @hidden */
  98106. _getViewMatrix(): Matrix;
  98107. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  98108. /**
  98109. * @hidden
  98110. */
  98111. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98112. /**
  98113. * @hidden
  98114. */
  98115. _updateRigCameras(): void;
  98116. private _getRigCamPositionAndTarget;
  98117. /**
  98118. * Gets the current object class name.
  98119. * @return the class name
  98120. */
  98121. getClassName(): string;
  98122. }
  98123. }
  98124. declare module BABYLON {
  98125. /**
  98126. * Gather the list of keyboard event types as constants.
  98127. */
  98128. export class KeyboardEventTypes {
  98129. /**
  98130. * The keydown event is fired when a key becomes active (pressed).
  98131. */
  98132. static readonly KEYDOWN: number;
  98133. /**
  98134. * The keyup event is fired when a key has been released.
  98135. */
  98136. static readonly KEYUP: number;
  98137. }
  98138. /**
  98139. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98140. */
  98141. export class KeyboardInfo {
  98142. /**
  98143. * Defines the type of event (KeyboardEventTypes)
  98144. */
  98145. type: number;
  98146. /**
  98147. * Defines the related dom event
  98148. */
  98149. event: KeyboardEvent;
  98150. /**
  98151. * Instantiates a new keyboard info.
  98152. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98153. * @param type Defines the type of event (KeyboardEventTypes)
  98154. * @param event Defines the related dom event
  98155. */
  98156. constructor(
  98157. /**
  98158. * Defines the type of event (KeyboardEventTypes)
  98159. */
  98160. type: number,
  98161. /**
  98162. * Defines the related dom event
  98163. */
  98164. event: KeyboardEvent);
  98165. }
  98166. /**
  98167. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98168. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  98169. */
  98170. export class KeyboardInfoPre extends KeyboardInfo {
  98171. /**
  98172. * Defines the type of event (KeyboardEventTypes)
  98173. */
  98174. type: number;
  98175. /**
  98176. * Defines the related dom event
  98177. */
  98178. event: KeyboardEvent;
  98179. /**
  98180. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  98181. */
  98182. skipOnPointerObservable: boolean;
  98183. /**
  98184. * Instantiates a new keyboard pre info.
  98185. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98186. * @param type Defines the type of event (KeyboardEventTypes)
  98187. * @param event Defines the related dom event
  98188. */
  98189. constructor(
  98190. /**
  98191. * Defines the type of event (KeyboardEventTypes)
  98192. */
  98193. type: number,
  98194. /**
  98195. * Defines the related dom event
  98196. */
  98197. event: KeyboardEvent);
  98198. }
  98199. }
  98200. declare module BABYLON {
  98201. /**
  98202. * Manage the keyboard inputs to control the movement of a free camera.
  98203. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98204. */
  98205. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  98206. /**
  98207. * Defines the camera the input is attached to.
  98208. */
  98209. camera: FreeCamera;
  98210. /**
  98211. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98212. */
  98213. keysUp: number[];
  98214. /**
  98215. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98216. */
  98217. keysUpward: number[];
  98218. /**
  98219. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98220. */
  98221. keysDown: number[];
  98222. /**
  98223. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98224. */
  98225. keysDownward: number[];
  98226. /**
  98227. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98228. */
  98229. keysLeft: number[];
  98230. /**
  98231. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98232. */
  98233. keysRight: number[];
  98234. private _keys;
  98235. private _onCanvasBlurObserver;
  98236. private _onKeyboardObserver;
  98237. private _engine;
  98238. private _scene;
  98239. /**
  98240. * Attach the input controls to a specific dom element to get the input from.
  98241. * @param element Defines the element the controls should be listened from
  98242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98243. */
  98244. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98245. /**
  98246. * Detach the current controls from the specified dom element.
  98247. * @param element Defines the element to stop listening the inputs from
  98248. */
  98249. detachControl(element: Nullable<HTMLElement>): void;
  98250. /**
  98251. * Update the current camera state depending on the inputs that have been used this frame.
  98252. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98253. */
  98254. checkInputs(): void;
  98255. /**
  98256. * Gets the class name of the current intput.
  98257. * @returns the class name
  98258. */
  98259. getClassName(): string;
  98260. /** @hidden */
  98261. _onLostFocus(): void;
  98262. /**
  98263. * Get the friendly name associated with the input class.
  98264. * @returns the input friendly name
  98265. */
  98266. getSimpleName(): string;
  98267. }
  98268. }
  98269. declare module BABYLON {
  98270. /**
  98271. * Gather the list of pointer event types as constants.
  98272. */
  98273. export class PointerEventTypes {
  98274. /**
  98275. * 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.
  98276. */
  98277. static readonly POINTERDOWN: number;
  98278. /**
  98279. * The pointerup event is fired when a pointer is no longer active.
  98280. */
  98281. static readonly POINTERUP: number;
  98282. /**
  98283. * The pointermove event is fired when a pointer changes coordinates.
  98284. */
  98285. static readonly POINTERMOVE: number;
  98286. /**
  98287. * The pointerwheel event is fired when a mouse wheel has been rotated.
  98288. */
  98289. static readonly POINTERWHEEL: number;
  98290. /**
  98291. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  98292. */
  98293. static readonly POINTERPICK: number;
  98294. /**
  98295. * The pointertap event is fired when a the object has been touched and released without drag.
  98296. */
  98297. static readonly POINTERTAP: number;
  98298. /**
  98299. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  98300. */
  98301. static readonly POINTERDOUBLETAP: number;
  98302. }
  98303. /**
  98304. * Base class of pointer info types.
  98305. */
  98306. export class PointerInfoBase {
  98307. /**
  98308. * Defines the type of event (PointerEventTypes)
  98309. */
  98310. type: number;
  98311. /**
  98312. * Defines the related dom event
  98313. */
  98314. event: PointerEvent | MouseWheelEvent;
  98315. /**
  98316. * Instantiates the base class of pointers info.
  98317. * @param type Defines the type of event (PointerEventTypes)
  98318. * @param event Defines the related dom event
  98319. */
  98320. constructor(
  98321. /**
  98322. * Defines the type of event (PointerEventTypes)
  98323. */
  98324. type: number,
  98325. /**
  98326. * Defines the related dom event
  98327. */
  98328. event: PointerEvent | MouseWheelEvent);
  98329. }
  98330. /**
  98331. * This class is used to store pointer related info for the onPrePointerObservable event.
  98332. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  98333. */
  98334. export class PointerInfoPre extends PointerInfoBase {
  98335. /**
  98336. * Ray from a pointer if availible (eg. 6dof controller)
  98337. */
  98338. ray: Nullable<Ray>;
  98339. /**
  98340. * Defines the local position of the pointer on the canvas.
  98341. */
  98342. localPosition: Vector2;
  98343. /**
  98344. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  98345. */
  98346. skipOnPointerObservable: boolean;
  98347. /**
  98348. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  98349. * @param type Defines the type of event (PointerEventTypes)
  98350. * @param event Defines the related dom event
  98351. * @param localX Defines the local x coordinates of the pointer when the event occured
  98352. * @param localY Defines the local y coordinates of the pointer when the event occured
  98353. */
  98354. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  98355. }
  98356. /**
  98357. * This type contains all the data related to a pointer event in Babylon.js.
  98358. * 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.
  98359. */
  98360. export class PointerInfo extends PointerInfoBase {
  98361. /**
  98362. * Defines the picking info associated to the info (if any)\
  98363. */
  98364. pickInfo: Nullable<PickingInfo>;
  98365. /**
  98366. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  98367. * @param type Defines the type of event (PointerEventTypes)
  98368. * @param event Defines the related dom event
  98369. * @param pickInfo Defines the picking info associated to the info (if any)\
  98370. */
  98371. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  98372. /**
  98373. * Defines the picking info associated to the info (if any)\
  98374. */
  98375. pickInfo: Nullable<PickingInfo>);
  98376. }
  98377. /**
  98378. * Data relating to a touch event on the screen.
  98379. */
  98380. export interface PointerTouch {
  98381. /**
  98382. * X coordinate of touch.
  98383. */
  98384. x: number;
  98385. /**
  98386. * Y coordinate of touch.
  98387. */
  98388. y: number;
  98389. /**
  98390. * Id of touch. Unique for each finger.
  98391. */
  98392. pointerId: number;
  98393. /**
  98394. * Event type passed from DOM.
  98395. */
  98396. type: any;
  98397. }
  98398. }
  98399. declare module BABYLON {
  98400. /**
  98401. * Manage the mouse inputs to control the movement of a free camera.
  98402. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98403. */
  98404. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  98405. /**
  98406. * Define if touch is enabled in the mouse input
  98407. */
  98408. touchEnabled: boolean;
  98409. /**
  98410. * Defines the camera the input is attached to.
  98411. */
  98412. camera: FreeCamera;
  98413. /**
  98414. * Defines the buttons associated with the input to handle camera move.
  98415. */
  98416. buttons: number[];
  98417. /**
  98418. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  98419. */
  98420. angularSensibility: number;
  98421. private _pointerInput;
  98422. private _onMouseMove;
  98423. private _observer;
  98424. private previousPosition;
  98425. /**
  98426. * Observable for when a pointer move event occurs containing the move offset
  98427. */
  98428. onPointerMovedObservable: Observable<{
  98429. offsetX: number;
  98430. offsetY: number;
  98431. }>;
  98432. /**
  98433. * @hidden
  98434. * If the camera should be rotated automatically based on pointer movement
  98435. */
  98436. _allowCameraRotation: boolean;
  98437. /**
  98438. * Manage the mouse inputs to control the movement of a free camera.
  98439. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98440. * @param touchEnabled Defines if touch is enabled or not
  98441. */
  98442. constructor(
  98443. /**
  98444. * Define if touch is enabled in the mouse input
  98445. */
  98446. touchEnabled?: boolean);
  98447. /**
  98448. * Attach the input controls to a specific dom element to get the input from.
  98449. * @param element Defines the element the controls should be listened from
  98450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98451. */
  98452. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98453. /**
  98454. * Called on JS contextmenu event.
  98455. * Override this method to provide functionality.
  98456. */
  98457. protected onContextMenu(evt: PointerEvent): void;
  98458. /**
  98459. * Detach the current controls from the specified dom element.
  98460. * @param element Defines the element to stop listening the inputs from
  98461. */
  98462. detachControl(element: Nullable<HTMLElement>): void;
  98463. /**
  98464. * Gets the class name of the current intput.
  98465. * @returns the class name
  98466. */
  98467. getClassName(): string;
  98468. /**
  98469. * Get the friendly name associated with the input class.
  98470. * @returns the input friendly name
  98471. */
  98472. getSimpleName(): string;
  98473. }
  98474. }
  98475. declare module BABYLON {
  98476. /**
  98477. * Manage the touch inputs to control the movement of a free camera.
  98478. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98479. */
  98480. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  98481. /**
  98482. * Define if mouse events can be treated as touch events
  98483. */
  98484. allowMouse: boolean;
  98485. /**
  98486. * Defines the camera the input is attached to.
  98487. */
  98488. camera: FreeCamera;
  98489. /**
  98490. * Defines the touch sensibility for rotation.
  98491. * The higher the faster.
  98492. */
  98493. touchAngularSensibility: number;
  98494. /**
  98495. * Defines the touch sensibility for move.
  98496. * The higher the faster.
  98497. */
  98498. touchMoveSensibility: number;
  98499. private _offsetX;
  98500. private _offsetY;
  98501. private _pointerPressed;
  98502. private _pointerInput;
  98503. private _observer;
  98504. private _onLostFocus;
  98505. /**
  98506. * Manage the touch inputs to control the movement of a free camera.
  98507. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98508. * @param allowMouse Defines if mouse events can be treated as touch events
  98509. */
  98510. constructor(
  98511. /**
  98512. * Define if mouse events can be treated as touch events
  98513. */
  98514. allowMouse?: boolean);
  98515. /**
  98516. * Attach the input controls to a specific dom element to get the input from.
  98517. * @param element Defines the element the controls should be listened from
  98518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98519. */
  98520. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98521. /**
  98522. * Detach the current controls from the specified dom element.
  98523. * @param element Defines the element to stop listening the inputs from
  98524. */
  98525. detachControl(element: Nullable<HTMLElement>): void;
  98526. /**
  98527. * Update the current camera state depending on the inputs that have been used this frame.
  98528. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98529. */
  98530. checkInputs(): void;
  98531. /**
  98532. * Gets the class name of the current intput.
  98533. * @returns the class name
  98534. */
  98535. getClassName(): string;
  98536. /**
  98537. * Get the friendly name associated with the input class.
  98538. * @returns the input friendly name
  98539. */
  98540. getSimpleName(): string;
  98541. }
  98542. }
  98543. declare module BABYLON {
  98544. /**
  98545. * Default Inputs manager for the FreeCamera.
  98546. * It groups all the default supported inputs for ease of use.
  98547. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98548. */
  98549. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  98550. /**
  98551. * @hidden
  98552. */
  98553. _mouseInput: Nullable<FreeCameraMouseInput>;
  98554. /**
  98555. * Instantiates a new FreeCameraInputsManager.
  98556. * @param camera Defines the camera the inputs belong to
  98557. */
  98558. constructor(camera: FreeCamera);
  98559. /**
  98560. * Add keyboard input support to the input manager.
  98561. * @returns the current input manager
  98562. */
  98563. addKeyboard(): FreeCameraInputsManager;
  98564. /**
  98565. * Add mouse input support to the input manager.
  98566. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  98567. * @returns the current input manager
  98568. */
  98569. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  98570. /**
  98571. * Removes the mouse input support from the manager
  98572. * @returns the current input manager
  98573. */
  98574. removeMouse(): FreeCameraInputsManager;
  98575. /**
  98576. * Add touch input support to the input manager.
  98577. * @returns the current input manager
  98578. */
  98579. addTouch(): FreeCameraInputsManager;
  98580. /**
  98581. * Remove all attached input methods from a camera
  98582. */
  98583. clear(): void;
  98584. }
  98585. }
  98586. declare module BABYLON {
  98587. /**
  98588. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98589. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  98590. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  98591. */
  98592. export class FreeCamera extends TargetCamera {
  98593. /**
  98594. * Define the collision ellipsoid of the camera.
  98595. * This is helpful to simulate a camera body like the player body around the camera
  98596. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98597. */
  98598. ellipsoid: Vector3;
  98599. /**
  98600. * Define an offset for the position of the ellipsoid around the camera.
  98601. * This can be helpful to determine the center of the body near the gravity center of the body
  98602. * instead of its head.
  98603. */
  98604. ellipsoidOffset: Vector3;
  98605. /**
  98606. * Enable or disable collisions of the camera with the rest of the scene objects.
  98607. */
  98608. checkCollisions: boolean;
  98609. /**
  98610. * Enable or disable gravity on the camera.
  98611. */
  98612. applyGravity: boolean;
  98613. /**
  98614. * Define the input manager associated to the camera.
  98615. */
  98616. inputs: FreeCameraInputsManager;
  98617. /**
  98618. * Gets the input sensibility for a mouse input. (default is 2000.0)
  98619. * Higher values reduce sensitivity.
  98620. */
  98621. get angularSensibility(): number;
  98622. /**
  98623. * Sets the input sensibility for a mouse input. (default is 2000.0)
  98624. * Higher values reduce sensitivity.
  98625. */
  98626. set angularSensibility(value: number);
  98627. /**
  98628. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98629. */
  98630. get keysUp(): number[];
  98631. set keysUp(value: number[]);
  98632. /**
  98633. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98634. */
  98635. get keysUpward(): number[];
  98636. set keysUpward(value: number[]);
  98637. /**
  98638. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98639. */
  98640. get keysDown(): number[];
  98641. set keysDown(value: number[]);
  98642. /**
  98643. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98644. */
  98645. get keysDownward(): number[];
  98646. set keysDownward(value: number[]);
  98647. /**
  98648. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98649. */
  98650. get keysLeft(): number[];
  98651. set keysLeft(value: number[]);
  98652. /**
  98653. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98654. */
  98655. get keysRight(): number[];
  98656. set keysRight(value: number[]);
  98657. /**
  98658. * Event raised when the camera collide with a mesh in the scene.
  98659. */
  98660. onCollide: (collidedMesh: AbstractMesh) => void;
  98661. private _collider;
  98662. private _needMoveForGravity;
  98663. private _oldPosition;
  98664. private _diffPosition;
  98665. private _newPosition;
  98666. /** @hidden */
  98667. _localDirection: Vector3;
  98668. /** @hidden */
  98669. _transformedDirection: Vector3;
  98670. /**
  98671. * Instantiates a Free Camera.
  98672. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98673. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  98674. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  98675. * @param name Define the name of the camera in the scene
  98676. * @param position Define the start position of the camera in the scene
  98677. * @param scene Define the scene the camera belongs to
  98678. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98679. */
  98680. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98681. /**
  98682. * Attached controls to the current camera.
  98683. * @param element Defines the element the controls should be listened from
  98684. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98685. */
  98686. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98687. /**
  98688. * Detach the current controls from the camera.
  98689. * The camera will stop reacting to inputs.
  98690. * @param element Defines the element to stop listening the inputs from
  98691. */
  98692. detachControl(element: HTMLElement): void;
  98693. private _collisionMask;
  98694. /**
  98695. * Define a collision mask to limit the list of object the camera can collide with
  98696. */
  98697. get collisionMask(): number;
  98698. set collisionMask(mask: number);
  98699. /** @hidden */
  98700. _collideWithWorld(displacement: Vector3): void;
  98701. private _onCollisionPositionChange;
  98702. /** @hidden */
  98703. _checkInputs(): void;
  98704. /** @hidden */
  98705. _decideIfNeedsToMove(): boolean;
  98706. /** @hidden */
  98707. _updatePosition(): void;
  98708. /**
  98709. * Destroy the camera and release the current resources hold by it.
  98710. */
  98711. dispose(): void;
  98712. /**
  98713. * Gets the current object class name.
  98714. * @return the class name
  98715. */
  98716. getClassName(): string;
  98717. }
  98718. }
  98719. declare module BABYLON {
  98720. /**
  98721. * Represents a gamepad control stick position
  98722. */
  98723. export class StickValues {
  98724. /**
  98725. * The x component of the control stick
  98726. */
  98727. x: number;
  98728. /**
  98729. * The y component of the control stick
  98730. */
  98731. y: number;
  98732. /**
  98733. * Initializes the gamepad x and y control stick values
  98734. * @param x The x component of the gamepad control stick value
  98735. * @param y The y component of the gamepad control stick value
  98736. */
  98737. constructor(
  98738. /**
  98739. * The x component of the control stick
  98740. */
  98741. x: number,
  98742. /**
  98743. * The y component of the control stick
  98744. */
  98745. y: number);
  98746. }
  98747. /**
  98748. * An interface which manages callbacks for gamepad button changes
  98749. */
  98750. export interface GamepadButtonChanges {
  98751. /**
  98752. * Called when a gamepad has been changed
  98753. */
  98754. changed: boolean;
  98755. /**
  98756. * Called when a gamepad press event has been triggered
  98757. */
  98758. pressChanged: boolean;
  98759. /**
  98760. * Called when a touch event has been triggered
  98761. */
  98762. touchChanged: boolean;
  98763. /**
  98764. * Called when a value has changed
  98765. */
  98766. valueChanged: boolean;
  98767. }
  98768. /**
  98769. * Represents a gamepad
  98770. */
  98771. export class Gamepad {
  98772. /**
  98773. * The id of the gamepad
  98774. */
  98775. id: string;
  98776. /**
  98777. * The index of the gamepad
  98778. */
  98779. index: number;
  98780. /**
  98781. * The browser gamepad
  98782. */
  98783. browserGamepad: any;
  98784. /**
  98785. * Specifies what type of gamepad this represents
  98786. */
  98787. type: number;
  98788. private _leftStick;
  98789. private _rightStick;
  98790. /** @hidden */
  98791. _isConnected: boolean;
  98792. private _leftStickAxisX;
  98793. private _leftStickAxisY;
  98794. private _rightStickAxisX;
  98795. private _rightStickAxisY;
  98796. /**
  98797. * Triggered when the left control stick has been changed
  98798. */
  98799. private _onleftstickchanged;
  98800. /**
  98801. * Triggered when the right control stick has been changed
  98802. */
  98803. private _onrightstickchanged;
  98804. /**
  98805. * Represents a gamepad controller
  98806. */
  98807. static GAMEPAD: number;
  98808. /**
  98809. * Represents a generic controller
  98810. */
  98811. static GENERIC: number;
  98812. /**
  98813. * Represents an XBox controller
  98814. */
  98815. static XBOX: number;
  98816. /**
  98817. * Represents a pose-enabled controller
  98818. */
  98819. static POSE_ENABLED: number;
  98820. /**
  98821. * Represents an Dual Shock controller
  98822. */
  98823. static DUALSHOCK: number;
  98824. /**
  98825. * Specifies whether the left control stick should be Y-inverted
  98826. */
  98827. protected _invertLeftStickY: boolean;
  98828. /**
  98829. * Specifies if the gamepad has been connected
  98830. */
  98831. get isConnected(): boolean;
  98832. /**
  98833. * Initializes the gamepad
  98834. * @param id The id of the gamepad
  98835. * @param index The index of the gamepad
  98836. * @param browserGamepad The browser gamepad
  98837. * @param leftStickX The x component of the left joystick
  98838. * @param leftStickY The y component of the left joystick
  98839. * @param rightStickX The x component of the right joystick
  98840. * @param rightStickY The y component of the right joystick
  98841. */
  98842. constructor(
  98843. /**
  98844. * The id of the gamepad
  98845. */
  98846. id: string,
  98847. /**
  98848. * The index of the gamepad
  98849. */
  98850. index: number,
  98851. /**
  98852. * The browser gamepad
  98853. */
  98854. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  98855. /**
  98856. * Callback triggered when the left joystick has changed
  98857. * @param callback
  98858. */
  98859. onleftstickchanged(callback: (values: StickValues) => void): void;
  98860. /**
  98861. * Callback triggered when the right joystick has changed
  98862. * @param callback
  98863. */
  98864. onrightstickchanged(callback: (values: StickValues) => void): void;
  98865. /**
  98866. * Gets the left joystick
  98867. */
  98868. get leftStick(): StickValues;
  98869. /**
  98870. * Sets the left joystick values
  98871. */
  98872. set leftStick(newValues: StickValues);
  98873. /**
  98874. * Gets the right joystick
  98875. */
  98876. get rightStick(): StickValues;
  98877. /**
  98878. * Sets the right joystick value
  98879. */
  98880. set rightStick(newValues: StickValues);
  98881. /**
  98882. * Updates the gamepad joystick positions
  98883. */
  98884. update(): void;
  98885. /**
  98886. * Disposes the gamepad
  98887. */
  98888. dispose(): void;
  98889. }
  98890. /**
  98891. * Represents a generic gamepad
  98892. */
  98893. export class GenericPad extends Gamepad {
  98894. private _buttons;
  98895. private _onbuttondown;
  98896. private _onbuttonup;
  98897. /**
  98898. * Observable triggered when a button has been pressed
  98899. */
  98900. onButtonDownObservable: Observable<number>;
  98901. /**
  98902. * Observable triggered when a button has been released
  98903. */
  98904. onButtonUpObservable: Observable<number>;
  98905. /**
  98906. * Callback triggered when a button has been pressed
  98907. * @param callback Called when a button has been pressed
  98908. */
  98909. onbuttondown(callback: (buttonPressed: number) => void): void;
  98910. /**
  98911. * Callback triggered when a button has been released
  98912. * @param callback Called when a button has been released
  98913. */
  98914. onbuttonup(callback: (buttonReleased: number) => void): void;
  98915. /**
  98916. * Initializes the generic gamepad
  98917. * @param id The id of the generic gamepad
  98918. * @param index The index of the generic gamepad
  98919. * @param browserGamepad The browser gamepad
  98920. */
  98921. constructor(id: string, index: number, browserGamepad: any);
  98922. private _setButtonValue;
  98923. /**
  98924. * Updates the generic gamepad
  98925. */
  98926. update(): void;
  98927. /**
  98928. * Disposes the generic gamepad
  98929. */
  98930. dispose(): void;
  98931. }
  98932. }
  98933. declare module BABYLON {
  98934. /**
  98935. * Defines the types of pose enabled controllers that are supported
  98936. */
  98937. export enum PoseEnabledControllerType {
  98938. /**
  98939. * HTC Vive
  98940. */
  98941. VIVE = 0,
  98942. /**
  98943. * Oculus Rift
  98944. */
  98945. OCULUS = 1,
  98946. /**
  98947. * Windows mixed reality
  98948. */
  98949. WINDOWS = 2,
  98950. /**
  98951. * Samsung gear VR
  98952. */
  98953. GEAR_VR = 3,
  98954. /**
  98955. * Google Daydream
  98956. */
  98957. DAYDREAM = 4,
  98958. /**
  98959. * Generic
  98960. */
  98961. GENERIC = 5
  98962. }
  98963. /**
  98964. * Defines the MutableGamepadButton interface for the state of a gamepad button
  98965. */
  98966. export interface MutableGamepadButton {
  98967. /**
  98968. * Value of the button/trigger
  98969. */
  98970. value: number;
  98971. /**
  98972. * If the button/trigger is currently touched
  98973. */
  98974. touched: boolean;
  98975. /**
  98976. * If the button/trigger is currently pressed
  98977. */
  98978. pressed: boolean;
  98979. }
  98980. /**
  98981. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  98982. * @hidden
  98983. */
  98984. export interface ExtendedGamepadButton extends GamepadButton {
  98985. /**
  98986. * If the button/trigger is currently pressed
  98987. */
  98988. readonly pressed: boolean;
  98989. /**
  98990. * If the button/trigger is currently touched
  98991. */
  98992. readonly touched: boolean;
  98993. /**
  98994. * Value of the button/trigger
  98995. */
  98996. readonly value: number;
  98997. }
  98998. /** @hidden */
  98999. export interface _GamePadFactory {
  99000. /**
  99001. * Returns whether or not the current gamepad can be created for this type of controller.
  99002. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99003. * @returns true if it can be created, otherwise false
  99004. */
  99005. canCreate(gamepadInfo: any): boolean;
  99006. /**
  99007. * Creates a new instance of the Gamepad.
  99008. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99009. * @returns the new gamepad instance
  99010. */
  99011. create(gamepadInfo: any): Gamepad;
  99012. }
  99013. /**
  99014. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99015. */
  99016. export class PoseEnabledControllerHelper {
  99017. /** @hidden */
  99018. static _ControllerFactories: _GamePadFactory[];
  99019. /** @hidden */
  99020. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  99021. /**
  99022. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99023. * @param vrGamepad the gamepad to initialized
  99024. * @returns a vr controller of the type the gamepad identified as
  99025. */
  99026. static InitiateController(vrGamepad: any): Gamepad;
  99027. }
  99028. /**
  99029. * Defines the PoseEnabledController object that contains state of a vr capable controller
  99030. */
  99031. export class PoseEnabledController extends Gamepad implements PoseControlled {
  99032. /**
  99033. * If the controller is used in a webXR session
  99034. */
  99035. isXR: boolean;
  99036. private _deviceRoomPosition;
  99037. private _deviceRoomRotationQuaternion;
  99038. /**
  99039. * The device position in babylon space
  99040. */
  99041. devicePosition: Vector3;
  99042. /**
  99043. * The device rotation in babylon space
  99044. */
  99045. deviceRotationQuaternion: Quaternion;
  99046. /**
  99047. * The scale factor of the device in babylon space
  99048. */
  99049. deviceScaleFactor: number;
  99050. /**
  99051. * (Likely devicePosition should be used instead) The device position in its room space
  99052. */
  99053. position: Vector3;
  99054. /**
  99055. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  99056. */
  99057. rotationQuaternion: Quaternion;
  99058. /**
  99059. * The type of controller (Eg. Windows mixed reality)
  99060. */
  99061. controllerType: PoseEnabledControllerType;
  99062. protected _calculatedPosition: Vector3;
  99063. private _calculatedRotation;
  99064. /**
  99065. * The raw pose from the device
  99066. */
  99067. rawPose: DevicePose;
  99068. private _trackPosition;
  99069. private _maxRotationDistFromHeadset;
  99070. private _draggedRoomRotation;
  99071. /**
  99072. * @hidden
  99073. */
  99074. _disableTrackPosition(fixedPosition: Vector3): void;
  99075. /**
  99076. * Internal, the mesh attached to the controller
  99077. * @hidden
  99078. */
  99079. _mesh: Nullable<AbstractMesh>;
  99080. private _poseControlledCamera;
  99081. private _leftHandSystemQuaternion;
  99082. /**
  99083. * Internal, matrix used to convert room space to babylon space
  99084. * @hidden
  99085. */
  99086. _deviceToWorld: Matrix;
  99087. /**
  99088. * Node to be used when casting a ray from the controller
  99089. * @hidden
  99090. */
  99091. _pointingPoseNode: Nullable<TransformNode>;
  99092. /**
  99093. * Name of the child mesh that can be used to cast a ray from the controller
  99094. */
  99095. static readonly POINTING_POSE: string;
  99096. /**
  99097. * Creates a new PoseEnabledController from a gamepad
  99098. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  99099. */
  99100. constructor(browserGamepad: any);
  99101. private _workingMatrix;
  99102. /**
  99103. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  99104. */
  99105. update(): void;
  99106. /**
  99107. * Updates only the pose device and mesh without doing any button event checking
  99108. */
  99109. protected _updatePoseAndMesh(): void;
  99110. /**
  99111. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  99112. * @param poseData raw pose fromthe device
  99113. */
  99114. updateFromDevice(poseData: DevicePose): void;
  99115. /**
  99116. * @hidden
  99117. */
  99118. _meshAttachedObservable: Observable<AbstractMesh>;
  99119. /**
  99120. * Attaches a mesh to the controller
  99121. * @param mesh the mesh to be attached
  99122. */
  99123. attachToMesh(mesh: AbstractMesh): void;
  99124. /**
  99125. * Attaches the controllers mesh to a camera
  99126. * @param camera the camera the mesh should be attached to
  99127. */
  99128. attachToPoseControlledCamera(camera: TargetCamera): void;
  99129. /**
  99130. * Disposes of the controller
  99131. */
  99132. dispose(): void;
  99133. /**
  99134. * The mesh that is attached to the controller
  99135. */
  99136. get mesh(): Nullable<AbstractMesh>;
  99137. /**
  99138. * Gets the ray of the controller in the direction the controller is pointing
  99139. * @param length the length the resulting ray should be
  99140. * @returns a ray in the direction the controller is pointing
  99141. */
  99142. getForwardRay(length?: number): Ray;
  99143. }
  99144. }
  99145. declare module BABYLON {
  99146. /**
  99147. * Defines the WebVRController object that represents controllers tracked in 3D space
  99148. */
  99149. export abstract class WebVRController extends PoseEnabledController {
  99150. /**
  99151. * Internal, the default controller model for the controller
  99152. */
  99153. protected _defaultModel: Nullable<AbstractMesh>;
  99154. /**
  99155. * Fired when the trigger state has changed
  99156. */
  99157. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99158. /**
  99159. * Fired when the main button state has changed
  99160. */
  99161. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99162. /**
  99163. * Fired when the secondary button state has changed
  99164. */
  99165. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99166. /**
  99167. * Fired when the pad state has changed
  99168. */
  99169. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  99170. /**
  99171. * Fired when controllers stick values have changed
  99172. */
  99173. onPadValuesChangedObservable: Observable<StickValues>;
  99174. /**
  99175. * Array of button availible on the controller
  99176. */
  99177. protected _buttons: Array<MutableGamepadButton>;
  99178. private _onButtonStateChange;
  99179. /**
  99180. * Fired when a controller button's state has changed
  99181. * @param callback the callback containing the button that was modified
  99182. */
  99183. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  99184. /**
  99185. * X and Y axis corresponding to the controllers joystick
  99186. */
  99187. pad: StickValues;
  99188. /**
  99189. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  99190. */
  99191. hand: string;
  99192. /**
  99193. * The default controller model for the controller
  99194. */
  99195. get defaultModel(): Nullable<AbstractMesh>;
  99196. /**
  99197. * Creates a new WebVRController from a gamepad
  99198. * @param vrGamepad the gamepad that the WebVRController should be created from
  99199. */
  99200. constructor(vrGamepad: any);
  99201. /**
  99202. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  99203. */
  99204. update(): void;
  99205. /**
  99206. * Function to be called when a button is modified
  99207. */
  99208. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99209. /**
  99210. * Loads a mesh and attaches it to the controller
  99211. * @param scene the scene the mesh should be added to
  99212. * @param meshLoaded callback for when the mesh has been loaded
  99213. */
  99214. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99215. private _setButtonValue;
  99216. private _changes;
  99217. private _checkChanges;
  99218. /**
  99219. * Disposes of th webVRCOntroller
  99220. */
  99221. dispose(): void;
  99222. }
  99223. }
  99224. declare module BABYLON {
  99225. /**
  99226. * The HemisphericLight simulates the ambient environment light,
  99227. * so the passed direction is the light reflection direction, not the incoming direction.
  99228. */
  99229. export class HemisphericLight extends Light {
  99230. /**
  99231. * The groundColor is the light in the opposite direction to the one specified during creation.
  99232. * 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.
  99233. */
  99234. groundColor: Color3;
  99235. /**
  99236. * The light reflection direction, not the incoming direction.
  99237. */
  99238. direction: Vector3;
  99239. /**
  99240. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  99241. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  99242. * The HemisphericLight can't cast shadows.
  99243. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99244. * @param name The friendly name of the light
  99245. * @param direction The direction of the light reflection
  99246. * @param scene The scene the light belongs to
  99247. */
  99248. constructor(name: string, direction: Vector3, scene: Scene);
  99249. protected _buildUniformLayout(): void;
  99250. /**
  99251. * Returns the string "HemisphericLight".
  99252. * @return The class name
  99253. */
  99254. getClassName(): string;
  99255. /**
  99256. * Sets the HemisphericLight direction towards the passed target (Vector3).
  99257. * Returns the updated direction.
  99258. * @param target The target the direction should point to
  99259. * @return The computed direction
  99260. */
  99261. setDirectionToTarget(target: Vector3): Vector3;
  99262. /**
  99263. * Returns the shadow generator associated to the light.
  99264. * @returns Always null for hemispheric lights because it does not support shadows.
  99265. */
  99266. getShadowGenerator(): Nullable<IShadowGenerator>;
  99267. /**
  99268. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  99269. * @param effect The effect to update
  99270. * @param lightIndex The index of the light in the effect to update
  99271. * @returns The hemispheric light
  99272. */
  99273. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  99274. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  99275. /**
  99276. * Computes the world matrix of the node
  99277. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  99278. * @param useWasUpdatedFlag defines a reserved property
  99279. * @returns the world matrix
  99280. */
  99281. computeWorldMatrix(): Matrix;
  99282. /**
  99283. * Returns the integer 3.
  99284. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99285. */
  99286. getTypeID(): number;
  99287. /**
  99288. * Prepares the list of defines specific to the light type.
  99289. * @param defines the list of defines
  99290. * @param lightIndex defines the index of the light for the effect
  99291. */
  99292. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99293. }
  99294. }
  99295. declare module BABYLON {
  99296. /** @hidden */
  99297. export var vrMultiviewToSingleviewPixelShader: {
  99298. name: string;
  99299. shader: string;
  99300. };
  99301. }
  99302. declare module BABYLON {
  99303. /**
  99304. * Renders to multiple views with a single draw call
  99305. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  99306. */
  99307. export class MultiviewRenderTarget extends RenderTargetTexture {
  99308. /**
  99309. * Creates a multiview render target
  99310. * @param scene scene used with the render target
  99311. * @param size the size of the render target (used for each view)
  99312. */
  99313. constructor(scene: Scene, size?: number | {
  99314. width: number;
  99315. height: number;
  99316. } | {
  99317. ratio: number;
  99318. });
  99319. /**
  99320. * @hidden
  99321. * @param faceIndex the face index, if its a cube texture
  99322. */
  99323. _bindFrameBuffer(faceIndex?: number): void;
  99324. /**
  99325. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  99326. * @returns the view count
  99327. */
  99328. getViewCount(): number;
  99329. }
  99330. }
  99331. declare module BABYLON {
  99332. interface Engine {
  99333. /**
  99334. * Creates a new multiview render target
  99335. * @param width defines the width of the texture
  99336. * @param height defines the height of the texture
  99337. * @returns the created multiview texture
  99338. */
  99339. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  99340. /**
  99341. * Binds a multiview framebuffer to be drawn to
  99342. * @param multiviewTexture texture to bind
  99343. */
  99344. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  99345. }
  99346. interface Camera {
  99347. /**
  99348. * @hidden
  99349. * 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)
  99350. */
  99351. _useMultiviewToSingleView: boolean;
  99352. /**
  99353. * @hidden
  99354. * 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)
  99355. */
  99356. _multiviewTexture: Nullable<RenderTargetTexture>;
  99357. /**
  99358. * @hidden
  99359. * ensures the multiview texture of the camera exists and has the specified width/height
  99360. * @param width height to set on the multiview texture
  99361. * @param height width to set on the multiview texture
  99362. */
  99363. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  99364. }
  99365. interface Scene {
  99366. /** @hidden */
  99367. _transformMatrixR: Matrix;
  99368. /** @hidden */
  99369. _multiviewSceneUbo: Nullable<UniformBuffer>;
  99370. /** @hidden */
  99371. _createMultiviewUbo(): void;
  99372. /** @hidden */
  99373. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  99374. /** @hidden */
  99375. _renderMultiviewToSingleView(camera: Camera): void;
  99376. }
  99377. }
  99378. declare module BABYLON {
  99379. /**
  99380. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  99381. * This will not be used for webXR as it supports displaying texture arrays directly
  99382. */
  99383. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  99384. /**
  99385. * Gets a string identifying the name of the class
  99386. * @returns "VRMultiviewToSingleviewPostProcess" string
  99387. */
  99388. getClassName(): string;
  99389. /**
  99390. * Initializes a VRMultiviewToSingleview
  99391. * @param name name of the post process
  99392. * @param camera camera to be applied to
  99393. * @param scaleFactor scaling factor to the size of the output texture
  99394. */
  99395. constructor(name: string, camera: Camera, scaleFactor: number);
  99396. }
  99397. }
  99398. declare module BABYLON {
  99399. /**
  99400. * Interface used to define additional presentation attributes
  99401. */
  99402. export interface IVRPresentationAttributes {
  99403. /**
  99404. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  99405. */
  99406. highRefreshRate: boolean;
  99407. /**
  99408. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  99409. */
  99410. foveationLevel: number;
  99411. }
  99412. interface Engine {
  99413. /** @hidden */
  99414. _vrDisplay: any;
  99415. /** @hidden */
  99416. _vrSupported: boolean;
  99417. /** @hidden */
  99418. _oldSize: Size;
  99419. /** @hidden */
  99420. _oldHardwareScaleFactor: number;
  99421. /** @hidden */
  99422. _vrExclusivePointerMode: boolean;
  99423. /** @hidden */
  99424. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  99425. /** @hidden */
  99426. _onVRDisplayPointerRestricted: () => void;
  99427. /** @hidden */
  99428. _onVRDisplayPointerUnrestricted: () => void;
  99429. /** @hidden */
  99430. _onVrDisplayConnect: Nullable<(display: any) => void>;
  99431. /** @hidden */
  99432. _onVrDisplayDisconnect: Nullable<() => void>;
  99433. /** @hidden */
  99434. _onVrDisplayPresentChange: Nullable<() => void>;
  99435. /**
  99436. * Observable signaled when VR display mode changes
  99437. */
  99438. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  99439. /**
  99440. * Observable signaled when VR request present is complete
  99441. */
  99442. onVRRequestPresentComplete: Observable<boolean>;
  99443. /**
  99444. * Observable signaled when VR request present starts
  99445. */
  99446. onVRRequestPresentStart: Observable<Engine>;
  99447. /**
  99448. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  99449. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  99450. */
  99451. isInVRExclusivePointerMode: boolean;
  99452. /**
  99453. * Gets a boolean indicating if a webVR device was detected
  99454. * @returns true if a webVR device was detected
  99455. */
  99456. isVRDevicePresent(): boolean;
  99457. /**
  99458. * Gets the current webVR device
  99459. * @returns the current webVR device (or null)
  99460. */
  99461. getVRDevice(): any;
  99462. /**
  99463. * Initializes a webVR display and starts listening to display change events
  99464. * The onVRDisplayChangedObservable will be notified upon these changes
  99465. * @returns A promise containing a VRDisplay and if vr is supported
  99466. */
  99467. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  99468. /** @hidden */
  99469. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  99470. /**
  99471. * Gets or sets the presentation attributes used to configure VR rendering
  99472. */
  99473. vrPresentationAttributes?: IVRPresentationAttributes;
  99474. /**
  99475. * Call this function to switch to webVR mode
  99476. * Will do nothing if webVR is not supported or if there is no webVR device
  99477. * @param options the webvr options provided to the camera. mainly used for multiview
  99478. * @see https://doc.babylonjs.com/how_to/webvr_camera
  99479. */
  99480. enableVR(options: WebVROptions): void;
  99481. /** @hidden */
  99482. _onVRFullScreenTriggered(): void;
  99483. }
  99484. }
  99485. declare module BABYLON {
  99486. /**
  99487. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  99488. * IMPORTANT!! The data is right-hand data.
  99489. * @export
  99490. * @interface DevicePose
  99491. */
  99492. export interface DevicePose {
  99493. /**
  99494. * The position of the device, values in array are [x,y,z].
  99495. */
  99496. readonly position: Nullable<Float32Array>;
  99497. /**
  99498. * The linearVelocity of the device, values in array are [x,y,z].
  99499. */
  99500. readonly linearVelocity: Nullable<Float32Array>;
  99501. /**
  99502. * The linearAcceleration of the device, values in array are [x,y,z].
  99503. */
  99504. readonly linearAcceleration: Nullable<Float32Array>;
  99505. /**
  99506. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  99507. */
  99508. readonly orientation: Nullable<Float32Array>;
  99509. /**
  99510. * The angularVelocity of the device, values in array are [x,y,z].
  99511. */
  99512. readonly angularVelocity: Nullable<Float32Array>;
  99513. /**
  99514. * The angularAcceleration of the device, values in array are [x,y,z].
  99515. */
  99516. readonly angularAcceleration: Nullable<Float32Array>;
  99517. }
  99518. /**
  99519. * Interface representing a pose controlled object in Babylon.
  99520. * A pose controlled object has both regular pose values as well as pose values
  99521. * from an external device such as a VR head mounted display
  99522. */
  99523. export interface PoseControlled {
  99524. /**
  99525. * The position of the object in babylon space.
  99526. */
  99527. position: Vector3;
  99528. /**
  99529. * The rotation quaternion of the object in babylon space.
  99530. */
  99531. rotationQuaternion: Quaternion;
  99532. /**
  99533. * The position of the device in babylon space.
  99534. */
  99535. devicePosition?: Vector3;
  99536. /**
  99537. * The rotation quaternion of the device in babylon space.
  99538. */
  99539. deviceRotationQuaternion: Quaternion;
  99540. /**
  99541. * The raw pose coming from the device.
  99542. */
  99543. rawPose: Nullable<DevicePose>;
  99544. /**
  99545. * The scale of the device to be used when translating from device space to babylon space.
  99546. */
  99547. deviceScaleFactor: number;
  99548. /**
  99549. * Updates the poseControlled values based on the input device pose.
  99550. * @param poseData the pose data to update the object with
  99551. */
  99552. updateFromDevice(poseData: DevicePose): void;
  99553. }
  99554. /**
  99555. * Set of options to customize the webVRCamera
  99556. */
  99557. export interface WebVROptions {
  99558. /**
  99559. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  99560. */
  99561. trackPosition?: boolean;
  99562. /**
  99563. * Sets the scale of the vrDevice in babylon space. (default: 1)
  99564. */
  99565. positionScale?: number;
  99566. /**
  99567. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  99568. */
  99569. displayName?: string;
  99570. /**
  99571. * Should the native controller meshes be initialized. (default: true)
  99572. */
  99573. controllerMeshes?: boolean;
  99574. /**
  99575. * Creating a default HemiLight only on controllers. (default: true)
  99576. */
  99577. defaultLightingOnControllers?: boolean;
  99578. /**
  99579. * If you don't want to use the default VR button of the helper. (default: false)
  99580. */
  99581. useCustomVRButton?: boolean;
  99582. /**
  99583. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  99584. */
  99585. customVRButton?: HTMLButtonElement;
  99586. /**
  99587. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  99588. */
  99589. rayLength?: number;
  99590. /**
  99591. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  99592. */
  99593. defaultHeight?: number;
  99594. /**
  99595. * If multiview should be used if availible (default: false)
  99596. */
  99597. useMultiview?: boolean;
  99598. }
  99599. /**
  99600. * This represents a WebVR camera.
  99601. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  99602. * @example https://doc.babylonjs.com/how_to/webvr_camera
  99603. */
  99604. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  99605. private webVROptions;
  99606. /**
  99607. * @hidden
  99608. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  99609. */
  99610. _vrDevice: any;
  99611. /**
  99612. * The rawPose of the vrDevice.
  99613. */
  99614. rawPose: Nullable<DevicePose>;
  99615. private _onVREnabled;
  99616. private _specsVersion;
  99617. private _attached;
  99618. private _frameData;
  99619. protected _descendants: Array<Node>;
  99620. private _deviceRoomPosition;
  99621. /** @hidden */
  99622. _deviceRoomRotationQuaternion: Quaternion;
  99623. private _standingMatrix;
  99624. /**
  99625. * Represents device position in babylon space.
  99626. */
  99627. devicePosition: Vector3;
  99628. /**
  99629. * Represents device rotation in babylon space.
  99630. */
  99631. deviceRotationQuaternion: Quaternion;
  99632. /**
  99633. * The scale of the device to be used when translating from device space to babylon space.
  99634. */
  99635. deviceScaleFactor: number;
  99636. private _deviceToWorld;
  99637. private _worldToDevice;
  99638. /**
  99639. * References to the webVR controllers for the vrDevice.
  99640. */
  99641. controllers: Array<WebVRController>;
  99642. /**
  99643. * Emits an event when a controller is attached.
  99644. */
  99645. onControllersAttachedObservable: Observable<WebVRController[]>;
  99646. /**
  99647. * Emits an event when a controller's mesh has been loaded;
  99648. */
  99649. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99650. /**
  99651. * Emits an event when the HMD's pose has been updated.
  99652. */
  99653. onPoseUpdatedFromDeviceObservable: Observable<any>;
  99654. private _poseSet;
  99655. /**
  99656. * If the rig cameras be used as parent instead of this camera.
  99657. */
  99658. rigParenting: boolean;
  99659. private _lightOnControllers;
  99660. private _defaultHeight?;
  99661. /**
  99662. * Instantiates a WebVRFreeCamera.
  99663. * @param name The name of the WebVRFreeCamera
  99664. * @param position The starting anchor position for the camera
  99665. * @param scene The scene the camera belongs to
  99666. * @param webVROptions a set of customizable options for the webVRCamera
  99667. */
  99668. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  99669. /**
  99670. * Gets the device distance from the ground in meters.
  99671. * @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.
  99672. */
  99673. deviceDistanceToRoomGround(): number;
  99674. /**
  99675. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  99676. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  99677. */
  99678. useStandingMatrix(callback?: (bool: boolean) => void): void;
  99679. /**
  99680. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  99681. * @returns A promise with a boolean set to if the standing matrix is supported.
  99682. */
  99683. useStandingMatrixAsync(): Promise<boolean>;
  99684. /**
  99685. * Disposes the camera
  99686. */
  99687. dispose(): void;
  99688. /**
  99689. * Gets a vrController by name.
  99690. * @param name The name of the controller to retreive
  99691. * @returns the controller matching the name specified or null if not found
  99692. */
  99693. getControllerByName(name: string): Nullable<WebVRController>;
  99694. private _leftController;
  99695. /**
  99696. * The controller corresponding to the users left hand.
  99697. */
  99698. get leftController(): Nullable<WebVRController>;
  99699. private _rightController;
  99700. /**
  99701. * The controller corresponding to the users right hand.
  99702. */
  99703. get rightController(): Nullable<WebVRController>;
  99704. /**
  99705. * Casts a ray forward from the vrCamera's gaze.
  99706. * @param length Length of the ray (default: 100)
  99707. * @returns the ray corresponding to the gaze
  99708. */
  99709. getForwardRay(length?: number): Ray;
  99710. /**
  99711. * @hidden
  99712. * Updates the camera based on device's frame data
  99713. */
  99714. _checkInputs(): void;
  99715. /**
  99716. * Updates the poseControlled values based on the input device pose.
  99717. * @param poseData Pose coming from the device
  99718. */
  99719. updateFromDevice(poseData: DevicePose): void;
  99720. private _htmlElementAttached;
  99721. private _detachIfAttached;
  99722. /**
  99723. * WebVR's attach control will start broadcasting frames to the device.
  99724. * Note that in certain browsers (chrome for example) this function must be called
  99725. * within a user-interaction callback. Example:
  99726. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  99727. *
  99728. * @param element html element to attach the vrDevice to
  99729. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  99730. */
  99731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99732. /**
  99733. * Detaches the camera from the html element and disables VR
  99734. *
  99735. * @param element html element to detach from
  99736. */
  99737. detachControl(element: HTMLElement): void;
  99738. /**
  99739. * @returns the name of this class
  99740. */
  99741. getClassName(): string;
  99742. /**
  99743. * Calls resetPose on the vrDisplay
  99744. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  99745. */
  99746. resetToCurrentRotation(): void;
  99747. /**
  99748. * @hidden
  99749. * Updates the rig cameras (left and right eye)
  99750. */
  99751. _updateRigCameras(): void;
  99752. private _workingVector;
  99753. private _oneVector;
  99754. private _workingMatrix;
  99755. private updateCacheCalled;
  99756. private _correctPositionIfNotTrackPosition;
  99757. /**
  99758. * @hidden
  99759. * Updates the cached values of the camera
  99760. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  99761. */
  99762. _updateCache(ignoreParentClass?: boolean): void;
  99763. /**
  99764. * @hidden
  99765. * Get current device position in babylon world
  99766. */
  99767. _computeDevicePosition(): void;
  99768. /**
  99769. * Updates the current device position and rotation in the babylon world
  99770. */
  99771. update(): void;
  99772. /**
  99773. * @hidden
  99774. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  99775. * @returns an identity matrix
  99776. */
  99777. _getViewMatrix(): Matrix;
  99778. private _tmpMatrix;
  99779. /**
  99780. * This function is called by the two RIG cameras.
  99781. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  99782. * @hidden
  99783. */
  99784. _getWebVRViewMatrix(): Matrix;
  99785. /** @hidden */
  99786. _getWebVRProjectionMatrix(): Matrix;
  99787. private _onGamepadConnectedObserver;
  99788. private _onGamepadDisconnectedObserver;
  99789. private _updateCacheWhenTrackingDisabledObserver;
  99790. /**
  99791. * Initializes the controllers and their meshes
  99792. */
  99793. initControllers(): void;
  99794. }
  99795. }
  99796. declare module BABYLON {
  99797. /**
  99798. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  99799. *
  99800. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  99801. *
  99802. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  99803. */
  99804. export class MaterialHelper {
  99805. /**
  99806. * Bind the current view position to an effect.
  99807. * @param effect The effect to be bound
  99808. * @param scene The scene the eyes position is used from
  99809. * @param variableName name of the shader variable that will hold the eye position
  99810. */
  99811. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  99812. /**
  99813. * Helps preparing the defines values about the UVs in used in the effect.
  99814. * UVs are shared as much as we can accross channels in the shaders.
  99815. * @param texture The texture we are preparing the UVs for
  99816. * @param defines The defines to update
  99817. * @param key The channel key "diffuse", "specular"... used in the shader
  99818. */
  99819. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  99820. /**
  99821. * Binds a texture matrix value to its corrsponding uniform
  99822. * @param texture The texture to bind the matrix for
  99823. * @param uniformBuffer The uniform buffer receivin the data
  99824. * @param key The channel key "diffuse", "specular"... used in the shader
  99825. */
  99826. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  99827. /**
  99828. * Gets the current status of the fog (should it be enabled?)
  99829. * @param mesh defines the mesh to evaluate for fog support
  99830. * @param scene defines the hosting scene
  99831. * @returns true if fog must be enabled
  99832. */
  99833. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  99834. /**
  99835. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  99836. * @param mesh defines the current mesh
  99837. * @param scene defines the current scene
  99838. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  99839. * @param pointsCloud defines if point cloud rendering has to be turned on
  99840. * @param fogEnabled defines if fog has to be turned on
  99841. * @param alphaTest defines if alpha testing has to be turned on
  99842. * @param defines defines the current list of defines
  99843. */
  99844. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  99845. /**
  99846. * Helper used to prepare the list of defines associated with frame values for shader compilation
  99847. * @param scene defines the current scene
  99848. * @param engine defines the current engine
  99849. * @param defines specifies the list of active defines
  99850. * @param useInstances defines if instances have to be turned on
  99851. * @param useClipPlane defines if clip plane have to be turned on
  99852. * @param useInstances defines if instances have to be turned on
  99853. * @param useThinInstances defines if thin instances have to be turned on
  99854. */
  99855. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  99856. /**
  99857. * Prepares the defines for bones
  99858. * @param mesh The mesh containing the geometry data we will draw
  99859. * @param defines The defines to update
  99860. */
  99861. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  99862. /**
  99863. * Prepares the defines for morph targets
  99864. * @param mesh The mesh containing the geometry data we will draw
  99865. * @param defines The defines to update
  99866. */
  99867. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  99868. /**
  99869. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  99870. * @param mesh The mesh containing the geometry data we will draw
  99871. * @param defines The defines to update
  99872. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  99873. * @param useBones Precise whether bones should be used or not (override mesh info)
  99874. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  99875. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  99876. * @returns false if defines are considered not dirty and have not been checked
  99877. */
  99878. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  99879. /**
  99880. * Prepares the defines related to multiview
  99881. * @param scene The scene we are intending to draw
  99882. * @param defines The defines to update
  99883. */
  99884. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  99885. /**
  99886. * Prepares the defines related to the prepass
  99887. * @param scene The scene we are intending to draw
  99888. * @param defines The defines to update
  99889. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  99890. */
  99891. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  99892. /**
  99893. * Prepares the defines related to the light information passed in parameter
  99894. * @param scene The scene we are intending to draw
  99895. * @param mesh The mesh the effect is compiling for
  99896. * @param light The light the effect is compiling for
  99897. * @param lightIndex The index of the light
  99898. * @param defines The defines to update
  99899. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  99900. * @param state Defines the current state regarding what is needed (normals, etc...)
  99901. */
  99902. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  99903. needNormals: boolean;
  99904. needRebuild: boolean;
  99905. shadowEnabled: boolean;
  99906. specularEnabled: boolean;
  99907. lightmapMode: boolean;
  99908. }): void;
  99909. /**
  99910. * Prepares the defines related to the light information passed in parameter
  99911. * @param scene The scene we are intending to draw
  99912. * @param mesh The mesh the effect is compiling for
  99913. * @param defines The defines to update
  99914. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  99915. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  99916. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  99917. * @returns true if normals will be required for the rest of the effect
  99918. */
  99919. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  99920. /**
  99921. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  99922. * @param lightIndex defines the light index
  99923. * @param uniformsList The uniform list
  99924. * @param samplersList The sampler list
  99925. * @param projectedLightTexture defines if projected texture must be used
  99926. * @param uniformBuffersList defines an optional list of uniform buffers
  99927. */
  99928. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  99929. /**
  99930. * Prepares the uniforms and samplers list to be used in the effect
  99931. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  99932. * @param samplersList The sampler list
  99933. * @param defines The defines helping in the list generation
  99934. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  99935. */
  99936. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  99937. /**
  99938. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  99939. * @param defines The defines to update while falling back
  99940. * @param fallbacks The authorized effect fallbacks
  99941. * @param maxSimultaneousLights The maximum number of lights allowed
  99942. * @param rank the current rank of the Effect
  99943. * @returns The newly affected rank
  99944. */
  99945. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  99946. private static _TmpMorphInfluencers;
  99947. /**
  99948. * Prepares the list of attributes required for morph targets according to the effect defines.
  99949. * @param attribs The current list of supported attribs
  99950. * @param mesh The mesh to prepare the morph targets attributes for
  99951. * @param influencers The number of influencers
  99952. */
  99953. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  99954. /**
  99955. * Prepares the list of attributes required for morph targets according to the effect defines.
  99956. * @param attribs The current list of supported attribs
  99957. * @param mesh The mesh to prepare the morph targets attributes for
  99958. * @param defines The current Defines of the effect
  99959. */
  99960. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  99961. /**
  99962. * Prepares the list of attributes required for bones according to the effect defines.
  99963. * @param attribs The current list of supported attribs
  99964. * @param mesh The mesh to prepare the bones attributes for
  99965. * @param defines The current Defines of the effect
  99966. * @param fallbacks The current efffect fallback strategy
  99967. */
  99968. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  99969. /**
  99970. * Check and prepare the list of attributes required for instances according to the effect defines.
  99971. * @param attribs The current list of supported attribs
  99972. * @param defines The current MaterialDefines of the effect
  99973. */
  99974. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  99975. /**
  99976. * Add the list of attributes required for instances to the attribs array.
  99977. * @param attribs The current list of supported attribs
  99978. */
  99979. static PushAttributesForInstances(attribs: string[]): void;
  99980. /**
  99981. * Binds the light information to the effect.
  99982. * @param light The light containing the generator
  99983. * @param effect The effect we are binding the data to
  99984. * @param lightIndex The light index in the effect used to render
  99985. */
  99986. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  99987. /**
  99988. * Binds the lights information from the scene to the effect for the given mesh.
  99989. * @param light Light to bind
  99990. * @param lightIndex Light index
  99991. * @param scene The scene where the light belongs to
  99992. * @param effect The effect we are binding the data to
  99993. * @param useSpecular Defines if specular is supported
  99994. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99995. */
  99996. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99997. /**
  99998. * Binds the lights information from the scene to the effect for the given mesh.
  99999. * @param scene The scene the lights belongs to
  100000. * @param mesh The mesh we are binding the information to render
  100001. * @param effect The effect we are binding the data to
  100002. * @param defines The generated defines for the effect
  100003. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  100004. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100005. */
  100006. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  100007. private static _tempFogColor;
  100008. /**
  100009. * Binds the fog information from the scene to the effect for the given mesh.
  100010. * @param scene The scene the lights belongs to
  100011. * @param mesh The mesh we are binding the information to render
  100012. * @param effect The effect we are binding the data to
  100013. * @param linearSpace Defines if the fog effect is applied in linear space
  100014. */
  100015. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  100016. /**
  100017. * Binds the bones information from the mesh to the effect.
  100018. * @param mesh The mesh we are binding the information to render
  100019. * @param effect The effect we are binding the data to
  100020. */
  100021. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  100022. /**
  100023. * Binds the morph targets information from the mesh to the effect.
  100024. * @param abstractMesh The mesh we are binding the information to render
  100025. * @param effect The effect we are binding the data to
  100026. */
  100027. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  100028. /**
  100029. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  100030. * @param defines The generated defines used in the effect
  100031. * @param effect The effect we are binding the data to
  100032. * @param scene The scene we are willing to render with logarithmic scale for
  100033. */
  100034. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  100035. /**
  100036. * Binds the clip plane information from the scene to the effect.
  100037. * @param scene The scene the clip plane information are extracted from
  100038. * @param effect The effect we are binding the data to
  100039. */
  100040. static BindClipPlane(effect: Effect, scene: Scene): void;
  100041. }
  100042. }
  100043. declare module BABYLON {
  100044. /**
  100045. * Block used to expose an input value
  100046. */
  100047. export class InputBlock extends NodeMaterialBlock {
  100048. private _mode;
  100049. private _associatedVariableName;
  100050. private _storedValue;
  100051. private _valueCallback;
  100052. private _type;
  100053. private _animationType;
  100054. /** Gets or set a value used to limit the range of float values */
  100055. min: number;
  100056. /** Gets or set a value used to limit the range of float values */
  100057. max: number;
  100058. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  100059. isBoolean: boolean;
  100060. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  100061. matrixMode: number;
  100062. /** @hidden */
  100063. _systemValue: Nullable<NodeMaterialSystemValues>;
  100064. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  100065. visibleInInspector: boolean;
  100066. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  100067. isConstant: boolean;
  100068. /** Gets or sets the group to use to display this block in the Inspector */
  100069. groupInInspector: string;
  100070. /** Gets an observable raised when the value is changed */
  100071. onValueChangedObservable: Observable<InputBlock>;
  100072. /**
  100073. * Gets or sets the connection point type (default is float)
  100074. */
  100075. get type(): NodeMaterialBlockConnectionPointTypes;
  100076. /**
  100077. * Creates a new InputBlock
  100078. * @param name defines the block name
  100079. * @param target defines the target of that block (Vertex by default)
  100080. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  100081. */
  100082. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  100083. /**
  100084. * Validates if a name is a reserve word.
  100085. * @param newName the new name to be given to the node.
  100086. * @returns false if the name is a reserve word, else true.
  100087. */
  100088. validateBlockName(newName: string): boolean;
  100089. /**
  100090. * Gets the output component
  100091. */
  100092. get output(): NodeMaterialConnectionPoint;
  100093. /**
  100094. * Set the source of this connection point to a vertex attribute
  100095. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  100096. * @returns the current connection point
  100097. */
  100098. setAsAttribute(attributeName?: string): InputBlock;
  100099. /**
  100100. * Set the source of this connection point to a system value
  100101. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  100102. * @returns the current connection point
  100103. */
  100104. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  100105. /**
  100106. * Gets or sets the value of that point.
  100107. * Please note that this value will be ignored if valueCallback is defined
  100108. */
  100109. get value(): any;
  100110. set value(value: any);
  100111. /**
  100112. * Gets or sets a callback used to get the value of that point.
  100113. * Please note that setting this value will force the connection point to ignore the value property
  100114. */
  100115. get valueCallback(): () => any;
  100116. set valueCallback(value: () => any);
  100117. /**
  100118. * Gets or sets the associated variable name in the shader
  100119. */
  100120. get associatedVariableName(): string;
  100121. set associatedVariableName(value: string);
  100122. /** Gets or sets the type of animation applied to the input */
  100123. get animationType(): AnimatedInputBlockTypes;
  100124. set animationType(value: AnimatedInputBlockTypes);
  100125. /**
  100126. * Gets a boolean indicating that this connection point not defined yet
  100127. */
  100128. get isUndefined(): boolean;
  100129. /**
  100130. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  100131. * In this case the connection point name must be the name of the uniform to use.
  100132. * Can only be set on inputs
  100133. */
  100134. get isUniform(): boolean;
  100135. set isUniform(value: boolean);
  100136. /**
  100137. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  100138. * In this case the connection point name must be the name of the attribute to use
  100139. * Can only be set on inputs
  100140. */
  100141. get isAttribute(): boolean;
  100142. set isAttribute(value: boolean);
  100143. /**
  100144. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  100145. * Can only be set on exit points
  100146. */
  100147. get isVarying(): boolean;
  100148. set isVarying(value: boolean);
  100149. /**
  100150. * Gets a boolean indicating that the current connection point is a system value
  100151. */
  100152. get isSystemValue(): boolean;
  100153. /**
  100154. * Gets or sets the current well known value or null if not defined as a system value
  100155. */
  100156. get systemValue(): Nullable<NodeMaterialSystemValues>;
  100157. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  100158. /**
  100159. * Gets the current class name
  100160. * @returns the class name
  100161. */
  100162. getClassName(): string;
  100163. /**
  100164. * Animate the input if animationType !== None
  100165. * @param scene defines the rendering scene
  100166. */
  100167. animate(scene: Scene): void;
  100168. private _emitDefine;
  100169. initialize(state: NodeMaterialBuildState): void;
  100170. /**
  100171. * Set the input block to its default value (based on its type)
  100172. */
  100173. setDefaultValue(): void;
  100174. private _emitConstant;
  100175. /** @hidden */
  100176. get _noContextSwitch(): boolean;
  100177. private _emit;
  100178. /** @hidden */
  100179. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  100180. /** @hidden */
  100181. _transmit(effect: Effect, scene: Scene): void;
  100182. protected _buildBlock(state: NodeMaterialBuildState): void;
  100183. protected _dumpPropertiesCode(): string;
  100184. dispose(): void;
  100185. serialize(): any;
  100186. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100187. }
  100188. }
  100189. declare module BABYLON {
  100190. /**
  100191. * Enum used to define the compatibility state between two connection points
  100192. */
  100193. export enum NodeMaterialConnectionPointCompatibilityStates {
  100194. /** Points are compatibles */
  100195. Compatible = 0,
  100196. /** Points are incompatible because of their types */
  100197. TypeIncompatible = 1,
  100198. /** Points are incompatible because of their targets (vertex vs fragment) */
  100199. TargetIncompatible = 2
  100200. }
  100201. /**
  100202. * Defines the direction of a connection point
  100203. */
  100204. export enum NodeMaterialConnectionPointDirection {
  100205. /** Input */
  100206. Input = 0,
  100207. /** Output */
  100208. Output = 1
  100209. }
  100210. /**
  100211. * Defines a connection point for a block
  100212. */
  100213. export class NodeMaterialConnectionPoint {
  100214. /** @hidden */
  100215. _ownerBlock: NodeMaterialBlock;
  100216. /** @hidden */
  100217. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  100218. private _endpoints;
  100219. private _associatedVariableName;
  100220. private _direction;
  100221. /** @hidden */
  100222. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100223. /** @hidden */
  100224. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100225. private _type;
  100226. /** @hidden */
  100227. _enforceAssociatedVariableName: boolean;
  100228. /** Gets the direction of the point */
  100229. get direction(): NodeMaterialConnectionPointDirection;
  100230. /** Indicates that this connection point needs dual validation before being connected to another point */
  100231. needDualDirectionValidation: boolean;
  100232. /**
  100233. * Gets or sets the additional types supported by this connection point
  100234. */
  100235. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100236. /**
  100237. * Gets or sets the additional types excluded by this connection point
  100238. */
  100239. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100240. /**
  100241. * Observable triggered when this point is connected
  100242. */
  100243. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  100244. /**
  100245. * Gets or sets the associated variable name in the shader
  100246. */
  100247. get associatedVariableName(): string;
  100248. set associatedVariableName(value: string);
  100249. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  100250. get innerType(): NodeMaterialBlockConnectionPointTypes;
  100251. /**
  100252. * Gets or sets the connection point type (default is float)
  100253. */
  100254. get type(): NodeMaterialBlockConnectionPointTypes;
  100255. set type(value: NodeMaterialBlockConnectionPointTypes);
  100256. /**
  100257. * Gets or sets the connection point name
  100258. */
  100259. name: string;
  100260. /**
  100261. * Gets or sets the connection point name
  100262. */
  100263. displayName: string;
  100264. /**
  100265. * Gets or sets a boolean indicating that this connection point can be omitted
  100266. */
  100267. isOptional: boolean;
  100268. /**
  100269. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  100270. */
  100271. isExposedOnFrame: boolean;
  100272. /**
  100273. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  100274. */
  100275. define: string;
  100276. /** @hidden */
  100277. _prioritizeVertex: boolean;
  100278. private _target;
  100279. /** Gets or sets the target of that connection point */
  100280. get target(): NodeMaterialBlockTargets;
  100281. set target(value: NodeMaterialBlockTargets);
  100282. /**
  100283. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  100284. */
  100285. get isConnected(): boolean;
  100286. /**
  100287. * Gets a boolean indicating that the current point is connected to an input block
  100288. */
  100289. get isConnectedToInputBlock(): boolean;
  100290. /**
  100291. * Gets a the connected input block (if any)
  100292. */
  100293. get connectInputBlock(): Nullable<InputBlock>;
  100294. /** Get the other side of the connection (if any) */
  100295. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  100296. /** Get the block that owns this connection point */
  100297. get ownerBlock(): NodeMaterialBlock;
  100298. /** Get the block connected on the other side of this connection (if any) */
  100299. get sourceBlock(): Nullable<NodeMaterialBlock>;
  100300. /** Get the block connected on the endpoints of this connection (if any) */
  100301. get connectedBlocks(): Array<NodeMaterialBlock>;
  100302. /** Gets the list of connected endpoints */
  100303. get endpoints(): NodeMaterialConnectionPoint[];
  100304. /** Gets a boolean indicating if that output point is connected to at least one input */
  100305. get hasEndpoints(): boolean;
  100306. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  100307. get isConnectedInVertexShader(): boolean;
  100308. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  100309. get isConnectedInFragmentShader(): boolean;
  100310. /**
  100311. * Creates a block suitable to be used as an input for this input point.
  100312. * If null is returned, a block based on the point type will be created.
  100313. * @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
  100314. */
  100315. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  100316. /**
  100317. * Creates a new connection point
  100318. * @param name defines the connection point name
  100319. * @param ownerBlock defines the block hosting this connection point
  100320. * @param direction defines the direction of the connection point
  100321. */
  100322. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  100323. /**
  100324. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  100325. * @returns the class name
  100326. */
  100327. getClassName(): string;
  100328. /**
  100329. * Gets a boolean indicating if the current point can be connected to another point
  100330. * @param connectionPoint defines the other connection point
  100331. * @returns a boolean
  100332. */
  100333. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  100334. /**
  100335. * Gets a number indicating if the current point can be connected to another point
  100336. * @param connectionPoint defines the other connection point
  100337. * @returns a number defining the compatibility state
  100338. */
  100339. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  100340. /**
  100341. * Connect this point to another connection point
  100342. * @param connectionPoint defines the other connection point
  100343. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  100344. * @returns the current connection point
  100345. */
  100346. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  100347. /**
  100348. * Disconnect this point from one of his endpoint
  100349. * @param endpoint defines the other connection point
  100350. * @returns the current connection point
  100351. */
  100352. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  100353. /**
  100354. * Serializes this point in a JSON representation
  100355. * @param isInput defines if the connection point is an input (default is true)
  100356. * @returns the serialized point object
  100357. */
  100358. serialize(isInput?: boolean): any;
  100359. /**
  100360. * Release resources
  100361. */
  100362. dispose(): void;
  100363. }
  100364. }
  100365. declare module BABYLON {
  100366. /**
  100367. * Enum used to define the material modes
  100368. */
  100369. export enum NodeMaterialModes {
  100370. /** Regular material */
  100371. Material = 0,
  100372. /** For post process */
  100373. PostProcess = 1,
  100374. /** For particle system */
  100375. Particle = 2
  100376. }
  100377. }
  100378. declare module BABYLON {
  100379. /**
  100380. * Block used to read a texture from a sampler
  100381. */
  100382. export class TextureBlock extends NodeMaterialBlock {
  100383. private _defineName;
  100384. private _linearDefineName;
  100385. private _gammaDefineName;
  100386. private _tempTextureRead;
  100387. private _samplerName;
  100388. private _transformedUVName;
  100389. private _textureTransformName;
  100390. private _textureInfoName;
  100391. private _mainUVName;
  100392. private _mainUVDefineName;
  100393. private _fragmentOnly;
  100394. /**
  100395. * Gets or sets the texture associated with the node
  100396. */
  100397. texture: Nullable<Texture>;
  100398. /**
  100399. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100400. */
  100401. convertToGammaSpace: boolean;
  100402. /**
  100403. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100404. */
  100405. convertToLinearSpace: boolean;
  100406. /**
  100407. * Create a new TextureBlock
  100408. * @param name defines the block name
  100409. */
  100410. constructor(name: string, fragmentOnly?: boolean);
  100411. /**
  100412. * Gets the current class name
  100413. * @returns the class name
  100414. */
  100415. getClassName(): string;
  100416. /**
  100417. * Gets the uv input component
  100418. */
  100419. get uv(): NodeMaterialConnectionPoint;
  100420. /**
  100421. * Gets the rgba output component
  100422. */
  100423. get rgba(): NodeMaterialConnectionPoint;
  100424. /**
  100425. * Gets the rgb output component
  100426. */
  100427. get rgb(): NodeMaterialConnectionPoint;
  100428. /**
  100429. * Gets the r output component
  100430. */
  100431. get r(): NodeMaterialConnectionPoint;
  100432. /**
  100433. * Gets the g output component
  100434. */
  100435. get g(): NodeMaterialConnectionPoint;
  100436. /**
  100437. * Gets the b output component
  100438. */
  100439. get b(): NodeMaterialConnectionPoint;
  100440. /**
  100441. * Gets the a output component
  100442. */
  100443. get a(): NodeMaterialConnectionPoint;
  100444. get target(): NodeMaterialBlockTargets;
  100445. autoConfigure(material: NodeMaterial): void;
  100446. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100447. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100448. isReady(): boolean;
  100449. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  100450. private get _isMixed();
  100451. private _injectVertexCode;
  100452. private _writeTextureRead;
  100453. private _writeOutput;
  100454. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100455. protected _dumpPropertiesCode(): string;
  100456. serialize(): any;
  100457. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100458. }
  100459. }
  100460. declare module BABYLON {
  100461. /** @hidden */
  100462. export var reflectionFunction: {
  100463. name: string;
  100464. shader: string;
  100465. };
  100466. }
  100467. declare module BABYLON {
  100468. /**
  100469. * Base block used to read a reflection texture from a sampler
  100470. */
  100471. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  100472. /** @hidden */
  100473. _define3DName: string;
  100474. /** @hidden */
  100475. _defineCubicName: string;
  100476. /** @hidden */
  100477. _defineExplicitName: string;
  100478. /** @hidden */
  100479. _defineProjectionName: string;
  100480. /** @hidden */
  100481. _defineLocalCubicName: string;
  100482. /** @hidden */
  100483. _defineSphericalName: string;
  100484. /** @hidden */
  100485. _definePlanarName: string;
  100486. /** @hidden */
  100487. _defineEquirectangularName: string;
  100488. /** @hidden */
  100489. _defineMirroredEquirectangularFixedName: string;
  100490. /** @hidden */
  100491. _defineEquirectangularFixedName: string;
  100492. /** @hidden */
  100493. _defineSkyboxName: string;
  100494. /** @hidden */
  100495. _defineOppositeZ: string;
  100496. /** @hidden */
  100497. _cubeSamplerName: string;
  100498. /** @hidden */
  100499. _2DSamplerName: string;
  100500. protected _positionUVWName: string;
  100501. protected _directionWName: string;
  100502. protected _reflectionVectorName: string;
  100503. /** @hidden */
  100504. _reflectionCoordsName: string;
  100505. /** @hidden */
  100506. _reflectionMatrixName: string;
  100507. protected _reflectionColorName: string;
  100508. /**
  100509. * Gets or sets the texture associated with the node
  100510. */
  100511. texture: Nullable<BaseTexture>;
  100512. /**
  100513. * Create a new ReflectionTextureBaseBlock
  100514. * @param name defines the block name
  100515. */
  100516. constructor(name: string);
  100517. /**
  100518. * Gets the current class name
  100519. * @returns the class name
  100520. */
  100521. getClassName(): string;
  100522. /**
  100523. * Gets the world position input component
  100524. */
  100525. abstract get position(): NodeMaterialConnectionPoint;
  100526. /**
  100527. * Gets the world position input component
  100528. */
  100529. abstract get worldPosition(): NodeMaterialConnectionPoint;
  100530. /**
  100531. * Gets the world normal input component
  100532. */
  100533. abstract get worldNormal(): NodeMaterialConnectionPoint;
  100534. /**
  100535. * Gets the world input component
  100536. */
  100537. abstract get world(): NodeMaterialConnectionPoint;
  100538. /**
  100539. * Gets the camera (or eye) position component
  100540. */
  100541. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  100542. /**
  100543. * Gets the view input component
  100544. */
  100545. abstract get view(): NodeMaterialConnectionPoint;
  100546. protected _getTexture(): Nullable<BaseTexture>;
  100547. autoConfigure(material: NodeMaterial): void;
  100548. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100549. isReady(): boolean;
  100550. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  100551. /**
  100552. * Gets the code to inject in the vertex shader
  100553. * @param state current state of the node material building
  100554. * @returns the shader code
  100555. */
  100556. handleVertexSide(state: NodeMaterialBuildState): string;
  100557. /**
  100558. * Handles the inits for the fragment code path
  100559. * @param state node material build state
  100560. */
  100561. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  100562. /**
  100563. * Generates the reflection coords code for the fragment code path
  100564. * @param worldNormalVarName name of the world normal variable
  100565. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  100566. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  100567. * @returns the shader code
  100568. */
  100569. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  100570. /**
  100571. * Generates the reflection color code for the fragment code path
  100572. * @param lodVarName name of the lod variable
  100573. * @param swizzleLookupTexture swizzle to use for the final color variable
  100574. * @returns the shader code
  100575. */
  100576. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  100577. /**
  100578. * Generates the code corresponding to the connected output points
  100579. * @param state node material build state
  100580. * @param varName name of the variable to output
  100581. * @returns the shader code
  100582. */
  100583. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  100584. protected _buildBlock(state: NodeMaterialBuildState): this;
  100585. protected _dumpPropertiesCode(): string;
  100586. serialize(): any;
  100587. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100588. }
  100589. }
  100590. declare module BABYLON {
  100591. /**
  100592. * Defines a connection point to be used for points with a custom object type
  100593. */
  100594. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  100595. private _blockType;
  100596. private _blockName;
  100597. private _nameForCheking?;
  100598. /**
  100599. * Creates a new connection point
  100600. * @param name defines the connection point name
  100601. * @param ownerBlock defines the block hosting this connection point
  100602. * @param direction defines the direction of the connection point
  100603. */
  100604. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  100605. /**
  100606. * Gets a number indicating if the current point can be connected to another point
  100607. * @param connectionPoint defines the other connection point
  100608. * @returns a number defining the compatibility state
  100609. */
  100610. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  100611. /**
  100612. * Creates a block suitable to be used as an input for this input point.
  100613. * If null is returned, a block based on the point type will be created.
  100614. * @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
  100615. */
  100616. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  100617. }
  100618. }
  100619. declare module BABYLON {
  100620. /**
  100621. * Enum defining the type of properties that can be edited in the property pages in the NME
  100622. */
  100623. export enum PropertyTypeForEdition {
  100624. /** property is a boolean */
  100625. Boolean = 0,
  100626. /** property is a float */
  100627. Float = 1,
  100628. /** property is a Vector2 */
  100629. Vector2 = 2,
  100630. /** property is a list of values */
  100631. List = 3
  100632. }
  100633. /**
  100634. * Interface that defines an option in a variable of type list
  100635. */
  100636. export interface IEditablePropertyListOption {
  100637. /** label of the option */
  100638. "label": string;
  100639. /** value of the option */
  100640. "value": number;
  100641. }
  100642. /**
  100643. * Interface that defines the options available for an editable property
  100644. */
  100645. export interface IEditablePropertyOption {
  100646. /** min value */
  100647. "min"?: number;
  100648. /** max value */
  100649. "max"?: number;
  100650. /** notifiers: indicates which actions to take when the property is changed */
  100651. "notifiers"?: {
  100652. /** the material should be rebuilt */
  100653. "rebuild"?: boolean;
  100654. /** the preview should be updated */
  100655. "update"?: boolean;
  100656. };
  100657. /** list of the options for a variable of type list */
  100658. "options"?: IEditablePropertyListOption[];
  100659. }
  100660. /**
  100661. * Interface that describes an editable property
  100662. */
  100663. export interface IPropertyDescriptionForEdition {
  100664. /** name of the property */
  100665. "propertyName": string;
  100666. /** display name of the property */
  100667. "displayName": string;
  100668. /** type of the property */
  100669. "type": PropertyTypeForEdition;
  100670. /** group of the property - all properties with the same group value will be displayed in a specific section */
  100671. "groupName": string;
  100672. /** options for the property */
  100673. "options": IEditablePropertyOption;
  100674. }
  100675. /**
  100676. * Decorator that flags a property in a node material block as being editable
  100677. */
  100678. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  100679. }
  100680. declare module BABYLON {
  100681. /**
  100682. * Block used to implement the refraction part of the sub surface module of the PBR material
  100683. */
  100684. export class RefractionBlock extends NodeMaterialBlock {
  100685. /** @hidden */
  100686. _define3DName: string;
  100687. /** @hidden */
  100688. _refractionMatrixName: string;
  100689. /** @hidden */
  100690. _defineLODRefractionAlpha: string;
  100691. /** @hidden */
  100692. _defineLinearSpecularRefraction: string;
  100693. /** @hidden */
  100694. _defineOppositeZ: string;
  100695. /** @hidden */
  100696. _cubeSamplerName: string;
  100697. /** @hidden */
  100698. _2DSamplerName: string;
  100699. /** @hidden */
  100700. _vRefractionMicrosurfaceInfosName: string;
  100701. /** @hidden */
  100702. _vRefractionInfosName: string;
  100703. private _scene;
  100704. /**
  100705. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  100706. * Materials half opaque for instance using refraction could benefit from this control.
  100707. */
  100708. linkRefractionWithTransparency: boolean;
  100709. /**
  100710. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  100711. */
  100712. invertRefractionY: boolean;
  100713. /**
  100714. * Gets or sets the texture associated with the node
  100715. */
  100716. texture: Nullable<BaseTexture>;
  100717. /**
  100718. * Create a new RefractionBlock
  100719. * @param name defines the block name
  100720. */
  100721. constructor(name: string);
  100722. /**
  100723. * Gets the current class name
  100724. * @returns the class name
  100725. */
  100726. getClassName(): string;
  100727. /**
  100728. * Gets the intensity input component
  100729. */
  100730. get intensity(): NodeMaterialConnectionPoint;
  100731. /**
  100732. * Gets the index of refraction input component
  100733. */
  100734. get indexOfRefraction(): NodeMaterialConnectionPoint;
  100735. /**
  100736. * Gets the tint at distance input component
  100737. */
  100738. get tintAtDistance(): NodeMaterialConnectionPoint;
  100739. /**
  100740. * Gets the view input component
  100741. */
  100742. get view(): NodeMaterialConnectionPoint;
  100743. /**
  100744. * Gets the refraction object output component
  100745. */
  100746. get refraction(): NodeMaterialConnectionPoint;
  100747. /**
  100748. * Returns true if the block has a texture
  100749. */
  100750. get hasTexture(): boolean;
  100751. protected _getTexture(): Nullable<BaseTexture>;
  100752. autoConfigure(material: NodeMaterial): void;
  100753. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100754. isReady(): boolean;
  100755. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  100756. /**
  100757. * Gets the main code of the block (fragment side)
  100758. * @param state current state of the node material building
  100759. * @returns the shader code
  100760. */
  100761. getCode(state: NodeMaterialBuildState): string;
  100762. protected _buildBlock(state: NodeMaterialBuildState): this;
  100763. protected _dumpPropertiesCode(): string;
  100764. serialize(): any;
  100765. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100766. }
  100767. }
  100768. declare module BABYLON {
  100769. /**
  100770. * Base block used as input for post process
  100771. */
  100772. export class CurrentScreenBlock extends NodeMaterialBlock {
  100773. private _samplerName;
  100774. private _linearDefineName;
  100775. private _gammaDefineName;
  100776. private _mainUVName;
  100777. private _tempTextureRead;
  100778. /**
  100779. * Gets or sets the texture associated with the node
  100780. */
  100781. texture: Nullable<BaseTexture>;
  100782. /**
  100783. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100784. */
  100785. convertToGammaSpace: boolean;
  100786. /**
  100787. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100788. */
  100789. convertToLinearSpace: boolean;
  100790. /**
  100791. * Create a new CurrentScreenBlock
  100792. * @param name defines the block name
  100793. */
  100794. constructor(name: string);
  100795. /**
  100796. * Gets the current class name
  100797. * @returns the class name
  100798. */
  100799. getClassName(): string;
  100800. /**
  100801. * Gets the uv input component
  100802. */
  100803. get uv(): NodeMaterialConnectionPoint;
  100804. /**
  100805. * Gets the rgba output component
  100806. */
  100807. get rgba(): NodeMaterialConnectionPoint;
  100808. /**
  100809. * Gets the rgb output component
  100810. */
  100811. get rgb(): NodeMaterialConnectionPoint;
  100812. /**
  100813. * Gets the r output component
  100814. */
  100815. get r(): NodeMaterialConnectionPoint;
  100816. /**
  100817. * Gets the g output component
  100818. */
  100819. get g(): NodeMaterialConnectionPoint;
  100820. /**
  100821. * Gets the b output component
  100822. */
  100823. get b(): NodeMaterialConnectionPoint;
  100824. /**
  100825. * Gets the a output component
  100826. */
  100827. get a(): NodeMaterialConnectionPoint;
  100828. /**
  100829. * Initialize the block and prepare the context for build
  100830. * @param state defines the state that will be used for the build
  100831. */
  100832. initialize(state: NodeMaterialBuildState): void;
  100833. get target(): NodeMaterialBlockTargets;
  100834. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100835. isReady(): boolean;
  100836. private _injectVertexCode;
  100837. private _writeTextureRead;
  100838. private _writeOutput;
  100839. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100840. serialize(): any;
  100841. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100842. }
  100843. }
  100844. declare module BABYLON {
  100845. /**
  100846. * Base block used for the particle texture
  100847. */
  100848. export class ParticleTextureBlock extends NodeMaterialBlock {
  100849. private _samplerName;
  100850. private _linearDefineName;
  100851. private _gammaDefineName;
  100852. private _tempTextureRead;
  100853. /**
  100854. * Gets or sets the texture associated with the node
  100855. */
  100856. texture: Nullable<BaseTexture>;
  100857. /**
  100858. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100859. */
  100860. convertToGammaSpace: boolean;
  100861. /**
  100862. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100863. */
  100864. convertToLinearSpace: boolean;
  100865. /**
  100866. * Create a new ParticleTextureBlock
  100867. * @param name defines the block name
  100868. */
  100869. constructor(name: string);
  100870. /**
  100871. * Gets the current class name
  100872. * @returns the class name
  100873. */
  100874. getClassName(): string;
  100875. /**
  100876. * Gets the uv input component
  100877. */
  100878. get uv(): NodeMaterialConnectionPoint;
  100879. /**
  100880. * Gets the rgba output component
  100881. */
  100882. get rgba(): NodeMaterialConnectionPoint;
  100883. /**
  100884. * Gets the rgb output component
  100885. */
  100886. get rgb(): NodeMaterialConnectionPoint;
  100887. /**
  100888. * Gets the r output component
  100889. */
  100890. get r(): NodeMaterialConnectionPoint;
  100891. /**
  100892. * Gets the g output component
  100893. */
  100894. get g(): NodeMaterialConnectionPoint;
  100895. /**
  100896. * Gets the b output component
  100897. */
  100898. get b(): NodeMaterialConnectionPoint;
  100899. /**
  100900. * Gets the a output component
  100901. */
  100902. get a(): NodeMaterialConnectionPoint;
  100903. /**
  100904. * Initialize the block and prepare the context for build
  100905. * @param state defines the state that will be used for the build
  100906. */
  100907. initialize(state: NodeMaterialBuildState): void;
  100908. autoConfigure(material: NodeMaterial): void;
  100909. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100910. isReady(): boolean;
  100911. private _writeOutput;
  100912. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100913. serialize(): any;
  100914. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100915. }
  100916. }
  100917. declare module BABYLON {
  100918. /**
  100919. * Class used to store shared data between 2 NodeMaterialBuildState
  100920. */
  100921. export class NodeMaterialBuildStateSharedData {
  100922. /**
  100923. * Gets the list of emitted varyings
  100924. */
  100925. temps: string[];
  100926. /**
  100927. * Gets the list of emitted varyings
  100928. */
  100929. varyings: string[];
  100930. /**
  100931. * Gets the varying declaration string
  100932. */
  100933. varyingDeclaration: string;
  100934. /**
  100935. * Input blocks
  100936. */
  100937. inputBlocks: InputBlock[];
  100938. /**
  100939. * Input blocks
  100940. */
  100941. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100942. /**
  100943. * Bindable blocks (Blocks that need to set data to the effect)
  100944. */
  100945. bindableBlocks: NodeMaterialBlock[];
  100946. /**
  100947. * List of blocks that can provide a compilation fallback
  100948. */
  100949. blocksWithFallbacks: NodeMaterialBlock[];
  100950. /**
  100951. * List of blocks that can provide a define update
  100952. */
  100953. blocksWithDefines: NodeMaterialBlock[];
  100954. /**
  100955. * List of blocks that can provide a repeatable content
  100956. */
  100957. repeatableContentBlocks: NodeMaterialBlock[];
  100958. /**
  100959. * List of blocks that can provide a dynamic list of uniforms
  100960. */
  100961. dynamicUniformBlocks: NodeMaterialBlock[];
  100962. /**
  100963. * List of blocks that can block the isReady function for the material
  100964. */
  100965. blockingBlocks: NodeMaterialBlock[];
  100966. /**
  100967. * Gets the list of animated inputs
  100968. */
  100969. animatedInputs: InputBlock[];
  100970. /**
  100971. * Build Id used to avoid multiple recompilations
  100972. */
  100973. buildId: number;
  100974. /** List of emitted variables */
  100975. variableNames: {
  100976. [key: string]: number;
  100977. };
  100978. /** List of emitted defines */
  100979. defineNames: {
  100980. [key: string]: number;
  100981. };
  100982. /** Should emit comments? */
  100983. emitComments: boolean;
  100984. /** Emit build activity */
  100985. verbose: boolean;
  100986. /** Gets or sets the hosting scene */
  100987. scene: Scene;
  100988. /**
  100989. * Gets the compilation hints emitted at compilation time
  100990. */
  100991. hints: {
  100992. needWorldViewMatrix: boolean;
  100993. needWorldViewProjectionMatrix: boolean;
  100994. needAlphaBlending: boolean;
  100995. needAlphaTesting: boolean;
  100996. };
  100997. /**
  100998. * List of compilation checks
  100999. */
  101000. checks: {
  101001. emitVertex: boolean;
  101002. emitFragment: boolean;
  101003. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  101004. };
  101005. /**
  101006. * Is vertex program allowed to be empty?
  101007. */
  101008. allowEmptyVertexProgram: boolean;
  101009. /** Creates a new shared data */
  101010. constructor();
  101011. /**
  101012. * Emits console errors and exceptions if there is a failing check
  101013. */
  101014. emitErrors(): void;
  101015. }
  101016. }
  101017. declare module BABYLON {
  101018. /**
  101019. * Class used to store node based material build state
  101020. */
  101021. export class NodeMaterialBuildState {
  101022. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  101023. supportUniformBuffers: boolean;
  101024. /**
  101025. * Gets the list of emitted attributes
  101026. */
  101027. attributes: string[];
  101028. /**
  101029. * Gets the list of emitted uniforms
  101030. */
  101031. uniforms: string[];
  101032. /**
  101033. * Gets the list of emitted constants
  101034. */
  101035. constants: string[];
  101036. /**
  101037. * Gets the list of emitted samplers
  101038. */
  101039. samplers: string[];
  101040. /**
  101041. * Gets the list of emitted functions
  101042. */
  101043. functions: {
  101044. [key: string]: string;
  101045. };
  101046. /**
  101047. * Gets the list of emitted extensions
  101048. */
  101049. extensions: {
  101050. [key: string]: string;
  101051. };
  101052. /**
  101053. * Gets the target of the compilation state
  101054. */
  101055. target: NodeMaterialBlockTargets;
  101056. /**
  101057. * Gets the list of emitted counters
  101058. */
  101059. counters: {
  101060. [key: string]: number;
  101061. };
  101062. /**
  101063. * Shared data between multiple NodeMaterialBuildState instances
  101064. */
  101065. sharedData: NodeMaterialBuildStateSharedData;
  101066. /** @hidden */
  101067. _vertexState: NodeMaterialBuildState;
  101068. /** @hidden */
  101069. _attributeDeclaration: string;
  101070. /** @hidden */
  101071. _uniformDeclaration: string;
  101072. /** @hidden */
  101073. _constantDeclaration: string;
  101074. /** @hidden */
  101075. _samplerDeclaration: string;
  101076. /** @hidden */
  101077. _varyingTransfer: string;
  101078. /** @hidden */
  101079. _injectAtEnd: string;
  101080. private _repeatableContentAnchorIndex;
  101081. /** @hidden */
  101082. _builtCompilationString: string;
  101083. /**
  101084. * Gets the emitted compilation strings
  101085. */
  101086. compilationString: string;
  101087. /**
  101088. * Finalize the compilation strings
  101089. * @param state defines the current compilation state
  101090. */
  101091. finalize(state: NodeMaterialBuildState): void;
  101092. /** @hidden */
  101093. get _repeatableContentAnchor(): string;
  101094. /** @hidden */
  101095. _getFreeVariableName(prefix: string): string;
  101096. /** @hidden */
  101097. _getFreeDefineName(prefix: string): string;
  101098. /** @hidden */
  101099. _excludeVariableName(name: string): void;
  101100. /** @hidden */
  101101. _emit2DSampler(name: string): void;
  101102. /** @hidden */
  101103. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  101104. /** @hidden */
  101105. _emitExtension(name: string, extension: string, define?: string): void;
  101106. /** @hidden */
  101107. _emitFunction(name: string, code: string, comments: string): void;
  101108. /** @hidden */
  101109. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  101110. replaceStrings?: {
  101111. search: RegExp;
  101112. replace: string;
  101113. }[];
  101114. repeatKey?: string;
  101115. }): string;
  101116. /** @hidden */
  101117. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  101118. repeatKey?: string;
  101119. removeAttributes?: boolean;
  101120. removeUniforms?: boolean;
  101121. removeVaryings?: boolean;
  101122. removeIfDef?: boolean;
  101123. replaceStrings?: {
  101124. search: RegExp;
  101125. replace: string;
  101126. }[];
  101127. }, storeKey?: string): void;
  101128. /** @hidden */
  101129. _registerTempVariable(name: string): boolean;
  101130. /** @hidden */
  101131. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  101132. /** @hidden */
  101133. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  101134. /** @hidden */
  101135. _emitFloat(value: number): string;
  101136. }
  101137. }
  101138. declare module BABYLON {
  101139. /**
  101140. * Helper class used to generate session unique ID
  101141. */
  101142. export class UniqueIdGenerator {
  101143. private static _UniqueIdCounter;
  101144. /**
  101145. * Gets an unique (relatively to the current scene) Id
  101146. */
  101147. static get UniqueId(): number;
  101148. }
  101149. }
  101150. declare module BABYLON {
  101151. /**
  101152. * Defines a block that can be used inside a node based material
  101153. */
  101154. export class NodeMaterialBlock {
  101155. private _buildId;
  101156. private _buildTarget;
  101157. private _target;
  101158. private _isFinalMerger;
  101159. private _isInput;
  101160. private _name;
  101161. protected _isUnique: boolean;
  101162. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  101163. inputsAreExclusive: boolean;
  101164. /** @hidden */
  101165. _codeVariableName: string;
  101166. /** @hidden */
  101167. _inputs: NodeMaterialConnectionPoint[];
  101168. /** @hidden */
  101169. _outputs: NodeMaterialConnectionPoint[];
  101170. /** @hidden */
  101171. _preparationId: number;
  101172. /**
  101173. * Gets the name of the block
  101174. */
  101175. get name(): string;
  101176. /**
  101177. * Sets the name of the block. Will check if the name is valid.
  101178. */
  101179. set name(newName: string);
  101180. /**
  101181. * Gets or sets the unique id of the node
  101182. */
  101183. uniqueId: number;
  101184. /**
  101185. * Gets or sets the comments associated with this block
  101186. */
  101187. comments: string;
  101188. /**
  101189. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  101190. */
  101191. get isUnique(): boolean;
  101192. /**
  101193. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  101194. */
  101195. get isFinalMerger(): boolean;
  101196. /**
  101197. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  101198. */
  101199. get isInput(): boolean;
  101200. /**
  101201. * Gets or sets the build Id
  101202. */
  101203. get buildId(): number;
  101204. set buildId(value: number);
  101205. /**
  101206. * Gets or sets the target of the block
  101207. */
  101208. get target(): NodeMaterialBlockTargets;
  101209. set target(value: NodeMaterialBlockTargets);
  101210. /**
  101211. * Gets the list of input points
  101212. */
  101213. get inputs(): NodeMaterialConnectionPoint[];
  101214. /** Gets the list of output points */
  101215. get outputs(): NodeMaterialConnectionPoint[];
  101216. /**
  101217. * Find an input by its name
  101218. * @param name defines the name of the input to look for
  101219. * @returns the input or null if not found
  101220. */
  101221. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101222. /**
  101223. * Find an output by its name
  101224. * @param name defines the name of the outputto look for
  101225. * @returns the output or null if not found
  101226. */
  101227. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101228. /**
  101229. * Creates a new NodeMaterialBlock
  101230. * @param name defines the block name
  101231. * @param target defines the target of that block (Vertex by default)
  101232. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  101233. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  101234. */
  101235. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  101236. /**
  101237. * Initialize the block and prepare the context for build
  101238. * @param state defines the state that will be used for the build
  101239. */
  101240. initialize(state: NodeMaterialBuildState): void;
  101241. /**
  101242. * Bind data to effect. Will only be called for blocks with isBindable === true
  101243. * @param effect defines the effect to bind data to
  101244. * @param nodeMaterial defines the hosting NodeMaterial
  101245. * @param mesh defines the mesh that will be rendered
  101246. * @param subMesh defines the submesh that will be rendered
  101247. */
  101248. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101249. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  101250. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  101251. protected _writeFloat(value: number): string;
  101252. /**
  101253. * Gets the current class name e.g. "NodeMaterialBlock"
  101254. * @returns the class name
  101255. */
  101256. getClassName(): string;
  101257. /**
  101258. * Register a new input. Must be called inside a block constructor
  101259. * @param name defines the connection point name
  101260. * @param type defines the connection point type
  101261. * @param isOptional defines a boolean indicating that this input can be omitted
  101262. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101263. * @param point an already created connection point. If not provided, create a new one
  101264. * @returns the current block
  101265. */
  101266. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  101267. /**
  101268. * Register a new output. Must be called inside a block constructor
  101269. * @param name defines the connection point name
  101270. * @param type defines the connection point type
  101271. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101272. * @param point an already created connection point. If not provided, create a new one
  101273. * @returns the current block
  101274. */
  101275. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  101276. /**
  101277. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  101278. * @param forOutput defines an optional connection point to check compatibility with
  101279. * @returns the first available input or null
  101280. */
  101281. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  101282. /**
  101283. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  101284. * @param forBlock defines an optional block to check compatibility with
  101285. * @returns the first available input or null
  101286. */
  101287. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  101288. /**
  101289. * Gets the sibling of the given output
  101290. * @param current defines the current output
  101291. * @returns the next output in the list or null
  101292. */
  101293. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  101294. /**
  101295. * Connect current block with another block
  101296. * @param other defines the block to connect with
  101297. * @param options define the various options to help pick the right connections
  101298. * @returns the current block
  101299. */
  101300. connectTo(other: NodeMaterialBlock, options?: {
  101301. input?: string;
  101302. output?: string;
  101303. outputSwizzle?: string;
  101304. }): this | undefined;
  101305. protected _buildBlock(state: NodeMaterialBuildState): void;
  101306. /**
  101307. * Add uniforms, samplers and uniform buffers at compilation time
  101308. * @param state defines the state to update
  101309. * @param nodeMaterial defines the node material requesting the update
  101310. * @param defines defines the material defines to update
  101311. * @param uniformBuffers defines the list of uniform buffer names
  101312. */
  101313. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  101314. /**
  101315. * Add potential fallbacks if shader compilation fails
  101316. * @param mesh defines the mesh to be rendered
  101317. * @param fallbacks defines the current prioritized list of fallbacks
  101318. */
  101319. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  101320. /**
  101321. * Initialize defines for shader compilation
  101322. * @param mesh defines the mesh to be rendered
  101323. * @param nodeMaterial defines the node material requesting the update
  101324. * @param defines defines the material defines to update
  101325. * @param useInstances specifies that instances should be used
  101326. */
  101327. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101328. /**
  101329. * Update defines for shader compilation
  101330. * @param mesh defines the mesh to be rendered
  101331. * @param nodeMaterial defines the node material requesting the update
  101332. * @param defines defines the material defines to update
  101333. * @param useInstances specifies that instances should be used
  101334. * @param subMesh defines which submesh to render
  101335. */
  101336. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  101337. /**
  101338. * Lets the block try to connect some inputs automatically
  101339. * @param material defines the hosting NodeMaterial
  101340. */
  101341. autoConfigure(material: NodeMaterial): void;
  101342. /**
  101343. * Function called when a block is declared as repeatable content generator
  101344. * @param vertexShaderState defines the current compilation state for the vertex shader
  101345. * @param fragmentShaderState defines the current compilation state for the fragment shader
  101346. * @param mesh defines the mesh to be rendered
  101347. * @param defines defines the material defines to update
  101348. */
  101349. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  101350. /**
  101351. * Checks if the block is ready
  101352. * @param mesh defines the mesh to be rendered
  101353. * @param nodeMaterial defines the node material requesting the update
  101354. * @param defines defines the material defines to update
  101355. * @param useInstances specifies that instances should be used
  101356. * @returns true if the block is ready
  101357. */
  101358. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  101359. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  101360. private _processBuild;
  101361. /**
  101362. * Validates the new name for the block node.
  101363. * @param newName the new name to be given to the node.
  101364. * @returns false if the name is a reserve word, else true.
  101365. */
  101366. validateBlockName(newName: string): boolean;
  101367. /**
  101368. * Compile the current node and generate the shader code
  101369. * @param state defines the current compilation state (uniforms, samplers, current string)
  101370. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  101371. * @returns true if already built
  101372. */
  101373. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  101374. protected _inputRename(name: string): string;
  101375. protected _outputRename(name: string): string;
  101376. protected _dumpPropertiesCode(): string;
  101377. /** @hidden */
  101378. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  101379. /** @hidden */
  101380. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  101381. /**
  101382. * Clone the current block to a new identical block
  101383. * @param scene defines the hosting scene
  101384. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101385. * @returns a copy of the current block
  101386. */
  101387. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  101388. /**
  101389. * Serializes this block in a JSON representation
  101390. * @returns the serialized block object
  101391. */
  101392. serialize(): any;
  101393. /** @hidden */
  101394. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101395. private _deserializePortDisplayNamesAndExposedOnFrame;
  101396. /**
  101397. * Release resources
  101398. */
  101399. dispose(): void;
  101400. }
  101401. }
  101402. declare module BABYLON {
  101403. /**
  101404. * Base class of materials working in push mode in babylon JS
  101405. * @hidden
  101406. */
  101407. export class PushMaterial extends Material {
  101408. protected _activeEffect: Effect;
  101409. protected _normalMatrix: Matrix;
  101410. constructor(name: string, scene: Scene);
  101411. getEffect(): Effect;
  101412. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101413. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  101414. /**
  101415. * Binds the given world matrix to the active effect
  101416. *
  101417. * @param world the matrix to bind
  101418. */
  101419. bindOnlyWorldMatrix(world: Matrix): void;
  101420. /**
  101421. * Binds the given normal matrix to the active effect
  101422. *
  101423. * @param normalMatrix the matrix to bind
  101424. */
  101425. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101426. bind(world: Matrix, mesh?: Mesh): void;
  101427. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101428. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101429. }
  101430. }
  101431. declare module BABYLON {
  101432. /**
  101433. * Root class for all node material optimizers
  101434. */
  101435. export class NodeMaterialOptimizer {
  101436. /**
  101437. * Function used to optimize a NodeMaterial graph
  101438. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  101439. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  101440. */
  101441. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  101442. }
  101443. }
  101444. declare module BABYLON {
  101445. /**
  101446. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  101447. */
  101448. export class TransformBlock extends NodeMaterialBlock {
  101449. /**
  101450. * Defines the value to use to complement W value to transform it to a Vector4
  101451. */
  101452. complementW: number;
  101453. /**
  101454. * Defines the value to use to complement z value to transform it to a Vector4
  101455. */
  101456. complementZ: number;
  101457. /**
  101458. * Creates a new TransformBlock
  101459. * @param name defines the block name
  101460. */
  101461. constructor(name: string);
  101462. /**
  101463. * Gets the current class name
  101464. * @returns the class name
  101465. */
  101466. getClassName(): string;
  101467. /**
  101468. * Gets the vector input
  101469. */
  101470. get vector(): NodeMaterialConnectionPoint;
  101471. /**
  101472. * Gets the output component
  101473. */
  101474. get output(): NodeMaterialConnectionPoint;
  101475. /**
  101476. * Gets the xyz output component
  101477. */
  101478. get xyz(): NodeMaterialConnectionPoint;
  101479. /**
  101480. * Gets the matrix transform input
  101481. */
  101482. get transform(): NodeMaterialConnectionPoint;
  101483. protected _buildBlock(state: NodeMaterialBuildState): this;
  101484. /**
  101485. * Update defines for shader compilation
  101486. * @param mesh defines the mesh to be rendered
  101487. * @param nodeMaterial defines the node material requesting the update
  101488. * @param defines defines the material defines to update
  101489. * @param useInstances specifies that instances should be used
  101490. * @param subMesh defines which submesh to render
  101491. */
  101492. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  101493. serialize(): any;
  101494. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101495. protected _dumpPropertiesCode(): string;
  101496. }
  101497. }
  101498. declare module BABYLON {
  101499. /**
  101500. * Block used to output the vertex position
  101501. */
  101502. export class VertexOutputBlock extends NodeMaterialBlock {
  101503. /**
  101504. * Creates a new VertexOutputBlock
  101505. * @param name defines the block name
  101506. */
  101507. constructor(name: string);
  101508. /**
  101509. * Gets the current class name
  101510. * @returns the class name
  101511. */
  101512. getClassName(): string;
  101513. /**
  101514. * Gets the vector input component
  101515. */
  101516. get vector(): NodeMaterialConnectionPoint;
  101517. protected _buildBlock(state: NodeMaterialBuildState): this;
  101518. }
  101519. }
  101520. declare module BABYLON {
  101521. /**
  101522. * Block used to output the final color
  101523. */
  101524. export class FragmentOutputBlock extends NodeMaterialBlock {
  101525. /**
  101526. * Create a new FragmentOutputBlock
  101527. * @param name defines the block name
  101528. */
  101529. constructor(name: string);
  101530. /**
  101531. * Gets the current class name
  101532. * @returns the class name
  101533. */
  101534. getClassName(): string;
  101535. /**
  101536. * Gets the rgba input component
  101537. */
  101538. get rgba(): NodeMaterialConnectionPoint;
  101539. /**
  101540. * Gets the rgb input component
  101541. */
  101542. get rgb(): NodeMaterialConnectionPoint;
  101543. /**
  101544. * Gets the a input component
  101545. */
  101546. get a(): NodeMaterialConnectionPoint;
  101547. protected _buildBlock(state: NodeMaterialBuildState): this;
  101548. }
  101549. }
  101550. declare module BABYLON {
  101551. /**
  101552. * Block used for the particle ramp gradient section
  101553. */
  101554. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  101555. /**
  101556. * Create a new ParticleRampGradientBlock
  101557. * @param name defines the block name
  101558. */
  101559. constructor(name: string);
  101560. /**
  101561. * Gets the current class name
  101562. * @returns the class name
  101563. */
  101564. getClassName(): string;
  101565. /**
  101566. * Gets the color input component
  101567. */
  101568. get color(): NodeMaterialConnectionPoint;
  101569. /**
  101570. * Gets the rampColor output component
  101571. */
  101572. get rampColor(): NodeMaterialConnectionPoint;
  101573. /**
  101574. * Initialize the block and prepare the context for build
  101575. * @param state defines the state that will be used for the build
  101576. */
  101577. initialize(state: NodeMaterialBuildState): void;
  101578. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101579. }
  101580. }
  101581. declare module BABYLON {
  101582. /**
  101583. * Block used for the particle blend multiply section
  101584. */
  101585. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  101586. /**
  101587. * Create a new ParticleBlendMultiplyBlock
  101588. * @param name defines the block name
  101589. */
  101590. constructor(name: string);
  101591. /**
  101592. * Gets the current class name
  101593. * @returns the class name
  101594. */
  101595. getClassName(): string;
  101596. /**
  101597. * Gets the color input component
  101598. */
  101599. get color(): NodeMaterialConnectionPoint;
  101600. /**
  101601. * Gets the alphaTexture input component
  101602. */
  101603. get alphaTexture(): NodeMaterialConnectionPoint;
  101604. /**
  101605. * Gets the alphaColor input component
  101606. */
  101607. get alphaColor(): NodeMaterialConnectionPoint;
  101608. /**
  101609. * Gets the blendColor output component
  101610. */
  101611. get blendColor(): NodeMaterialConnectionPoint;
  101612. /**
  101613. * Initialize the block and prepare the context for build
  101614. * @param state defines the state that will be used for the build
  101615. */
  101616. initialize(state: NodeMaterialBuildState): void;
  101617. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101618. }
  101619. }
  101620. declare module BABYLON {
  101621. /**
  101622. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  101623. */
  101624. export class VectorMergerBlock extends NodeMaterialBlock {
  101625. /**
  101626. * Create a new VectorMergerBlock
  101627. * @param name defines the block name
  101628. */
  101629. constructor(name: string);
  101630. /**
  101631. * Gets the current class name
  101632. * @returns the class name
  101633. */
  101634. getClassName(): string;
  101635. /**
  101636. * Gets the xyz component (input)
  101637. */
  101638. get xyzIn(): NodeMaterialConnectionPoint;
  101639. /**
  101640. * Gets the xy component (input)
  101641. */
  101642. get xyIn(): NodeMaterialConnectionPoint;
  101643. /**
  101644. * Gets the x component (input)
  101645. */
  101646. get x(): NodeMaterialConnectionPoint;
  101647. /**
  101648. * Gets the y component (input)
  101649. */
  101650. get y(): NodeMaterialConnectionPoint;
  101651. /**
  101652. * Gets the z component (input)
  101653. */
  101654. get z(): NodeMaterialConnectionPoint;
  101655. /**
  101656. * Gets the w component (input)
  101657. */
  101658. get w(): NodeMaterialConnectionPoint;
  101659. /**
  101660. * Gets the xyzw component (output)
  101661. */
  101662. get xyzw(): NodeMaterialConnectionPoint;
  101663. /**
  101664. * Gets the xyz component (output)
  101665. */
  101666. get xyzOut(): NodeMaterialConnectionPoint;
  101667. /**
  101668. * Gets the xy component (output)
  101669. */
  101670. get xyOut(): NodeMaterialConnectionPoint;
  101671. /**
  101672. * Gets the xy component (output)
  101673. * @deprecated Please use xyOut instead.
  101674. */
  101675. get xy(): NodeMaterialConnectionPoint;
  101676. /**
  101677. * Gets the xyz component (output)
  101678. * @deprecated Please use xyzOut instead.
  101679. */
  101680. get xyz(): NodeMaterialConnectionPoint;
  101681. protected _buildBlock(state: NodeMaterialBuildState): this;
  101682. }
  101683. }
  101684. declare module BABYLON {
  101685. /**
  101686. * Block used to remap a float from a range to a new one
  101687. */
  101688. export class RemapBlock extends NodeMaterialBlock {
  101689. /**
  101690. * Gets or sets the source range
  101691. */
  101692. sourceRange: Vector2;
  101693. /**
  101694. * Gets or sets the target range
  101695. */
  101696. targetRange: Vector2;
  101697. /**
  101698. * Creates a new RemapBlock
  101699. * @param name defines the block name
  101700. */
  101701. constructor(name: string);
  101702. /**
  101703. * Gets the current class name
  101704. * @returns the class name
  101705. */
  101706. getClassName(): string;
  101707. /**
  101708. * Gets the input component
  101709. */
  101710. get input(): NodeMaterialConnectionPoint;
  101711. /**
  101712. * Gets the source min input component
  101713. */
  101714. get sourceMin(): NodeMaterialConnectionPoint;
  101715. /**
  101716. * Gets the source max input component
  101717. */
  101718. get sourceMax(): NodeMaterialConnectionPoint;
  101719. /**
  101720. * Gets the target min input component
  101721. */
  101722. get targetMin(): NodeMaterialConnectionPoint;
  101723. /**
  101724. * Gets the target max input component
  101725. */
  101726. get targetMax(): NodeMaterialConnectionPoint;
  101727. /**
  101728. * Gets the output component
  101729. */
  101730. get output(): NodeMaterialConnectionPoint;
  101731. protected _buildBlock(state: NodeMaterialBuildState): this;
  101732. protected _dumpPropertiesCode(): string;
  101733. serialize(): any;
  101734. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101735. }
  101736. }
  101737. declare module BABYLON {
  101738. /**
  101739. * Block used to multiply 2 values
  101740. */
  101741. export class MultiplyBlock extends NodeMaterialBlock {
  101742. /**
  101743. * Creates a new MultiplyBlock
  101744. * @param name defines the block name
  101745. */
  101746. constructor(name: string);
  101747. /**
  101748. * Gets the current class name
  101749. * @returns the class name
  101750. */
  101751. getClassName(): string;
  101752. /**
  101753. * Gets the left operand input component
  101754. */
  101755. get left(): NodeMaterialConnectionPoint;
  101756. /**
  101757. * Gets the right operand input component
  101758. */
  101759. get right(): NodeMaterialConnectionPoint;
  101760. /**
  101761. * Gets the output component
  101762. */
  101763. get output(): NodeMaterialConnectionPoint;
  101764. protected _buildBlock(state: NodeMaterialBuildState): this;
  101765. }
  101766. }
  101767. declare module BABYLON {
  101768. /**
  101769. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  101770. */
  101771. export class ColorSplitterBlock extends NodeMaterialBlock {
  101772. /**
  101773. * Create a new ColorSplitterBlock
  101774. * @param name defines the block name
  101775. */
  101776. constructor(name: string);
  101777. /**
  101778. * Gets the current class name
  101779. * @returns the class name
  101780. */
  101781. getClassName(): string;
  101782. /**
  101783. * Gets the rgba component (input)
  101784. */
  101785. get rgba(): NodeMaterialConnectionPoint;
  101786. /**
  101787. * Gets the rgb component (input)
  101788. */
  101789. get rgbIn(): NodeMaterialConnectionPoint;
  101790. /**
  101791. * Gets the rgb component (output)
  101792. */
  101793. get rgbOut(): NodeMaterialConnectionPoint;
  101794. /**
  101795. * Gets the r component (output)
  101796. */
  101797. get r(): NodeMaterialConnectionPoint;
  101798. /**
  101799. * Gets the g component (output)
  101800. */
  101801. get g(): NodeMaterialConnectionPoint;
  101802. /**
  101803. * Gets the b component (output)
  101804. */
  101805. get b(): NodeMaterialConnectionPoint;
  101806. /**
  101807. * Gets the a component (output)
  101808. */
  101809. get a(): NodeMaterialConnectionPoint;
  101810. protected _inputRename(name: string): string;
  101811. protected _outputRename(name: string): string;
  101812. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101813. }
  101814. }
  101815. declare module BABYLON {
  101816. /**
  101817. * Interface used to configure the node material editor
  101818. */
  101819. export interface INodeMaterialEditorOptions {
  101820. /** Define the URl to load node editor script */
  101821. editorURL?: string;
  101822. }
  101823. /** @hidden */
  101824. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101825. NORMAL: boolean;
  101826. TANGENT: boolean;
  101827. UV1: boolean;
  101828. /** BONES */
  101829. NUM_BONE_INFLUENCERS: number;
  101830. BonesPerMesh: number;
  101831. BONETEXTURE: boolean;
  101832. /** MORPH TARGETS */
  101833. MORPHTARGETS: boolean;
  101834. MORPHTARGETS_NORMAL: boolean;
  101835. MORPHTARGETS_TANGENT: boolean;
  101836. MORPHTARGETS_UV: boolean;
  101837. NUM_MORPH_INFLUENCERS: number;
  101838. /** IMAGE PROCESSING */
  101839. IMAGEPROCESSING: boolean;
  101840. VIGNETTE: boolean;
  101841. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101842. VIGNETTEBLENDMODEOPAQUE: boolean;
  101843. TONEMAPPING: boolean;
  101844. TONEMAPPING_ACES: boolean;
  101845. CONTRAST: boolean;
  101846. EXPOSURE: boolean;
  101847. COLORCURVES: boolean;
  101848. COLORGRADING: boolean;
  101849. COLORGRADING3D: boolean;
  101850. SAMPLER3DGREENDEPTH: boolean;
  101851. SAMPLER3DBGRMAP: boolean;
  101852. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101853. /** MISC. */
  101854. BUMPDIRECTUV: number;
  101855. constructor();
  101856. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  101857. }
  101858. /**
  101859. * Class used to configure NodeMaterial
  101860. */
  101861. export interface INodeMaterialOptions {
  101862. /**
  101863. * Defines if blocks should emit comments
  101864. */
  101865. emitComments: boolean;
  101866. }
  101867. /**
  101868. * Class used to create a node based material built by assembling shader blocks
  101869. */
  101870. export class NodeMaterial extends PushMaterial {
  101871. private static _BuildIdGenerator;
  101872. private _options;
  101873. private _vertexCompilationState;
  101874. private _fragmentCompilationState;
  101875. private _sharedData;
  101876. private _buildId;
  101877. private _buildWasSuccessful;
  101878. private _cachedWorldViewMatrix;
  101879. private _cachedWorldViewProjectionMatrix;
  101880. private _optimizers;
  101881. private _animationFrame;
  101882. /** Define the Url to load node editor script */
  101883. static EditorURL: string;
  101884. /** Define the Url to load snippets */
  101885. static SnippetUrl: string;
  101886. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  101887. static IgnoreTexturesAtLoadTime: boolean;
  101888. private BJSNODEMATERIALEDITOR;
  101889. /** Get the inspector from bundle or global */
  101890. private _getGlobalNodeMaterialEditor;
  101891. /**
  101892. * Snippet ID if the material was created from the snippet server
  101893. */
  101894. snippetId: string;
  101895. /**
  101896. * Gets or sets data used by visual editor
  101897. * @see https://nme.babylonjs.com
  101898. */
  101899. editorData: any;
  101900. /**
  101901. * 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)
  101902. */
  101903. ignoreAlpha: boolean;
  101904. /**
  101905. * Defines the maximum number of lights that can be used in the material
  101906. */
  101907. maxSimultaneousLights: number;
  101908. /**
  101909. * Observable raised when the material is built
  101910. */
  101911. onBuildObservable: Observable<NodeMaterial>;
  101912. /**
  101913. * Gets or sets the root nodes of the material vertex shader
  101914. */
  101915. _vertexOutputNodes: NodeMaterialBlock[];
  101916. /**
  101917. * Gets or sets the root nodes of the material fragment (pixel) shader
  101918. */
  101919. _fragmentOutputNodes: NodeMaterialBlock[];
  101920. /** Gets or sets options to control the node material overall behavior */
  101921. get options(): INodeMaterialOptions;
  101922. set options(options: INodeMaterialOptions);
  101923. /**
  101924. * Default configuration related to image processing available in the standard Material.
  101925. */
  101926. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101927. /**
  101928. * Gets the image processing configuration used either in this material.
  101929. */
  101930. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  101931. /**
  101932. * Sets the Default image processing configuration used either in the this material.
  101933. *
  101934. * If sets to null, the scene one is in use.
  101935. */
  101936. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  101937. /**
  101938. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  101939. */
  101940. attachedBlocks: NodeMaterialBlock[];
  101941. /**
  101942. * Specifies the mode of the node material
  101943. * @hidden
  101944. */
  101945. _mode: NodeMaterialModes;
  101946. /**
  101947. * Gets the mode property
  101948. */
  101949. get mode(): NodeMaterialModes;
  101950. /**
  101951. * Create a new node based material
  101952. * @param name defines the material name
  101953. * @param scene defines the hosting scene
  101954. * @param options defines creation option
  101955. */
  101956. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  101957. /**
  101958. * Gets the current class name of the material e.g. "NodeMaterial"
  101959. * @returns the class name
  101960. */
  101961. getClassName(): string;
  101962. /**
  101963. * Keep track of the image processing observer to allow dispose and replace.
  101964. */
  101965. private _imageProcessingObserver;
  101966. /**
  101967. * Attaches a new image processing configuration to the Standard Material.
  101968. * @param configuration
  101969. */
  101970. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101971. /**
  101972. * Get a block by its name
  101973. * @param name defines the name of the block to retrieve
  101974. * @returns the required block or null if not found
  101975. */
  101976. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  101977. /**
  101978. * Get a block by its name
  101979. * @param predicate defines the predicate used to find the good candidate
  101980. * @returns the required block or null if not found
  101981. */
  101982. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  101983. /**
  101984. * Get an input block by its name
  101985. * @param predicate defines the predicate used to find the good candidate
  101986. * @returns the required input block or null if not found
  101987. */
  101988. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  101989. /**
  101990. * Gets the list of input blocks attached to this material
  101991. * @returns an array of InputBlocks
  101992. */
  101993. getInputBlocks(): InputBlock[];
  101994. /**
  101995. * Adds a new optimizer to the list of optimizers
  101996. * @param optimizer defines the optimizers to add
  101997. * @returns the current material
  101998. */
  101999. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102000. /**
  102001. * Remove an optimizer from the list of optimizers
  102002. * @param optimizer defines the optimizers to remove
  102003. * @returns the current material
  102004. */
  102005. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102006. /**
  102007. * Add a new block to the list of output nodes
  102008. * @param node defines the node to add
  102009. * @returns the current material
  102010. */
  102011. addOutputNode(node: NodeMaterialBlock): this;
  102012. /**
  102013. * Remove a block from the list of root nodes
  102014. * @param node defines the node to remove
  102015. * @returns the current material
  102016. */
  102017. removeOutputNode(node: NodeMaterialBlock): this;
  102018. private _addVertexOutputNode;
  102019. private _removeVertexOutputNode;
  102020. private _addFragmentOutputNode;
  102021. private _removeFragmentOutputNode;
  102022. /**
  102023. * Specifies if the material will require alpha blending
  102024. * @returns a boolean specifying if alpha blending is needed
  102025. */
  102026. needAlphaBlending(): boolean;
  102027. /**
  102028. * Specifies if this material should be rendered in alpha test mode
  102029. * @returns a boolean specifying if an alpha test is needed.
  102030. */
  102031. needAlphaTesting(): boolean;
  102032. private _initializeBlock;
  102033. private _resetDualBlocks;
  102034. /**
  102035. * Remove a block from the current node material
  102036. * @param block defines the block to remove
  102037. */
  102038. removeBlock(block: NodeMaterialBlock): void;
  102039. /**
  102040. * Build the material and generates the inner effect
  102041. * @param verbose defines if the build should log activity
  102042. */
  102043. build(verbose?: boolean): void;
  102044. /**
  102045. * Runs an otpimization phase to try to improve the shader code
  102046. */
  102047. optimize(): void;
  102048. private _prepareDefinesForAttributes;
  102049. /**
  102050. * Create a post process from the material
  102051. * @param camera The camera to apply the render pass to.
  102052. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102053. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102054. * @param engine The engine which the post process will be applied. (default: current engine)
  102055. * @param reusable If the post process can be reused on the same frame. (default: false)
  102056. * @param textureType Type of textures used when performing the post process. (default: 0)
  102057. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102058. * @returns the post process created
  102059. */
  102060. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  102061. /**
  102062. * Create the post process effect from the material
  102063. * @param postProcess The post process to create the effect for
  102064. */
  102065. createEffectForPostProcess(postProcess: PostProcess): void;
  102066. private _createEffectOrPostProcess;
  102067. private _createEffectForParticles;
  102068. /**
  102069. * Create the effect to be used as the custom effect for a particle system
  102070. * @param particleSystem Particle system to create the effect for
  102071. * @param onCompiled defines a function to call when the effect creation is successful
  102072. * @param onError defines a function to call when the effect creation has failed
  102073. */
  102074. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102075. private _processDefines;
  102076. /**
  102077. * Get if the submesh is ready to be used and all its information available.
  102078. * Child classes can use it to update shaders
  102079. * @param mesh defines the mesh to check
  102080. * @param subMesh defines which submesh to check
  102081. * @param useInstances specifies that instances should be used
  102082. * @returns a boolean indicating that the submesh is ready or not
  102083. */
  102084. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102085. /**
  102086. * Get a string representing the shaders built by the current node graph
  102087. */
  102088. get compiledShaders(): string;
  102089. /**
  102090. * Binds the world matrix to the material
  102091. * @param world defines the world transformation matrix
  102092. */
  102093. bindOnlyWorldMatrix(world: Matrix): void;
  102094. /**
  102095. * Binds the submesh to this material by preparing the effect and shader to draw
  102096. * @param world defines the world transformation matrix
  102097. * @param mesh defines the mesh containing the submesh
  102098. * @param subMesh defines the submesh to bind the material to
  102099. */
  102100. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102101. /**
  102102. * Gets the active textures from the material
  102103. * @returns an array of textures
  102104. */
  102105. getActiveTextures(): BaseTexture[];
  102106. /**
  102107. * Gets the list of texture blocks
  102108. * @returns an array of texture blocks
  102109. */
  102110. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102111. /**
  102112. * Specifies if the material uses a texture
  102113. * @param texture defines the texture to check against the material
  102114. * @returns a boolean specifying if the material uses the texture
  102115. */
  102116. hasTexture(texture: BaseTexture): boolean;
  102117. /**
  102118. * Disposes the material
  102119. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102120. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102121. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102122. */
  102123. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102124. /** Creates the node editor window. */
  102125. private _createNodeEditor;
  102126. /**
  102127. * Launch the node material editor
  102128. * @param config Define the configuration of the editor
  102129. * @return a promise fulfilled when the node editor is visible
  102130. */
  102131. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  102132. /**
  102133. * Clear the current material
  102134. */
  102135. clear(): void;
  102136. /**
  102137. * Clear the current material and set it to a default state
  102138. */
  102139. setToDefault(): void;
  102140. /**
  102141. * Clear the current material and set it to a default state for post process
  102142. */
  102143. setToDefaultPostProcess(): void;
  102144. /**
  102145. * Clear the current material and set it to a default state for particle
  102146. */
  102147. setToDefaultParticle(): void;
  102148. /**
  102149. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  102150. * @param url defines the url to load from
  102151. * @returns a promise that will fullfil when the material is fully loaded
  102152. */
  102153. loadAsync(url: string): Promise<void>;
  102154. private _gatherBlocks;
  102155. /**
  102156. * Generate a string containing the code declaration required to create an equivalent of this material
  102157. * @returns a string
  102158. */
  102159. generateCode(): string;
  102160. /**
  102161. * Serializes this material in a JSON representation
  102162. * @returns the serialized material object
  102163. */
  102164. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  102165. private _restoreConnections;
  102166. /**
  102167. * Clear the current graph and load a new one from a serialization object
  102168. * @param source defines the JSON representation of the material
  102169. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102170. * @param merge defines whether or not the source must be merged or replace the current content
  102171. */
  102172. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  102173. /**
  102174. * Makes a duplicate of the current material.
  102175. * @param name - name to use for the new material.
  102176. */
  102177. clone(name: string): NodeMaterial;
  102178. /**
  102179. * Creates a node material from parsed material data
  102180. * @param source defines the JSON representation of the material
  102181. * @param scene defines the hosting scene
  102182. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102183. * @returns a new node material
  102184. */
  102185. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  102186. /**
  102187. * Creates a node material from a snippet saved in a remote file
  102188. * @param name defines the name of the material to create
  102189. * @param url defines the url to load from
  102190. * @param scene defines the hosting scene
  102191. * @returns a promise that will resolve to the new node material
  102192. */
  102193. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  102194. /**
  102195. * Creates a node material from a snippet saved by the node material editor
  102196. * @param snippetId defines the snippet to load
  102197. * @param scene defines the hosting scene
  102198. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102199. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  102200. * @returns a promise that will resolve to the new node material
  102201. */
  102202. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  102203. /**
  102204. * Creates a new node material set to default basic configuration
  102205. * @param name defines the name of the material
  102206. * @param scene defines the hosting scene
  102207. * @returns a new NodeMaterial
  102208. */
  102209. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  102210. }
  102211. }
  102212. declare module BABYLON {
  102213. /**
  102214. * Size options for a post process
  102215. */
  102216. export type PostProcessOptions = {
  102217. width: number;
  102218. height: number;
  102219. };
  102220. /**
  102221. * PostProcess can be used to apply a shader to a texture after it has been rendered
  102222. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  102223. */
  102224. export class PostProcess {
  102225. /**
  102226. * Gets or sets the unique id of the post process
  102227. */
  102228. uniqueId: number;
  102229. /** Name of the PostProcess. */
  102230. name: string;
  102231. /**
  102232. * Width of the texture to apply the post process on
  102233. */
  102234. width: number;
  102235. /**
  102236. * Height of the texture to apply the post process on
  102237. */
  102238. height: number;
  102239. /**
  102240. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  102241. */
  102242. nodeMaterialSource: Nullable<NodeMaterial>;
  102243. /**
  102244. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  102245. * @hidden
  102246. */
  102247. _outputTexture: Nullable<InternalTexture>;
  102248. /**
  102249. * Sampling mode used by the shader
  102250. * See https://doc.babylonjs.com/classes/3.1/texture
  102251. */
  102252. renderTargetSamplingMode: number;
  102253. /**
  102254. * Clear color to use when screen clearing
  102255. */
  102256. clearColor: Color4;
  102257. /**
  102258. * If the buffer needs to be cleared before applying the post process. (default: true)
  102259. * Should be set to false if shader will overwrite all previous pixels.
  102260. */
  102261. autoClear: boolean;
  102262. /**
  102263. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  102264. */
  102265. alphaMode: number;
  102266. /**
  102267. * Sets the setAlphaBlendConstants of the babylon engine
  102268. */
  102269. alphaConstants: Color4;
  102270. /**
  102271. * Animations to be used for the post processing
  102272. */
  102273. animations: Animation[];
  102274. /**
  102275. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  102276. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  102277. */
  102278. enablePixelPerfectMode: boolean;
  102279. /**
  102280. * Force the postprocess to be applied without taking in account viewport
  102281. */
  102282. forceFullscreenViewport: boolean;
  102283. /**
  102284. * List of inspectable custom properties (used by the Inspector)
  102285. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102286. */
  102287. inspectableCustomProperties: IInspectable[];
  102288. /**
  102289. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  102290. *
  102291. * | Value | Type | Description |
  102292. * | ----- | ----------------------------------- | ----------- |
  102293. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  102294. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  102295. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  102296. *
  102297. */
  102298. scaleMode: number;
  102299. /**
  102300. * Force textures to be a power of two (default: false)
  102301. */
  102302. alwaysForcePOT: boolean;
  102303. private _samples;
  102304. /**
  102305. * Number of sample textures (default: 1)
  102306. */
  102307. get samples(): number;
  102308. set samples(n: number);
  102309. /**
  102310. * Modify the scale of the post process to be the same as the viewport (default: false)
  102311. */
  102312. adaptScaleToCurrentViewport: boolean;
  102313. private _camera;
  102314. protected _scene: Scene;
  102315. private _engine;
  102316. private _options;
  102317. private _reusable;
  102318. private _textureType;
  102319. private _textureFormat;
  102320. /**
  102321. * Smart array of input and output textures for the post process.
  102322. * @hidden
  102323. */
  102324. _textures: SmartArray<InternalTexture>;
  102325. /**
  102326. * The index in _textures that corresponds to the output texture.
  102327. * @hidden
  102328. */
  102329. _currentRenderTextureInd: number;
  102330. private _effect;
  102331. private _samplers;
  102332. private _fragmentUrl;
  102333. private _vertexUrl;
  102334. private _parameters;
  102335. private _scaleRatio;
  102336. protected _indexParameters: any;
  102337. private _shareOutputWithPostProcess;
  102338. private _texelSize;
  102339. private _forcedOutputTexture;
  102340. /**
  102341. * Returns the fragment url or shader name used in the post process.
  102342. * @returns the fragment url or name in the shader store.
  102343. */
  102344. getEffectName(): string;
  102345. /**
  102346. * An event triggered when the postprocess is activated.
  102347. */
  102348. onActivateObservable: Observable<Camera>;
  102349. private _onActivateObserver;
  102350. /**
  102351. * A function that is added to the onActivateObservable
  102352. */
  102353. set onActivate(callback: Nullable<(camera: Camera) => void>);
  102354. /**
  102355. * An event triggered when the postprocess changes its size.
  102356. */
  102357. onSizeChangedObservable: Observable<PostProcess>;
  102358. private _onSizeChangedObserver;
  102359. /**
  102360. * A function that is added to the onSizeChangedObservable
  102361. */
  102362. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  102363. /**
  102364. * An event triggered when the postprocess applies its effect.
  102365. */
  102366. onApplyObservable: Observable<Effect>;
  102367. private _onApplyObserver;
  102368. /**
  102369. * A function that is added to the onApplyObservable
  102370. */
  102371. set onApply(callback: (effect: Effect) => void);
  102372. /**
  102373. * An event triggered before rendering the postprocess
  102374. */
  102375. onBeforeRenderObservable: Observable<Effect>;
  102376. private _onBeforeRenderObserver;
  102377. /**
  102378. * A function that is added to the onBeforeRenderObservable
  102379. */
  102380. set onBeforeRender(callback: (effect: Effect) => void);
  102381. /**
  102382. * An event triggered after rendering the postprocess
  102383. */
  102384. onAfterRenderObservable: Observable<Effect>;
  102385. private _onAfterRenderObserver;
  102386. /**
  102387. * A function that is added to the onAfterRenderObservable
  102388. */
  102389. set onAfterRender(callback: (efect: Effect) => void);
  102390. /**
  102391. * 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
  102392. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  102393. */
  102394. get inputTexture(): InternalTexture;
  102395. set inputTexture(value: InternalTexture);
  102396. /**
  102397. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  102398. * the only way to unset it is to use this function to restore its internal state
  102399. */
  102400. restoreDefaultInputTexture(): void;
  102401. /**
  102402. * Gets the camera which post process is applied to.
  102403. * @returns The camera the post process is applied to.
  102404. */
  102405. getCamera(): Camera;
  102406. /**
  102407. * Gets the texel size of the postprocess.
  102408. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  102409. */
  102410. get texelSize(): Vector2;
  102411. /**
  102412. * Creates a new instance PostProcess
  102413. * @param name The name of the PostProcess.
  102414. * @param fragmentUrl The url of the fragment shader to be used.
  102415. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  102416. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  102417. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102418. * @param camera The camera to apply the render pass to.
  102419. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102420. * @param engine The engine which the post process will be applied. (default: current engine)
  102421. * @param reusable If the post process can be reused on the same frame. (default: false)
  102422. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  102423. * @param textureType Type of textures used when performing the post process. (default: 0)
  102424. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  102425. * @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
  102426. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  102427. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102428. */
  102429. 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);
  102430. /**
  102431. * Gets a string identifying the name of the class
  102432. * @returns "PostProcess" string
  102433. */
  102434. getClassName(): string;
  102435. /**
  102436. * Gets the engine which this post process belongs to.
  102437. * @returns The engine the post process was enabled with.
  102438. */
  102439. getEngine(): Engine;
  102440. /**
  102441. * The effect that is created when initializing the post process.
  102442. * @returns The created effect corresponding the the postprocess.
  102443. */
  102444. getEffect(): Effect;
  102445. /**
  102446. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  102447. * @param postProcess The post process to share the output with.
  102448. * @returns This post process.
  102449. */
  102450. shareOutputWith(postProcess: PostProcess): PostProcess;
  102451. /**
  102452. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  102453. * This should be called if the post process that shares output with this post process is disabled/disposed.
  102454. */
  102455. useOwnOutput(): void;
  102456. /**
  102457. * Updates the effect with the current post process compile time values and recompiles the shader.
  102458. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  102459. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  102460. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  102461. * @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
  102462. * @param onCompiled Called when the shader has been compiled.
  102463. * @param onError Called if there is an error when compiling a shader.
  102464. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  102465. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  102466. */
  102467. 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;
  102468. /**
  102469. * The post process is reusable if it can be used multiple times within one frame.
  102470. * @returns If the post process is reusable
  102471. */
  102472. isReusable(): boolean;
  102473. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  102474. markTextureDirty(): void;
  102475. /**
  102476. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  102477. * 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.
  102478. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  102479. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  102480. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  102481. * @returns The target texture that was bound to be written to.
  102482. */
  102483. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  102484. /**
  102485. * If the post process is supported.
  102486. */
  102487. get isSupported(): boolean;
  102488. /**
  102489. * The aspect ratio of the output texture.
  102490. */
  102491. get aspectRatio(): number;
  102492. /**
  102493. * Get a value indicating if the post-process is ready to be used
  102494. * @returns true if the post-process is ready (shader is compiled)
  102495. */
  102496. isReady(): boolean;
  102497. /**
  102498. * Binds all textures and uniforms to the shader, this will be run on every pass.
  102499. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  102500. */
  102501. apply(): Nullable<Effect>;
  102502. private _disposeTextures;
  102503. /**
  102504. * Disposes the post process.
  102505. * @param camera The camera to dispose the post process on.
  102506. */
  102507. dispose(camera?: Camera): void;
  102508. /**
  102509. * Serializes the particle system to a JSON object
  102510. * @returns the JSON object
  102511. */
  102512. serialize(): any;
  102513. /**
  102514. * Creates a material from parsed material data
  102515. * @param parsedPostProcess defines parsed post process data
  102516. * @param scene defines the hosting scene
  102517. * @param rootUrl defines the root URL to use to load textures
  102518. * @returns a new post process
  102519. */
  102520. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  102521. }
  102522. }
  102523. declare module BABYLON {
  102524. /** @hidden */
  102525. export var kernelBlurVaryingDeclaration: {
  102526. name: string;
  102527. shader: string;
  102528. };
  102529. }
  102530. declare module BABYLON {
  102531. /** @hidden */
  102532. export var kernelBlurFragment: {
  102533. name: string;
  102534. shader: string;
  102535. };
  102536. }
  102537. declare module BABYLON {
  102538. /** @hidden */
  102539. export var kernelBlurFragment2: {
  102540. name: string;
  102541. shader: string;
  102542. };
  102543. }
  102544. declare module BABYLON {
  102545. /** @hidden */
  102546. export var kernelBlurPixelShader: {
  102547. name: string;
  102548. shader: string;
  102549. };
  102550. }
  102551. declare module BABYLON {
  102552. /** @hidden */
  102553. export var kernelBlurVertex: {
  102554. name: string;
  102555. shader: string;
  102556. };
  102557. }
  102558. declare module BABYLON {
  102559. /** @hidden */
  102560. export var kernelBlurVertexShader: {
  102561. name: string;
  102562. shader: string;
  102563. };
  102564. }
  102565. declare module BABYLON {
  102566. /**
  102567. * The Blur Post Process which blurs an image based on a kernel and direction.
  102568. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  102569. */
  102570. export class BlurPostProcess extends PostProcess {
  102571. private blockCompilation;
  102572. protected _kernel: number;
  102573. protected _idealKernel: number;
  102574. protected _packedFloat: boolean;
  102575. private _staticDefines;
  102576. /** The direction in which to blur the image. */
  102577. direction: Vector2;
  102578. /**
  102579. * Sets the length in pixels of the blur sample region
  102580. */
  102581. set kernel(v: number);
  102582. /**
  102583. * Gets the length in pixels of the blur sample region
  102584. */
  102585. get kernel(): number;
  102586. /**
  102587. * Sets wether or not the blur needs to unpack/repack floats
  102588. */
  102589. set packedFloat(v: boolean);
  102590. /**
  102591. * Gets wether or not the blur is unpacking/repacking floats
  102592. */
  102593. get packedFloat(): boolean;
  102594. /**
  102595. * Gets a string identifying the name of the class
  102596. * @returns "BlurPostProcess" string
  102597. */
  102598. getClassName(): string;
  102599. /**
  102600. * Creates a new instance BlurPostProcess
  102601. * @param name The name of the effect.
  102602. * @param direction The direction in which to blur the image.
  102603. * @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.
  102604. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102605. * @param camera The camera to apply the render pass to.
  102606. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102607. * @param engine The engine which the post process will be applied. (default: current engine)
  102608. * @param reusable If the post process can be reused on the same frame. (default: false)
  102609. * @param textureType Type of textures used when performing the post process. (default: 0)
  102610. * @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)
  102611. */
  102612. 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);
  102613. /**
  102614. * Updates the effect with the current post process compile time values and recompiles the shader.
  102615. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  102616. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  102617. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  102618. * @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
  102619. * @param onCompiled Called when the shader has been compiled.
  102620. * @param onError Called if there is an error when compiling a shader.
  102621. */
  102622. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102623. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102624. /**
  102625. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  102626. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  102627. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  102628. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  102629. * The gaps between physical kernels are compensated for in the weighting of the samples
  102630. * @param idealKernel Ideal blur kernel.
  102631. * @return Nearest best kernel.
  102632. */
  102633. protected _nearestBestKernel(idealKernel: number): number;
  102634. /**
  102635. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  102636. * @param x The point on the Gaussian distribution to sample.
  102637. * @return the value of the Gaussian function at x.
  102638. */
  102639. protected _gaussianWeight(x: number): number;
  102640. /**
  102641. * Generates a string that can be used as a floating point number in GLSL.
  102642. * @param x Value to print.
  102643. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  102644. * @return GLSL float string.
  102645. */
  102646. protected _glslFloat(x: number, decimalFigures?: number): string;
  102647. /** @hidden */
  102648. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  102649. }
  102650. }
  102651. declare module BABYLON {
  102652. /**
  102653. * Mirror texture can be used to simulate the view from a mirror in a scene.
  102654. * It will dynamically be rendered every frame to adapt to the camera point of view.
  102655. * You can then easily use it as a reflectionTexture on a flat surface.
  102656. * In case the surface is not a plane, please consider relying on reflection probes.
  102657. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102658. */
  102659. export class MirrorTexture extends RenderTargetTexture {
  102660. private scene;
  102661. /**
  102662. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  102663. * 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.
  102664. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102665. */
  102666. mirrorPlane: Plane;
  102667. /**
  102668. * Define the blur ratio used to blur the reflection if needed.
  102669. */
  102670. set blurRatio(value: number);
  102671. get blurRatio(): number;
  102672. /**
  102673. * Define the adaptive blur kernel used to blur the reflection if needed.
  102674. * This will autocompute the closest best match for the `blurKernel`
  102675. */
  102676. set adaptiveBlurKernel(value: number);
  102677. /**
  102678. * Define the blur kernel used to blur the reflection if needed.
  102679. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102680. */
  102681. set blurKernel(value: number);
  102682. /**
  102683. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  102684. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102685. */
  102686. set blurKernelX(value: number);
  102687. get blurKernelX(): number;
  102688. /**
  102689. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  102690. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102691. */
  102692. set blurKernelY(value: number);
  102693. get blurKernelY(): number;
  102694. private _autoComputeBlurKernel;
  102695. protected _onRatioRescale(): void;
  102696. private _updateGammaSpace;
  102697. private _imageProcessingConfigChangeObserver;
  102698. private _transformMatrix;
  102699. private _mirrorMatrix;
  102700. private _savedViewMatrix;
  102701. private _blurX;
  102702. private _blurY;
  102703. private _adaptiveBlurKernel;
  102704. private _blurKernelX;
  102705. private _blurKernelY;
  102706. private _blurRatio;
  102707. /**
  102708. * Instantiates a Mirror Texture.
  102709. * Mirror texture can be used to simulate the view from a mirror in a scene.
  102710. * It will dynamically be rendered every frame to adapt to the camera point of view.
  102711. * You can then easily use it as a reflectionTexture on a flat surface.
  102712. * In case the surface is not a plane, please consider relying on reflection probes.
  102713. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102714. * @param name
  102715. * @param size
  102716. * @param scene
  102717. * @param generateMipMaps
  102718. * @param type
  102719. * @param samplingMode
  102720. * @param generateDepthBuffer
  102721. */
  102722. constructor(name: string, size: number | {
  102723. width: number;
  102724. height: number;
  102725. } | {
  102726. ratio: number;
  102727. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  102728. private _preparePostProcesses;
  102729. /**
  102730. * Clone the mirror texture.
  102731. * @returns the cloned texture
  102732. */
  102733. clone(): MirrorTexture;
  102734. /**
  102735. * Serialize the texture to a JSON representation you could use in Parse later on
  102736. * @returns the serialized JSON representation
  102737. */
  102738. serialize(): any;
  102739. /**
  102740. * Dispose the texture and release its associated resources.
  102741. */
  102742. dispose(): void;
  102743. }
  102744. }
  102745. declare module BABYLON {
  102746. /**
  102747. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  102748. * @see https://doc.babylonjs.com/babylon101/materials#texture
  102749. */
  102750. export class Texture extends BaseTexture {
  102751. /**
  102752. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  102753. */
  102754. static SerializeBuffers: boolean;
  102755. /** @hidden */
  102756. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  102757. /** @hidden */
  102758. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  102759. /** @hidden */
  102760. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  102761. /** nearest is mag = nearest and min = nearest and mip = linear */
  102762. static readonly NEAREST_SAMPLINGMODE: number;
  102763. /** nearest is mag = nearest and min = nearest and mip = linear */
  102764. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  102765. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102766. static readonly BILINEAR_SAMPLINGMODE: number;
  102767. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102768. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  102769. /** Trilinear is mag = linear and min = linear and mip = linear */
  102770. static readonly TRILINEAR_SAMPLINGMODE: number;
  102771. /** Trilinear is mag = linear and min = linear and mip = linear */
  102772. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  102773. /** mag = nearest and min = nearest and mip = nearest */
  102774. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  102775. /** mag = nearest and min = linear and mip = nearest */
  102776. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  102777. /** mag = nearest and min = linear and mip = linear */
  102778. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  102779. /** mag = nearest and min = linear and mip = none */
  102780. static readonly NEAREST_LINEAR: number;
  102781. /** mag = nearest and min = nearest and mip = none */
  102782. static readonly NEAREST_NEAREST: number;
  102783. /** mag = linear and min = nearest and mip = nearest */
  102784. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  102785. /** mag = linear and min = nearest and mip = linear */
  102786. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  102787. /** mag = linear and min = linear and mip = none */
  102788. static readonly LINEAR_LINEAR: number;
  102789. /** mag = linear and min = nearest and mip = none */
  102790. static readonly LINEAR_NEAREST: number;
  102791. /** Explicit coordinates mode */
  102792. static readonly EXPLICIT_MODE: number;
  102793. /** Spherical coordinates mode */
  102794. static readonly SPHERICAL_MODE: number;
  102795. /** Planar coordinates mode */
  102796. static readonly PLANAR_MODE: number;
  102797. /** Cubic coordinates mode */
  102798. static readonly CUBIC_MODE: number;
  102799. /** Projection coordinates mode */
  102800. static readonly PROJECTION_MODE: number;
  102801. /** Inverse Cubic coordinates mode */
  102802. static readonly SKYBOX_MODE: number;
  102803. /** Inverse Cubic coordinates mode */
  102804. static readonly INVCUBIC_MODE: number;
  102805. /** Equirectangular coordinates mode */
  102806. static readonly EQUIRECTANGULAR_MODE: number;
  102807. /** Equirectangular Fixed coordinates mode */
  102808. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  102809. /** Equirectangular Fixed Mirrored coordinates mode */
  102810. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  102811. /** Texture is not repeating outside of 0..1 UVs */
  102812. static readonly CLAMP_ADDRESSMODE: number;
  102813. /** Texture is repeating outside of 0..1 UVs */
  102814. static readonly WRAP_ADDRESSMODE: number;
  102815. /** Texture is repeating and mirrored */
  102816. static readonly MIRROR_ADDRESSMODE: number;
  102817. /**
  102818. * 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
  102819. */
  102820. static UseSerializedUrlIfAny: boolean;
  102821. /**
  102822. * Define the url of the texture.
  102823. */
  102824. url: Nullable<string>;
  102825. /**
  102826. * Define an offset on the texture to offset the u coordinates of the UVs
  102827. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  102828. */
  102829. uOffset: number;
  102830. /**
  102831. * Define an offset on the texture to offset the v coordinates of the UVs
  102832. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  102833. */
  102834. vOffset: number;
  102835. /**
  102836. * Define an offset on the texture to scale the u coordinates of the UVs
  102837. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  102838. */
  102839. uScale: number;
  102840. /**
  102841. * Define an offset on the texture to scale the v coordinates of the UVs
  102842. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  102843. */
  102844. vScale: number;
  102845. /**
  102846. * Define an offset on the texture to rotate around the u coordinates of the UVs
  102847. * @see https://doc.babylonjs.com/how_to/more_materials
  102848. */
  102849. uAng: number;
  102850. /**
  102851. * Define an offset on the texture to rotate around the v coordinates of the UVs
  102852. * @see https://doc.babylonjs.com/how_to/more_materials
  102853. */
  102854. vAng: number;
  102855. /**
  102856. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  102857. * @see https://doc.babylonjs.com/how_to/more_materials
  102858. */
  102859. wAng: number;
  102860. /**
  102861. * Defines the center of rotation (U)
  102862. */
  102863. uRotationCenter: number;
  102864. /**
  102865. * Defines the center of rotation (V)
  102866. */
  102867. vRotationCenter: number;
  102868. /**
  102869. * Defines the center of rotation (W)
  102870. */
  102871. wRotationCenter: number;
  102872. /**
  102873. * Are mip maps generated for this texture or not.
  102874. */
  102875. get noMipmap(): boolean;
  102876. /**
  102877. * List of inspectable custom properties (used by the Inspector)
  102878. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102879. */
  102880. inspectableCustomProperties: Nullable<IInspectable[]>;
  102881. private _noMipmap;
  102882. /** @hidden */
  102883. _invertY: boolean;
  102884. private _rowGenerationMatrix;
  102885. private _cachedTextureMatrix;
  102886. private _projectionModeMatrix;
  102887. private _t0;
  102888. private _t1;
  102889. private _t2;
  102890. private _cachedUOffset;
  102891. private _cachedVOffset;
  102892. private _cachedUScale;
  102893. private _cachedVScale;
  102894. private _cachedUAng;
  102895. private _cachedVAng;
  102896. private _cachedWAng;
  102897. private _cachedProjectionMatrixId;
  102898. private _cachedCoordinatesMode;
  102899. /** @hidden */
  102900. protected _initialSamplingMode: number;
  102901. /** @hidden */
  102902. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  102903. private _deleteBuffer;
  102904. protected _format: Nullable<number>;
  102905. private _delayedOnLoad;
  102906. private _delayedOnError;
  102907. private _mimeType?;
  102908. /**
  102909. * Observable triggered once the texture has been loaded.
  102910. */
  102911. onLoadObservable: Observable<Texture>;
  102912. protected _isBlocking: boolean;
  102913. /**
  102914. * Is the texture preventing material to render while loading.
  102915. * If false, a default texture will be used instead of the loading one during the preparation step.
  102916. */
  102917. set isBlocking(value: boolean);
  102918. get isBlocking(): boolean;
  102919. /**
  102920. * Get the current sampling mode associated with the texture.
  102921. */
  102922. get samplingMode(): number;
  102923. /**
  102924. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  102925. */
  102926. get invertY(): boolean;
  102927. /**
  102928. * Instantiates a new texture.
  102929. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  102930. * @see https://doc.babylonjs.com/babylon101/materials#texture
  102931. * @param url defines the url of the picture to load as a texture
  102932. * @param sceneOrEngine defines the scene or engine the texture will belong to
  102933. * @param noMipmap defines if the texture will require mip maps or not
  102934. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  102935. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102936. * @param onLoad defines a callback triggered when the texture has been loaded
  102937. * @param onError defines a callback triggered when an error occurred during the loading session
  102938. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  102939. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  102940. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102941. * @param mimeType defines an optional mime type information
  102942. */
  102943. 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);
  102944. /**
  102945. * Update the url (and optional buffer) of this texture if url was null during construction.
  102946. * @param url the url of the texture
  102947. * @param buffer the buffer of the texture (defaults to null)
  102948. * @param onLoad callback called when the texture is loaded (defaults to null)
  102949. */
  102950. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  102951. /**
  102952. * Finish the loading sequence of a texture flagged as delayed load.
  102953. * @hidden
  102954. */
  102955. delayLoad(): void;
  102956. private _prepareRowForTextureGeneration;
  102957. /**
  102958. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  102959. * @returns the transform matrix of the texture.
  102960. */
  102961. getTextureMatrix(uBase?: number): Matrix;
  102962. /**
  102963. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  102964. * @returns The reflection texture transform
  102965. */
  102966. getReflectionTextureMatrix(): Matrix;
  102967. /**
  102968. * Clones the texture.
  102969. * @returns the cloned texture
  102970. */
  102971. clone(): Texture;
  102972. /**
  102973. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  102974. * @returns The JSON representation of the texture
  102975. */
  102976. serialize(): any;
  102977. /**
  102978. * Get the current class name of the texture useful for serialization or dynamic coding.
  102979. * @returns "Texture"
  102980. */
  102981. getClassName(): string;
  102982. /**
  102983. * Dispose the texture and release its associated resources.
  102984. */
  102985. dispose(): void;
  102986. /**
  102987. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  102988. * @param parsedTexture Define the JSON representation of the texture
  102989. * @param scene Define the scene the parsed texture should be instantiated in
  102990. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  102991. * @returns The parsed texture if successful
  102992. */
  102993. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  102994. /**
  102995. * Creates a texture from its base 64 representation.
  102996. * @param data Define the base64 payload without the data: prefix
  102997. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  102998. * @param scene Define the scene the texture should belong to
  102999. * @param noMipmap Forces the texture to not create mip map information if true
  103000. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103001. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103002. * @param onLoad define a callback triggered when the texture has been loaded
  103003. * @param onError define a callback triggered when an error occurred during the loading session
  103004. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103005. * @returns the created texture
  103006. */
  103007. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  103008. /**
  103009. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  103010. * @param data Define the base64 payload without the data: prefix
  103011. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103012. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  103013. * @param scene Define the scene the texture should belong to
  103014. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  103015. * @param noMipmap Forces the texture to not create mip map information if true
  103016. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103017. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103018. * @param onLoad define a callback triggered when the texture has been loaded
  103019. * @param onError define a callback triggered when an error occurred during the loading session
  103020. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103021. * @returns the created texture
  103022. */
  103023. 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;
  103024. }
  103025. }
  103026. declare module BABYLON {
  103027. /**
  103028. * PostProcessManager is used to manage one or more post processes or post process pipelines
  103029. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103030. */
  103031. export class PostProcessManager {
  103032. private _scene;
  103033. private _indexBuffer;
  103034. private _vertexBuffers;
  103035. /**
  103036. * Creates a new instance PostProcess
  103037. * @param scene The scene that the post process is associated with.
  103038. */
  103039. constructor(scene: Scene);
  103040. private _prepareBuffers;
  103041. private _buildIndexBuffer;
  103042. /**
  103043. * Rebuilds the vertex buffers of the manager.
  103044. * @hidden
  103045. */
  103046. _rebuild(): void;
  103047. /**
  103048. * Prepares a frame to be run through a post process.
  103049. * @param sourceTexture The input texture to the post procesess. (default: null)
  103050. * @param postProcesses An array of post processes to be run. (default: null)
  103051. * @returns True if the post processes were able to be run.
  103052. * @hidden
  103053. */
  103054. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  103055. /**
  103056. * Manually render a set of post processes to a texture.
  103057. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  103058. * @param postProcesses An array of post processes to be run.
  103059. * @param targetTexture The target texture to render to.
  103060. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  103061. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  103062. * @param lodLevel defines which lod of the texture to render to
  103063. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  103064. */
  103065. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  103066. /**
  103067. * Finalize the result of the output of the postprocesses.
  103068. * @param doNotPresent If true the result will not be displayed to the screen.
  103069. * @param targetTexture The target texture to render to.
  103070. * @param faceIndex The index of the face to bind the target texture to.
  103071. * @param postProcesses The array of post processes to render.
  103072. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  103073. * @hidden
  103074. */
  103075. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  103076. /**
  103077. * Disposes of the post process manager.
  103078. */
  103079. dispose(): void;
  103080. }
  103081. }
  103082. declare module BABYLON {
  103083. /**
  103084. * This Helps creating a texture that will be created from a camera in your scene.
  103085. * It is basically a dynamic texture that could be used to create special effects for instance.
  103086. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  103087. */
  103088. export class RenderTargetTexture extends Texture {
  103089. isCube: boolean;
  103090. /**
  103091. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  103092. */
  103093. static readonly REFRESHRATE_RENDER_ONCE: number;
  103094. /**
  103095. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  103096. */
  103097. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  103098. /**
  103099. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  103100. * the central point of your effect and can save a lot of performances.
  103101. */
  103102. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  103103. /**
  103104. * Use this predicate to dynamically define the list of mesh you want to render.
  103105. * If set, the renderList property will be overwritten.
  103106. */
  103107. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  103108. private _renderList;
  103109. /**
  103110. * Use this list to define the list of mesh you want to render.
  103111. */
  103112. get renderList(): Nullable<Array<AbstractMesh>>;
  103113. set renderList(value: Nullable<Array<AbstractMesh>>);
  103114. /**
  103115. * Use this function to overload the renderList array at rendering time.
  103116. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  103117. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  103118. * the cube (if the RTT is a cube, else layerOrFace=0).
  103119. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  103120. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  103121. * hold dummy elements!
  103122. */
  103123. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  103124. private _hookArray;
  103125. /**
  103126. * Define if particles should be rendered in your texture.
  103127. */
  103128. renderParticles: boolean;
  103129. /**
  103130. * Define if sprites should be rendered in your texture.
  103131. */
  103132. renderSprites: boolean;
  103133. /**
  103134. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  103135. */
  103136. coordinatesMode: number;
  103137. /**
  103138. * Define the camera used to render the texture.
  103139. */
  103140. activeCamera: Nullable<Camera>;
  103141. /**
  103142. * Override the mesh isReady function with your own one.
  103143. */
  103144. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  103145. /**
  103146. * Override the render function of the texture with your own one.
  103147. */
  103148. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  103149. /**
  103150. * Define if camera post processes should be use while rendering the texture.
  103151. */
  103152. useCameraPostProcesses: boolean;
  103153. /**
  103154. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  103155. */
  103156. ignoreCameraViewport: boolean;
  103157. private _postProcessManager;
  103158. private _postProcesses;
  103159. private _resizeObserver;
  103160. /**
  103161. * An event triggered when the texture is unbind.
  103162. */
  103163. onBeforeBindObservable: Observable<RenderTargetTexture>;
  103164. /**
  103165. * An event triggered when the texture is unbind.
  103166. */
  103167. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  103168. private _onAfterUnbindObserver;
  103169. /**
  103170. * Set a after unbind callback in the texture.
  103171. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  103172. */
  103173. set onAfterUnbind(callback: () => void);
  103174. /**
  103175. * An event triggered before rendering the texture
  103176. */
  103177. onBeforeRenderObservable: Observable<number>;
  103178. private _onBeforeRenderObserver;
  103179. /**
  103180. * Set a before render callback in the texture.
  103181. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  103182. */
  103183. set onBeforeRender(callback: (faceIndex: number) => void);
  103184. /**
  103185. * An event triggered after rendering the texture
  103186. */
  103187. onAfterRenderObservable: Observable<number>;
  103188. private _onAfterRenderObserver;
  103189. /**
  103190. * Set a after render callback in the texture.
  103191. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  103192. */
  103193. set onAfterRender(callback: (faceIndex: number) => void);
  103194. /**
  103195. * An event triggered after the texture clear
  103196. */
  103197. onClearObservable: Observable<Engine>;
  103198. private _onClearObserver;
  103199. /**
  103200. * Set a clear callback in the texture.
  103201. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  103202. */
  103203. set onClear(callback: (Engine: Engine) => void);
  103204. /**
  103205. * An event triggered when the texture is resized.
  103206. */
  103207. onResizeObservable: Observable<RenderTargetTexture>;
  103208. /**
  103209. * Define the clear color of the Render Target if it should be different from the scene.
  103210. */
  103211. clearColor: Color4;
  103212. protected _size: number | {
  103213. width: number;
  103214. height: number;
  103215. layers?: number;
  103216. };
  103217. protected _initialSizeParameter: number | {
  103218. width: number;
  103219. height: number;
  103220. } | {
  103221. ratio: number;
  103222. };
  103223. protected _sizeRatio: Nullable<number>;
  103224. /** @hidden */
  103225. _generateMipMaps: boolean;
  103226. protected _renderingManager: RenderingManager;
  103227. /** @hidden */
  103228. _waitingRenderList: string[];
  103229. protected _doNotChangeAspectRatio: boolean;
  103230. protected _currentRefreshId: number;
  103231. protected _refreshRate: number;
  103232. protected _textureMatrix: Matrix;
  103233. protected _samples: number;
  103234. protected _renderTargetOptions: RenderTargetCreationOptions;
  103235. /**
  103236. * Gets render target creation options that were used.
  103237. */
  103238. get renderTargetOptions(): RenderTargetCreationOptions;
  103239. protected _onRatioRescale(): void;
  103240. /**
  103241. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  103242. * It must define where the camera used to render the texture is set
  103243. */
  103244. boundingBoxPosition: Vector3;
  103245. private _boundingBoxSize;
  103246. /**
  103247. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  103248. * When defined, the cubemap will switch to local mode
  103249. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  103250. * @example https://www.babylonjs-playground.com/#RNASML
  103251. */
  103252. set boundingBoxSize(value: Vector3);
  103253. get boundingBoxSize(): Vector3;
  103254. /**
  103255. * In case the RTT has been created with a depth texture, get the associated
  103256. * depth texture.
  103257. * Otherwise, return null.
  103258. */
  103259. get depthStencilTexture(): Nullable<InternalTexture>;
  103260. /**
  103261. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  103262. * or used a shadow, depth texture...
  103263. * @param name The friendly name of the texture
  103264. * @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)
  103265. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  103266. * @param generateMipMaps True if mip maps need to be generated after render.
  103267. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  103268. * @param type The type of the buffer in the RTT (int, half float, float...)
  103269. * @param isCube True if a cube texture needs to be created
  103270. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  103271. * @param generateDepthBuffer True to generate a depth buffer
  103272. * @param generateStencilBuffer True to generate a stencil buffer
  103273. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  103274. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  103275. * @param delayAllocation if the texture allocation should be delayed (default: false)
  103276. */
  103277. constructor(name: string, size: number | {
  103278. width: number;
  103279. height: number;
  103280. layers?: number;
  103281. } | {
  103282. ratio: number;
  103283. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  103284. /**
  103285. * Creates a depth stencil texture.
  103286. * This is only available in WebGL 2 or with the depth texture extension available.
  103287. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  103288. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  103289. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  103290. */
  103291. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  103292. private _processSizeParameter;
  103293. /**
  103294. * Define the number of samples to use in case of MSAA.
  103295. * It defaults to one meaning no MSAA has been enabled.
  103296. */
  103297. get samples(): number;
  103298. set samples(value: number);
  103299. /**
  103300. * Resets the refresh counter of the texture and start bak from scratch.
  103301. * Could be useful to regenerate the texture if it is setup to render only once.
  103302. */
  103303. resetRefreshCounter(): void;
  103304. /**
  103305. * Define the refresh rate of the texture or the rendering frequency.
  103306. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  103307. */
  103308. get refreshRate(): number;
  103309. set refreshRate(value: number);
  103310. /**
  103311. * Adds a post process to the render target rendering passes.
  103312. * @param postProcess define the post process to add
  103313. */
  103314. addPostProcess(postProcess: PostProcess): void;
  103315. /**
  103316. * Clear all the post processes attached to the render target
  103317. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  103318. */
  103319. clearPostProcesses(dispose?: boolean): void;
  103320. /**
  103321. * Remove one of the post process from the list of attached post processes to the texture
  103322. * @param postProcess define the post process to remove from the list
  103323. */
  103324. removePostProcess(postProcess: PostProcess): void;
  103325. /** @hidden */
  103326. _shouldRender(): boolean;
  103327. /**
  103328. * Gets the actual render size of the texture.
  103329. * @returns the width of the render size
  103330. */
  103331. getRenderSize(): number;
  103332. /**
  103333. * Gets the actual render width of the texture.
  103334. * @returns the width of the render size
  103335. */
  103336. getRenderWidth(): number;
  103337. /**
  103338. * Gets the actual render height of the texture.
  103339. * @returns the height of the render size
  103340. */
  103341. getRenderHeight(): number;
  103342. /**
  103343. * Gets the actual number of layers of the texture.
  103344. * @returns the number of layers
  103345. */
  103346. getRenderLayers(): number;
  103347. /**
  103348. * Get if the texture can be rescaled or not.
  103349. */
  103350. get canRescale(): boolean;
  103351. /**
  103352. * Resize the texture using a ratio.
  103353. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  103354. */
  103355. scale(ratio: number): void;
  103356. /**
  103357. * Get the texture reflection matrix used to rotate/transform the reflection.
  103358. * @returns the reflection matrix
  103359. */
  103360. getReflectionTextureMatrix(): Matrix;
  103361. /**
  103362. * Resize the texture to a new desired size.
  103363. * Be carrefull as it will recreate all the data in the new texture.
  103364. * @param size Define the new size. It can be:
  103365. * - a number for squared texture,
  103366. * - an object containing { width: number, height: number }
  103367. * - or an object containing a ratio { ratio: number }
  103368. */
  103369. resize(size: number | {
  103370. width: number;
  103371. height: number;
  103372. } | {
  103373. ratio: number;
  103374. }): void;
  103375. private _defaultRenderListPrepared;
  103376. /**
  103377. * Renders all the objects from the render list into the texture.
  103378. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  103379. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  103380. */
  103381. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  103382. private _bestReflectionRenderTargetDimension;
  103383. private _prepareRenderingManager;
  103384. /**
  103385. * @hidden
  103386. * @param faceIndex face index to bind to if this is a cubetexture
  103387. * @param layer defines the index of the texture to bind in the array
  103388. */
  103389. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  103390. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103391. private renderToTarget;
  103392. /**
  103393. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103394. * This allowed control for front to back rendering or reversly depending of the special needs.
  103395. *
  103396. * @param renderingGroupId The rendering group id corresponding to its index
  103397. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103398. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103399. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103400. */
  103401. 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;
  103402. /**
  103403. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103404. *
  103405. * @param renderingGroupId The rendering group id corresponding to its index
  103406. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103407. */
  103408. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  103409. /**
  103410. * Clones the texture.
  103411. * @returns the cloned texture
  103412. */
  103413. clone(): RenderTargetTexture;
  103414. /**
  103415. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103416. * @returns The JSON representation of the texture
  103417. */
  103418. serialize(): any;
  103419. /**
  103420. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  103421. */
  103422. disposeFramebufferObjects(): void;
  103423. /**
  103424. * Dispose the texture and release its associated resources.
  103425. */
  103426. dispose(): void;
  103427. /** @hidden */
  103428. _rebuild(): void;
  103429. /**
  103430. * Clear the info related to rendering groups preventing retention point in material dispose.
  103431. */
  103432. freeRenderingGroups(): void;
  103433. /**
  103434. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  103435. * @returns the view count
  103436. */
  103437. getViewCount(): number;
  103438. }
  103439. }
  103440. declare module BABYLON {
  103441. /**
  103442. * Class used to manipulate GUIDs
  103443. */
  103444. export class GUID {
  103445. /**
  103446. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103447. * Be aware Math.random() could cause collisions, but:
  103448. * "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"
  103449. * @returns a pseudo random id
  103450. */
  103451. static RandomId(): string;
  103452. }
  103453. }
  103454. declare module BABYLON {
  103455. /**
  103456. * Options to be used when creating a shadow depth material
  103457. */
  103458. export interface IIOptionShadowDepthMaterial {
  103459. /** Variables in the vertex shader code that need to have their names remapped.
  103460. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  103461. * "var_name" should be either: worldPos or vNormalW
  103462. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  103463. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  103464. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  103465. */
  103466. remappedVariables?: string[];
  103467. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  103468. standalone?: boolean;
  103469. }
  103470. /**
  103471. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  103472. */
  103473. export class ShadowDepthWrapper {
  103474. private _scene;
  103475. private _options?;
  103476. private _baseMaterial;
  103477. private _onEffectCreatedObserver;
  103478. private _subMeshToEffect;
  103479. private _subMeshToDepthEffect;
  103480. private _meshes;
  103481. /** @hidden */
  103482. _matriceNames: any;
  103483. /** Gets the standalone status of the wrapper */
  103484. get standalone(): boolean;
  103485. /** Gets the base material the wrapper is built upon */
  103486. get baseMaterial(): Material;
  103487. /**
  103488. * Instantiate a new shadow depth wrapper.
  103489. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  103490. * generate the shadow depth map. For more information, please refer to the documentation:
  103491. * https://doc.babylonjs.com/babylon101/shadows
  103492. * @param baseMaterial Material to wrap
  103493. * @param scene Define the scene the material belongs to
  103494. * @param options Options used to create the wrapper
  103495. */
  103496. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  103497. /**
  103498. * Gets the effect to use to generate the depth map
  103499. * @param subMesh subMesh to get the effect for
  103500. * @param shadowGenerator shadow generator to get the effect for
  103501. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  103502. */
  103503. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  103504. /**
  103505. * Specifies that the submesh is ready to be used for depth rendering
  103506. * @param subMesh submesh to check
  103507. * @param defines the list of defines to take into account when checking the effect
  103508. * @param shadowGenerator combined with subMesh, it defines the effect to check
  103509. * @param useInstances specifies that instances should be used
  103510. * @returns a boolean indicating that the submesh is ready or not
  103511. */
  103512. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  103513. /**
  103514. * Disposes the resources
  103515. */
  103516. dispose(): void;
  103517. private _makeEffect;
  103518. }
  103519. }
  103520. declare module BABYLON {
  103521. interface ThinEngine {
  103522. /**
  103523. * Unbind a list of render target textures from the webGL context
  103524. * This is used only when drawBuffer extension or webGL2 are active
  103525. * @param textures defines the render target textures to unbind
  103526. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103527. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103528. */
  103529. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103530. /**
  103531. * Create a multi render target texture
  103532. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103533. * @param size defines the size of the texture
  103534. * @param options defines the creation options
  103535. * @returns the cube texture as an InternalTexture
  103536. */
  103537. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103538. /**
  103539. * Update the sample count for a given multiple render target texture
  103540. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103541. * @param textures defines the textures to update
  103542. * @param samples defines the sample count to set
  103543. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103544. */
  103545. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103546. /**
  103547. * Select a subsets of attachments to draw to.
  103548. * @param attachments gl attachments
  103549. */
  103550. bindAttachments(attachments: number[]): void;
  103551. }
  103552. }
  103553. declare module BABYLON {
  103554. /**
  103555. * Creation options of the multi render target texture.
  103556. */
  103557. export interface IMultiRenderTargetOptions {
  103558. /**
  103559. * Define if the texture needs to create mip maps after render.
  103560. */
  103561. generateMipMaps?: boolean;
  103562. /**
  103563. * Define the types of all the draw buffers we want to create
  103564. */
  103565. types?: number[];
  103566. /**
  103567. * Define the sampling modes of all the draw buffers we want to create
  103568. */
  103569. samplingModes?: number[];
  103570. /**
  103571. * Define if a depth buffer is required
  103572. */
  103573. generateDepthBuffer?: boolean;
  103574. /**
  103575. * Define if a stencil buffer is required
  103576. */
  103577. generateStencilBuffer?: boolean;
  103578. /**
  103579. * Define if a depth texture is required instead of a depth buffer
  103580. */
  103581. generateDepthTexture?: boolean;
  103582. /**
  103583. * Define the number of desired draw buffers
  103584. */
  103585. textureCount?: number;
  103586. /**
  103587. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103588. */
  103589. doNotChangeAspectRatio?: boolean;
  103590. /**
  103591. * Define the default type of the buffers we are creating
  103592. */
  103593. defaultType?: number;
  103594. }
  103595. /**
  103596. * A multi render target, like a render target provides the ability to render to a texture.
  103597. * Unlike the render target, it can render to several draw buffers in one draw.
  103598. * This is specially interesting in deferred rendering or for any effects requiring more than
  103599. * just one color from a single pass.
  103600. */
  103601. export class MultiRenderTarget extends RenderTargetTexture {
  103602. private _internalTextures;
  103603. private _textures;
  103604. private _multiRenderTargetOptions;
  103605. private _count;
  103606. /**
  103607. * Get if draw buffers are currently supported by the used hardware and browser.
  103608. */
  103609. get isSupported(): boolean;
  103610. /**
  103611. * Get the list of textures generated by the multi render target.
  103612. */
  103613. get textures(): Texture[];
  103614. /**
  103615. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103616. */
  103617. get count(): number;
  103618. /**
  103619. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103620. */
  103621. get depthTexture(): Texture;
  103622. /**
  103623. * Set the wrapping mode on U of all the textures we are rendering to.
  103624. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103625. */
  103626. set wrapU(wrap: number);
  103627. /**
  103628. * Set the wrapping mode on V of all the textures we are rendering to.
  103629. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103630. */
  103631. set wrapV(wrap: number);
  103632. /**
  103633. * Instantiate a new multi render target texture.
  103634. * A multi render target, like a render target provides the ability to render to a texture.
  103635. * Unlike the render target, it can render to several draw buffers in one draw.
  103636. * This is specially interesting in deferred rendering or for any effects requiring more than
  103637. * just one color from a single pass.
  103638. * @param name Define the name of the texture
  103639. * @param size Define the size of the buffers to render to
  103640. * @param count Define the number of target we are rendering into
  103641. * @param scene Define the scene the texture belongs to
  103642. * @param options Define the options used to create the multi render target
  103643. */
  103644. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103645. /** @hidden */
  103646. _rebuild(): void;
  103647. private _createInternalTextures;
  103648. private _createTextures;
  103649. /**
  103650. * Define the number of samples used if MSAA is enabled.
  103651. */
  103652. get samples(): number;
  103653. set samples(value: number);
  103654. /**
  103655. * Resize all the textures in the multi render target.
  103656. * Be carrefull as it will recreate all the data in the new texture.
  103657. * @param size Define the new size
  103658. */
  103659. resize(size: any): void;
  103660. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103661. /**
  103662. * Dispose the render targets and their associated resources
  103663. */
  103664. dispose(): void;
  103665. /**
  103666. * Release all the underlying texture used as draw buffers.
  103667. */
  103668. releaseInternalTextures(): void;
  103669. }
  103670. }
  103671. declare module BABYLON {
  103672. /** @hidden */
  103673. export var imageProcessingPixelShader: {
  103674. name: string;
  103675. shader: string;
  103676. };
  103677. }
  103678. declare module BABYLON {
  103679. /**
  103680. * ImageProcessingPostProcess
  103681. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103682. */
  103683. export class ImageProcessingPostProcess extends PostProcess {
  103684. /**
  103685. * Default configuration related to image processing available in the PBR Material.
  103686. */
  103687. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103688. /**
  103689. * Gets the image processing configuration used either in this material.
  103690. */
  103691. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103692. /**
  103693. * Sets the Default image processing configuration used either in the this material.
  103694. *
  103695. * If sets to null, the scene one is in use.
  103696. */
  103697. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103698. /**
  103699. * Keep track of the image processing observer to allow dispose and replace.
  103700. */
  103701. private _imageProcessingObserver;
  103702. /**
  103703. * Attaches a new image processing configuration to the PBR Material.
  103704. * @param configuration
  103705. */
  103706. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103707. /**
  103708. * If the post process is supported.
  103709. */
  103710. get isSupported(): boolean;
  103711. /**
  103712. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103713. */
  103714. get colorCurves(): Nullable<ColorCurves>;
  103715. /**
  103716. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103717. */
  103718. set colorCurves(value: Nullable<ColorCurves>);
  103719. /**
  103720. * Gets wether the color curves effect is enabled.
  103721. */
  103722. get colorCurvesEnabled(): boolean;
  103723. /**
  103724. * Sets wether the color curves effect is enabled.
  103725. */
  103726. set colorCurvesEnabled(value: boolean);
  103727. /**
  103728. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103729. */
  103730. get colorGradingTexture(): Nullable<BaseTexture>;
  103731. /**
  103732. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103733. */
  103734. set colorGradingTexture(value: Nullable<BaseTexture>);
  103735. /**
  103736. * Gets wether the color grading effect is enabled.
  103737. */
  103738. get colorGradingEnabled(): boolean;
  103739. /**
  103740. * Gets wether the color grading effect is enabled.
  103741. */
  103742. set colorGradingEnabled(value: boolean);
  103743. /**
  103744. * Gets exposure used in the effect.
  103745. */
  103746. get exposure(): number;
  103747. /**
  103748. * Sets exposure used in the effect.
  103749. */
  103750. set exposure(value: number);
  103751. /**
  103752. * Gets wether tonemapping is enabled or not.
  103753. */
  103754. get toneMappingEnabled(): boolean;
  103755. /**
  103756. * Sets wether tonemapping is enabled or not
  103757. */
  103758. set toneMappingEnabled(value: boolean);
  103759. /**
  103760. * Gets the type of tone mapping effect.
  103761. */
  103762. get toneMappingType(): number;
  103763. /**
  103764. * Sets the type of tone mapping effect.
  103765. */
  103766. set toneMappingType(value: number);
  103767. /**
  103768. * Gets contrast used in the effect.
  103769. */
  103770. get contrast(): number;
  103771. /**
  103772. * Sets contrast used in the effect.
  103773. */
  103774. set contrast(value: number);
  103775. /**
  103776. * Gets Vignette stretch size.
  103777. */
  103778. get vignetteStretch(): number;
  103779. /**
  103780. * Sets Vignette stretch size.
  103781. */
  103782. set vignetteStretch(value: number);
  103783. /**
  103784. * Gets Vignette centre X Offset.
  103785. */
  103786. get vignetteCentreX(): number;
  103787. /**
  103788. * Sets Vignette centre X Offset.
  103789. */
  103790. set vignetteCentreX(value: number);
  103791. /**
  103792. * Gets Vignette centre Y Offset.
  103793. */
  103794. get vignetteCentreY(): number;
  103795. /**
  103796. * Sets Vignette centre Y Offset.
  103797. */
  103798. set vignetteCentreY(value: number);
  103799. /**
  103800. * Gets Vignette weight or intensity of the vignette effect.
  103801. */
  103802. get vignetteWeight(): number;
  103803. /**
  103804. * Sets Vignette weight or intensity of the vignette effect.
  103805. */
  103806. set vignetteWeight(value: number);
  103807. /**
  103808. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103809. * if vignetteEnabled is set to true.
  103810. */
  103811. get vignetteColor(): Color4;
  103812. /**
  103813. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103814. * if vignetteEnabled is set to true.
  103815. */
  103816. set vignetteColor(value: Color4);
  103817. /**
  103818. * Gets Camera field of view used by the Vignette effect.
  103819. */
  103820. get vignetteCameraFov(): number;
  103821. /**
  103822. * Sets Camera field of view used by the Vignette effect.
  103823. */
  103824. set vignetteCameraFov(value: number);
  103825. /**
  103826. * Gets the vignette blend mode allowing different kind of effect.
  103827. */
  103828. get vignetteBlendMode(): number;
  103829. /**
  103830. * Sets the vignette blend mode allowing different kind of effect.
  103831. */
  103832. set vignetteBlendMode(value: number);
  103833. /**
  103834. * Gets wether the vignette effect is enabled.
  103835. */
  103836. get vignetteEnabled(): boolean;
  103837. /**
  103838. * Sets wether the vignette effect is enabled.
  103839. */
  103840. set vignetteEnabled(value: boolean);
  103841. private _fromLinearSpace;
  103842. /**
  103843. * Gets wether the input of the processing is in Gamma or Linear Space.
  103844. */
  103845. get fromLinearSpace(): boolean;
  103846. /**
  103847. * Sets wether the input of the processing is in Gamma or Linear Space.
  103848. */
  103849. set fromLinearSpace(value: boolean);
  103850. /**
  103851. * Defines cache preventing GC.
  103852. */
  103853. private _defines;
  103854. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103855. /**
  103856. * "ImageProcessingPostProcess"
  103857. * @returns "ImageProcessingPostProcess"
  103858. */
  103859. getClassName(): string;
  103860. /**
  103861. * @hidden
  103862. */
  103863. _updateParameters(): void;
  103864. dispose(camera?: Camera): void;
  103865. }
  103866. }
  103867. declare module BABYLON {
  103868. /** @hidden */
  103869. export var fibonacci: {
  103870. name: string;
  103871. shader: string;
  103872. };
  103873. }
  103874. declare module BABYLON {
  103875. /** @hidden */
  103876. export var subSurfaceScatteringFunctions: {
  103877. name: string;
  103878. shader: string;
  103879. };
  103880. }
  103881. declare module BABYLON {
  103882. /** @hidden */
  103883. export var diffusionProfile: {
  103884. name: string;
  103885. shader: string;
  103886. };
  103887. }
  103888. declare module BABYLON {
  103889. /** @hidden */
  103890. export var subSurfaceScatteringPixelShader: {
  103891. name: string;
  103892. shader: string;
  103893. };
  103894. }
  103895. declare module BABYLON {
  103896. /**
  103897. * Sub surface scattering post process
  103898. */
  103899. export class SubSurfaceScatteringPostProcess extends PostProcess {
  103900. /**
  103901. * Gets a string identifying the name of the class
  103902. * @returns "SubSurfaceScatteringPostProcess" string
  103903. */
  103904. getClassName(): string;
  103905. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  103906. }
  103907. }
  103908. declare module BABYLON {
  103909. /**
  103910. * Interface for defining prepass effects in the prepass post-process pipeline
  103911. */
  103912. export interface PrePassEffectConfiguration {
  103913. /**
  103914. * Post process to attach for this effect
  103915. */
  103916. postProcess: PostProcess;
  103917. /**
  103918. * Is the effect enabled
  103919. */
  103920. enabled: boolean;
  103921. /**
  103922. * Disposes the effect configuration
  103923. */
  103924. dispose(): void;
  103925. /**
  103926. * Disposes the effect configuration
  103927. */
  103928. createPostProcess: () => PostProcess;
  103929. }
  103930. }
  103931. declare module BABYLON {
  103932. /**
  103933. * Contains all parameters needed for the prepass to perform
  103934. * screen space subsurface scattering
  103935. */
  103936. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  103937. private _ssDiffusionS;
  103938. private _ssFilterRadii;
  103939. private _ssDiffusionD;
  103940. /**
  103941. * Post process to attach for screen space subsurface scattering
  103942. */
  103943. postProcess: SubSurfaceScatteringPostProcess;
  103944. /**
  103945. * Diffusion profile color for subsurface scattering
  103946. */
  103947. get ssDiffusionS(): number[];
  103948. /**
  103949. * Diffusion profile max color channel value for subsurface scattering
  103950. */
  103951. get ssDiffusionD(): number[];
  103952. /**
  103953. * Diffusion profile filter radius for subsurface scattering
  103954. */
  103955. get ssFilterRadii(): number[];
  103956. /**
  103957. * Is subsurface enabled
  103958. */
  103959. enabled: boolean;
  103960. /**
  103961. * Diffusion profile colors for subsurface scattering
  103962. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  103963. * See ...
  103964. * Note that you can only store up to 5 of them
  103965. */
  103966. ssDiffusionProfileColors: Color3[];
  103967. /**
  103968. * Defines the ratio real world => scene units.
  103969. * Used for subsurface scattering
  103970. */
  103971. metersPerUnit: number;
  103972. private _scene;
  103973. /**
  103974. * Builds a subsurface configuration object
  103975. * @param scene The scene
  103976. */
  103977. constructor(scene: Scene);
  103978. /**
  103979. * Adds a new diffusion profile.
  103980. * Useful for more realistic subsurface scattering on diverse materials.
  103981. * @param color The color of the diffusion profile. Should be the average color of the material.
  103982. * @return The index of the diffusion profile for the material subsurface configuration
  103983. */
  103984. addDiffusionProfile(color: Color3): number;
  103985. /**
  103986. * Creates the sss post process
  103987. * @return The created post process
  103988. */
  103989. createPostProcess(): SubSurfaceScatteringPostProcess;
  103990. /**
  103991. * Deletes all diffusion profiles.
  103992. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  103993. */
  103994. clearAllDiffusionProfiles(): void;
  103995. /**
  103996. * Disposes this object
  103997. */
  103998. dispose(): void;
  103999. /**
  104000. * @hidden
  104001. * https://zero-radiance.github.io/post/sampling-diffusion/
  104002. *
  104003. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  104004. * ------------------------------------------------------------------------------------
  104005. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  104006. * PDF[r, phi, s] = r * R[r, phi, s]
  104007. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  104008. * ------------------------------------------------------------------------------------
  104009. * We importance sample the color channel with the widest scattering distance.
  104010. */
  104011. getDiffusionProfileParameters(color: Color3): number;
  104012. /**
  104013. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  104014. * 'u' is the random number (the value of the CDF): [0, 1).
  104015. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  104016. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  104017. */
  104018. private _sampleBurleyDiffusionProfile;
  104019. }
  104020. }
  104021. declare module BABYLON {
  104022. /**
  104023. * Renders a pre pass of the scene
  104024. * This means every mesh in the scene will be rendered to a render target texture
  104025. * And then this texture will be composited to the rendering canvas with post processes
  104026. * It is necessary for effects like subsurface scattering or deferred shading
  104027. */
  104028. export class PrePassRenderer {
  104029. /** @hidden */
  104030. static _SceneComponentInitialization: (scene: Scene) => void;
  104031. private _scene;
  104032. private _engine;
  104033. private _isDirty;
  104034. /**
  104035. * Number of textures in the multi render target texture where the scene is directly rendered
  104036. */
  104037. readonly mrtCount: number;
  104038. /**
  104039. * The render target where the scene is directly rendered
  104040. */
  104041. prePassRT: MultiRenderTarget;
  104042. private _mrtTypes;
  104043. private _multiRenderAttachments;
  104044. private _defaultAttachments;
  104045. private _clearAttachments;
  104046. private _postProcesses;
  104047. private readonly _clearColor;
  104048. /**
  104049. * Image processing post process for composition
  104050. */
  104051. imageProcessingPostProcess: ImageProcessingPostProcess;
  104052. /**
  104053. * Configuration for sub surface scattering post process
  104054. */
  104055. subSurfaceConfiguration: SubSurfaceConfiguration;
  104056. /**
  104057. * Should materials render their geometry on the MRT
  104058. */
  104059. materialsShouldRenderGeometry: boolean;
  104060. /**
  104061. * Should materials render the irradiance information on the MRT
  104062. */
  104063. materialsShouldRenderIrradiance: boolean;
  104064. private _enabled;
  104065. /**
  104066. * Indicates if the prepass is enabled
  104067. */
  104068. get enabled(): boolean;
  104069. /**
  104070. * How many samples are used for MSAA of the scene render target
  104071. */
  104072. get samples(): number;
  104073. set samples(n: number);
  104074. /**
  104075. * Instanciates a prepass renderer
  104076. * @param scene The scene
  104077. */
  104078. constructor(scene: Scene);
  104079. private _initializeAttachments;
  104080. private _createCompositionEffect;
  104081. /**
  104082. * Indicates if rendering a prepass is supported
  104083. */
  104084. get isSupported(): boolean;
  104085. /**
  104086. * Sets the proper output textures to draw in the engine.
  104087. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  104088. */
  104089. bindAttachmentsForEffect(effect: Effect): void;
  104090. /**
  104091. * @hidden
  104092. */
  104093. _beforeCameraDraw(): void;
  104094. /**
  104095. * @hidden
  104096. */
  104097. _afterCameraDraw(): void;
  104098. private _checkRTSize;
  104099. private _bindFrameBuffer;
  104100. /**
  104101. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  104102. */
  104103. clear(): void;
  104104. private _setState;
  104105. private _enable;
  104106. private _disable;
  104107. private _resetPostProcessChain;
  104108. private _bindPostProcessChain;
  104109. /**
  104110. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  104111. */
  104112. markAsDirty(): void;
  104113. private _update;
  104114. /**
  104115. * Disposes the prepass renderer.
  104116. */
  104117. dispose(): void;
  104118. }
  104119. }
  104120. declare module BABYLON {
  104121. /**
  104122. * Options for compiling materials.
  104123. */
  104124. export interface IMaterialCompilationOptions {
  104125. /**
  104126. * Defines whether clip planes are enabled.
  104127. */
  104128. clipPlane: boolean;
  104129. /**
  104130. * Defines whether instances are enabled.
  104131. */
  104132. useInstances: boolean;
  104133. }
  104134. /**
  104135. * Options passed when calling customShaderNameResolve
  104136. */
  104137. export interface ICustomShaderNameResolveOptions {
  104138. /**
  104139. * 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
  104140. */
  104141. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  104142. }
  104143. /**
  104144. * Base class for the main features of a material in Babylon.js
  104145. */
  104146. export class Material implements IAnimatable {
  104147. /**
  104148. * Returns the triangle fill mode
  104149. */
  104150. static readonly TriangleFillMode: number;
  104151. /**
  104152. * Returns the wireframe mode
  104153. */
  104154. static readonly WireFrameFillMode: number;
  104155. /**
  104156. * Returns the point fill mode
  104157. */
  104158. static readonly PointFillMode: number;
  104159. /**
  104160. * Returns the point list draw mode
  104161. */
  104162. static readonly PointListDrawMode: number;
  104163. /**
  104164. * Returns the line list draw mode
  104165. */
  104166. static readonly LineListDrawMode: number;
  104167. /**
  104168. * Returns the line loop draw mode
  104169. */
  104170. static readonly LineLoopDrawMode: number;
  104171. /**
  104172. * Returns the line strip draw mode
  104173. */
  104174. static readonly LineStripDrawMode: number;
  104175. /**
  104176. * Returns the triangle strip draw mode
  104177. */
  104178. static readonly TriangleStripDrawMode: number;
  104179. /**
  104180. * Returns the triangle fan draw mode
  104181. */
  104182. static readonly TriangleFanDrawMode: number;
  104183. /**
  104184. * Stores the clock-wise side orientation
  104185. */
  104186. static readonly ClockWiseSideOrientation: number;
  104187. /**
  104188. * Stores the counter clock-wise side orientation
  104189. */
  104190. static readonly CounterClockWiseSideOrientation: number;
  104191. /**
  104192. * The dirty texture flag value
  104193. */
  104194. static readonly TextureDirtyFlag: number;
  104195. /**
  104196. * The dirty light flag value
  104197. */
  104198. static readonly LightDirtyFlag: number;
  104199. /**
  104200. * The dirty fresnel flag value
  104201. */
  104202. static readonly FresnelDirtyFlag: number;
  104203. /**
  104204. * The dirty attribute flag value
  104205. */
  104206. static readonly AttributesDirtyFlag: number;
  104207. /**
  104208. * The dirty misc flag value
  104209. */
  104210. static readonly MiscDirtyFlag: number;
  104211. /**
  104212. * The all dirty flag value
  104213. */
  104214. static readonly AllDirtyFlag: number;
  104215. /**
  104216. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104217. */
  104218. static readonly MATERIAL_OPAQUE: number;
  104219. /**
  104220. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104221. */
  104222. static readonly MATERIAL_ALPHATEST: number;
  104223. /**
  104224. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104225. */
  104226. static readonly MATERIAL_ALPHABLEND: number;
  104227. /**
  104228. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104229. * They are also discarded below the alpha cutoff threshold to improve performances.
  104230. */
  104231. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  104232. /**
  104233. * The Whiteout method is used to blend normals.
  104234. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104235. */
  104236. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  104237. /**
  104238. * The Reoriented Normal Mapping method is used to blend normals.
  104239. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104240. */
  104241. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  104242. /**
  104243. * Custom callback helping to override the default shader used in the material.
  104244. */
  104245. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  104246. /**
  104247. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  104248. */
  104249. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  104250. /**
  104251. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  104252. * This means that the material can keep using a previous shader while a new one is being compiled.
  104253. * This is mostly used when shader parallel compilation is supported (true by default)
  104254. */
  104255. allowShaderHotSwapping: boolean;
  104256. /**
  104257. * The ID of the material
  104258. */
  104259. id: string;
  104260. /**
  104261. * Gets or sets the unique id of the material
  104262. */
  104263. uniqueId: number;
  104264. /**
  104265. * The name of the material
  104266. */
  104267. name: string;
  104268. /**
  104269. * Gets or sets user defined metadata
  104270. */
  104271. metadata: any;
  104272. /**
  104273. * For internal use only. Please do not use.
  104274. */
  104275. reservedDataStore: any;
  104276. /**
  104277. * Specifies if the ready state should be checked on each call
  104278. */
  104279. checkReadyOnEveryCall: boolean;
  104280. /**
  104281. * Specifies if the ready state should be checked once
  104282. */
  104283. checkReadyOnlyOnce: boolean;
  104284. /**
  104285. * The state of the material
  104286. */
  104287. state: string;
  104288. /**
  104289. * If the material can be rendered to several textures with MRT extension
  104290. */
  104291. get canRenderToMRT(): boolean;
  104292. /**
  104293. * The alpha value of the material
  104294. */
  104295. protected _alpha: number;
  104296. /**
  104297. * List of inspectable custom properties (used by the Inspector)
  104298. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104299. */
  104300. inspectableCustomProperties: IInspectable[];
  104301. /**
  104302. * Sets the alpha value of the material
  104303. */
  104304. set alpha(value: number);
  104305. /**
  104306. * Gets the alpha value of the material
  104307. */
  104308. get alpha(): number;
  104309. /**
  104310. * Specifies if back face culling is enabled
  104311. */
  104312. protected _backFaceCulling: boolean;
  104313. /**
  104314. * Sets the back-face culling state
  104315. */
  104316. set backFaceCulling(value: boolean);
  104317. /**
  104318. * Gets the back-face culling state
  104319. */
  104320. get backFaceCulling(): boolean;
  104321. /**
  104322. * Stores the value for side orientation
  104323. */
  104324. sideOrientation: number;
  104325. /**
  104326. * Callback triggered when the material is compiled
  104327. */
  104328. onCompiled: Nullable<(effect: Effect) => void>;
  104329. /**
  104330. * Callback triggered when an error occurs
  104331. */
  104332. onError: Nullable<(effect: Effect, errors: string) => void>;
  104333. /**
  104334. * Callback triggered to get the render target textures
  104335. */
  104336. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  104337. /**
  104338. * Gets a boolean indicating that current material needs to register RTT
  104339. */
  104340. get hasRenderTargetTextures(): boolean;
  104341. /**
  104342. * Specifies if the material should be serialized
  104343. */
  104344. doNotSerialize: boolean;
  104345. /**
  104346. * @hidden
  104347. */
  104348. _storeEffectOnSubMeshes: boolean;
  104349. /**
  104350. * Stores the animations for the material
  104351. */
  104352. animations: Nullable<Array<Animation>>;
  104353. /**
  104354. * An event triggered when the material is disposed
  104355. */
  104356. onDisposeObservable: Observable<Material>;
  104357. /**
  104358. * An observer which watches for dispose events
  104359. */
  104360. private _onDisposeObserver;
  104361. private _onUnBindObservable;
  104362. /**
  104363. * Called during a dispose event
  104364. */
  104365. set onDispose(callback: () => void);
  104366. private _onBindObservable;
  104367. /**
  104368. * An event triggered when the material is bound
  104369. */
  104370. get onBindObservable(): Observable<AbstractMesh>;
  104371. /**
  104372. * An observer which watches for bind events
  104373. */
  104374. private _onBindObserver;
  104375. /**
  104376. * Called during a bind event
  104377. */
  104378. set onBind(callback: (Mesh: AbstractMesh) => void);
  104379. /**
  104380. * An event triggered when the material is unbound
  104381. */
  104382. get onUnBindObservable(): Observable<Material>;
  104383. protected _onEffectCreatedObservable: Nullable<Observable<{
  104384. effect: Effect;
  104385. subMesh: Nullable<SubMesh>;
  104386. }>>;
  104387. /**
  104388. * An event triggered when the effect is (re)created
  104389. */
  104390. get onEffectCreatedObservable(): Observable<{
  104391. effect: Effect;
  104392. subMesh: Nullable<SubMesh>;
  104393. }>;
  104394. /**
  104395. * Stores the value of the alpha mode
  104396. */
  104397. private _alphaMode;
  104398. /**
  104399. * Sets the value of the alpha mode.
  104400. *
  104401. * | Value | Type | Description |
  104402. * | --- | --- | --- |
  104403. * | 0 | ALPHA_DISABLE | |
  104404. * | 1 | ALPHA_ADD | |
  104405. * | 2 | ALPHA_COMBINE | |
  104406. * | 3 | ALPHA_SUBTRACT | |
  104407. * | 4 | ALPHA_MULTIPLY | |
  104408. * | 5 | ALPHA_MAXIMIZED | |
  104409. * | 6 | ALPHA_ONEONE | |
  104410. * | 7 | ALPHA_PREMULTIPLIED | |
  104411. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  104412. * | 9 | ALPHA_INTERPOLATE | |
  104413. * | 10 | ALPHA_SCREENMODE | |
  104414. *
  104415. */
  104416. set alphaMode(value: number);
  104417. /**
  104418. * Gets the value of the alpha mode
  104419. */
  104420. get alphaMode(): number;
  104421. /**
  104422. * Stores the state of the need depth pre-pass value
  104423. */
  104424. private _needDepthPrePass;
  104425. /**
  104426. * Sets the need depth pre-pass value
  104427. */
  104428. set needDepthPrePass(value: boolean);
  104429. /**
  104430. * Gets the depth pre-pass value
  104431. */
  104432. get needDepthPrePass(): boolean;
  104433. /**
  104434. * Specifies if depth writing should be disabled
  104435. */
  104436. disableDepthWrite: boolean;
  104437. /**
  104438. * Specifies if color writing should be disabled
  104439. */
  104440. disableColorWrite: boolean;
  104441. /**
  104442. * Specifies if depth writing should be forced
  104443. */
  104444. forceDepthWrite: boolean;
  104445. /**
  104446. * Specifies the depth function that should be used. 0 means the default engine function
  104447. */
  104448. depthFunction: number;
  104449. /**
  104450. * Specifies if there should be a separate pass for culling
  104451. */
  104452. separateCullingPass: boolean;
  104453. /**
  104454. * Stores the state specifing if fog should be enabled
  104455. */
  104456. private _fogEnabled;
  104457. /**
  104458. * Sets the state for enabling fog
  104459. */
  104460. set fogEnabled(value: boolean);
  104461. /**
  104462. * Gets the value of the fog enabled state
  104463. */
  104464. get fogEnabled(): boolean;
  104465. /**
  104466. * Stores the size of points
  104467. */
  104468. pointSize: number;
  104469. /**
  104470. * Stores the z offset value
  104471. */
  104472. zOffset: number;
  104473. get wireframe(): boolean;
  104474. /**
  104475. * Sets the state of wireframe mode
  104476. */
  104477. set wireframe(value: boolean);
  104478. /**
  104479. * Gets the value specifying if point clouds are enabled
  104480. */
  104481. get pointsCloud(): boolean;
  104482. /**
  104483. * Sets the state of point cloud mode
  104484. */
  104485. set pointsCloud(value: boolean);
  104486. /**
  104487. * Gets the material fill mode
  104488. */
  104489. get fillMode(): number;
  104490. /**
  104491. * Sets the material fill mode
  104492. */
  104493. set fillMode(value: number);
  104494. /**
  104495. * @hidden
  104496. * Stores the effects for the material
  104497. */
  104498. _effect: Nullable<Effect>;
  104499. /**
  104500. * Specifies if uniform buffers should be used
  104501. */
  104502. private _useUBO;
  104503. /**
  104504. * Stores a reference to the scene
  104505. */
  104506. private _scene;
  104507. /**
  104508. * Stores the fill mode state
  104509. */
  104510. private _fillMode;
  104511. /**
  104512. * Specifies if the depth write state should be cached
  104513. */
  104514. private _cachedDepthWriteState;
  104515. /**
  104516. * Specifies if the color write state should be cached
  104517. */
  104518. private _cachedColorWriteState;
  104519. /**
  104520. * Specifies if the depth function state should be cached
  104521. */
  104522. private _cachedDepthFunctionState;
  104523. /**
  104524. * Stores the uniform buffer
  104525. */
  104526. protected _uniformBuffer: UniformBuffer;
  104527. /** @hidden */
  104528. _indexInSceneMaterialArray: number;
  104529. /** @hidden */
  104530. meshMap: Nullable<{
  104531. [id: string]: AbstractMesh | undefined;
  104532. }>;
  104533. /**
  104534. * Creates a material instance
  104535. * @param name defines the name of the material
  104536. * @param scene defines the scene to reference
  104537. * @param doNotAdd specifies if the material should be added to the scene
  104538. */
  104539. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  104540. /**
  104541. * Returns a string representation of the current material
  104542. * @param fullDetails defines a boolean indicating which levels of logging is desired
  104543. * @returns a string with material information
  104544. */
  104545. toString(fullDetails?: boolean): string;
  104546. /**
  104547. * Gets the class name of the material
  104548. * @returns a string with the class name of the material
  104549. */
  104550. getClassName(): string;
  104551. /**
  104552. * Specifies if updates for the material been locked
  104553. */
  104554. get isFrozen(): boolean;
  104555. /**
  104556. * Locks updates for the material
  104557. */
  104558. freeze(): void;
  104559. /**
  104560. * Unlocks updates for the material
  104561. */
  104562. unfreeze(): void;
  104563. /**
  104564. * Specifies if the material is ready to be used
  104565. * @param mesh defines the mesh to check
  104566. * @param useInstances specifies if instances should be used
  104567. * @returns a boolean indicating if the material is ready to be used
  104568. */
  104569. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  104570. /**
  104571. * Specifies that the submesh is ready to be used
  104572. * @param mesh defines the mesh to check
  104573. * @param subMesh defines which submesh to check
  104574. * @param useInstances specifies that instances should be used
  104575. * @returns a boolean indicating that the submesh is ready or not
  104576. */
  104577. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104578. /**
  104579. * Returns the material effect
  104580. * @returns the effect associated with the material
  104581. */
  104582. getEffect(): Nullable<Effect>;
  104583. /**
  104584. * Returns the current scene
  104585. * @returns a Scene
  104586. */
  104587. getScene(): Scene;
  104588. /**
  104589. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104590. */
  104591. protected _forceAlphaTest: boolean;
  104592. /**
  104593. * The transparency mode of the material.
  104594. */
  104595. protected _transparencyMode: Nullable<number>;
  104596. /**
  104597. * Gets the current transparency mode.
  104598. */
  104599. get transparencyMode(): Nullable<number>;
  104600. /**
  104601. * Sets the transparency mode of the material.
  104602. *
  104603. * | Value | Type | Description |
  104604. * | ----- | ----------------------------------- | ----------- |
  104605. * | 0 | OPAQUE | |
  104606. * | 1 | ALPHATEST | |
  104607. * | 2 | ALPHABLEND | |
  104608. * | 3 | ALPHATESTANDBLEND | |
  104609. *
  104610. */
  104611. set transparencyMode(value: Nullable<number>);
  104612. /**
  104613. * Returns true if alpha blending should be disabled.
  104614. */
  104615. protected get _disableAlphaBlending(): boolean;
  104616. /**
  104617. * Specifies whether or not this material should be rendered in alpha blend mode.
  104618. * @returns a boolean specifying if alpha blending is needed
  104619. */
  104620. needAlphaBlending(): boolean;
  104621. /**
  104622. * Specifies if the mesh will require alpha blending
  104623. * @param mesh defines the mesh to check
  104624. * @returns a boolean specifying if alpha blending is needed for the mesh
  104625. */
  104626. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  104627. /**
  104628. * Specifies whether or not this material should be rendered in alpha test mode.
  104629. * @returns a boolean specifying if an alpha test is needed.
  104630. */
  104631. needAlphaTesting(): boolean;
  104632. /**
  104633. * Specifies if material alpha testing should be turned on for the mesh
  104634. * @param mesh defines the mesh to check
  104635. */
  104636. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  104637. /**
  104638. * Gets the texture used for the alpha test
  104639. * @returns the texture to use for alpha testing
  104640. */
  104641. getAlphaTestTexture(): Nullable<BaseTexture>;
  104642. /**
  104643. * Marks the material to indicate that it needs to be re-calculated
  104644. */
  104645. markDirty(): void;
  104646. /** @hidden */
  104647. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  104648. /**
  104649. * Binds the material to the mesh
  104650. * @param world defines the world transformation matrix
  104651. * @param mesh defines the mesh to bind the material to
  104652. */
  104653. bind(world: Matrix, mesh?: Mesh): void;
  104654. /**
  104655. * Binds the submesh to the material
  104656. * @param world defines the world transformation matrix
  104657. * @param mesh defines the mesh containing the submesh
  104658. * @param subMesh defines the submesh to bind the material to
  104659. */
  104660. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104661. /**
  104662. * Binds the world matrix to the material
  104663. * @param world defines the world transformation matrix
  104664. */
  104665. bindOnlyWorldMatrix(world: Matrix): void;
  104666. /**
  104667. * Binds the scene's uniform buffer to the effect.
  104668. * @param effect defines the effect to bind to the scene uniform buffer
  104669. * @param sceneUbo defines the uniform buffer storing scene data
  104670. */
  104671. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  104672. /**
  104673. * Binds the view matrix to the effect
  104674. * @param effect defines the effect to bind the view matrix to
  104675. */
  104676. bindView(effect: Effect): void;
  104677. /**
  104678. * Binds the view projection matrix to the effect
  104679. * @param effect defines the effect to bind the view projection matrix to
  104680. */
  104681. bindViewProjection(effect: Effect): void;
  104682. /**
  104683. * Processes to execute after binding the material to a mesh
  104684. * @param mesh defines the rendered mesh
  104685. */
  104686. protected _afterBind(mesh?: Mesh): void;
  104687. /**
  104688. * Unbinds the material from the mesh
  104689. */
  104690. unbind(): void;
  104691. /**
  104692. * Gets the active textures from the material
  104693. * @returns an array of textures
  104694. */
  104695. getActiveTextures(): BaseTexture[];
  104696. /**
  104697. * Specifies if the material uses a texture
  104698. * @param texture defines the texture to check against the material
  104699. * @returns a boolean specifying if the material uses the texture
  104700. */
  104701. hasTexture(texture: BaseTexture): boolean;
  104702. /**
  104703. * Makes a duplicate of the material, and gives it a new name
  104704. * @param name defines the new name for the duplicated material
  104705. * @returns the cloned material
  104706. */
  104707. clone(name: string): Nullable<Material>;
  104708. /**
  104709. * Gets the meshes bound to the material
  104710. * @returns an array of meshes bound to the material
  104711. */
  104712. getBindedMeshes(): AbstractMesh[];
  104713. /**
  104714. * Force shader compilation
  104715. * @param mesh defines the mesh associated with this material
  104716. * @param onCompiled defines a function to execute once the material is compiled
  104717. * @param options defines the options to configure the compilation
  104718. * @param onError defines a function to execute if the material fails compiling
  104719. */
  104720. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  104721. /**
  104722. * Force shader compilation
  104723. * @param mesh defines the mesh that will use this material
  104724. * @param options defines additional options for compiling the shaders
  104725. * @returns a promise that resolves when the compilation completes
  104726. */
  104727. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  104728. private static readonly _AllDirtyCallBack;
  104729. private static readonly _ImageProcessingDirtyCallBack;
  104730. private static readonly _TextureDirtyCallBack;
  104731. private static readonly _FresnelDirtyCallBack;
  104732. private static readonly _MiscDirtyCallBack;
  104733. private static readonly _LightsDirtyCallBack;
  104734. private static readonly _AttributeDirtyCallBack;
  104735. private static _FresnelAndMiscDirtyCallBack;
  104736. private static _TextureAndMiscDirtyCallBack;
  104737. private static readonly _DirtyCallbackArray;
  104738. private static readonly _RunDirtyCallBacks;
  104739. /**
  104740. * Marks a define in the material to indicate that it needs to be re-computed
  104741. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  104742. */
  104743. markAsDirty(flag: number): void;
  104744. /**
  104745. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  104746. * @param func defines a function which checks material defines against the submeshes
  104747. */
  104748. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  104749. /**
  104750. * Indicates that the scene should check if the rendering now needs a prepass
  104751. */
  104752. protected _markScenePrePassDirty(): void;
  104753. /**
  104754. * Indicates that we need to re-calculated for all submeshes
  104755. */
  104756. protected _markAllSubMeshesAsAllDirty(): void;
  104757. /**
  104758. * Indicates that image processing needs to be re-calculated for all submeshes
  104759. */
  104760. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  104761. /**
  104762. * Indicates that textures need to be re-calculated for all submeshes
  104763. */
  104764. protected _markAllSubMeshesAsTexturesDirty(): void;
  104765. /**
  104766. * Indicates that fresnel needs to be re-calculated for all submeshes
  104767. */
  104768. protected _markAllSubMeshesAsFresnelDirty(): void;
  104769. /**
  104770. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  104771. */
  104772. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  104773. /**
  104774. * Indicates that lights need to be re-calculated for all submeshes
  104775. */
  104776. protected _markAllSubMeshesAsLightsDirty(): void;
  104777. /**
  104778. * Indicates that attributes need to be re-calculated for all submeshes
  104779. */
  104780. protected _markAllSubMeshesAsAttributesDirty(): void;
  104781. /**
  104782. * Indicates that misc needs to be re-calculated for all submeshes
  104783. */
  104784. protected _markAllSubMeshesAsMiscDirty(): void;
  104785. /**
  104786. * Indicates that textures and misc need to be re-calculated for all submeshes
  104787. */
  104788. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  104789. /**
  104790. * Sets the required values to the prepass renderer.
  104791. * @param prePassRenderer defines the prepass renderer to setup.
  104792. * @returns true if the pre pass is needed.
  104793. */
  104794. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  104795. /**
  104796. * Disposes the material
  104797. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104798. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104799. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  104800. */
  104801. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  104802. /** @hidden */
  104803. private releaseVertexArrayObject;
  104804. /**
  104805. * Serializes this material
  104806. * @returns the serialized material object
  104807. */
  104808. serialize(): any;
  104809. /**
  104810. * Creates a material from parsed material data
  104811. * @param parsedMaterial defines parsed material data
  104812. * @param scene defines the hosting scene
  104813. * @param rootUrl defines the root URL to use to load textures
  104814. * @returns a new material
  104815. */
  104816. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  104817. }
  104818. }
  104819. declare module BABYLON {
  104820. /**
  104821. * A multi-material is used to apply different materials to different parts of the same object without the need of
  104822. * separate meshes. This can be use to improve performances.
  104823. * @see https://doc.babylonjs.com/how_to/multi_materials
  104824. */
  104825. export class MultiMaterial extends Material {
  104826. private _subMaterials;
  104827. /**
  104828. * Gets or Sets the list of Materials used within the multi material.
  104829. * They need to be ordered according to the submeshes order in the associated mesh
  104830. */
  104831. get subMaterials(): Nullable<Material>[];
  104832. set subMaterials(value: Nullable<Material>[]);
  104833. /**
  104834. * Function used to align with Node.getChildren()
  104835. * @returns the list of Materials used within the multi material
  104836. */
  104837. getChildren(): Nullable<Material>[];
  104838. /**
  104839. * Instantiates a new Multi Material
  104840. * A multi-material is used to apply different materials to different parts of the same object without the need of
  104841. * separate meshes. This can be use to improve performances.
  104842. * @see https://doc.babylonjs.com/how_to/multi_materials
  104843. * @param name Define the name in the scene
  104844. * @param scene Define the scene the material belongs to
  104845. */
  104846. constructor(name: string, scene: Scene);
  104847. private _hookArray;
  104848. /**
  104849. * Get one of the submaterial by its index in the submaterials array
  104850. * @param index The index to look the sub material at
  104851. * @returns The Material if the index has been defined
  104852. */
  104853. getSubMaterial(index: number): Nullable<Material>;
  104854. /**
  104855. * Get the list of active textures for the whole sub materials list.
  104856. * @returns All the textures that will be used during the rendering
  104857. */
  104858. getActiveTextures(): BaseTexture[];
  104859. /**
  104860. * Gets the current class name of the material e.g. "MultiMaterial"
  104861. * Mainly use in serialization.
  104862. * @returns the class name
  104863. */
  104864. getClassName(): string;
  104865. /**
  104866. * Checks if the material is ready to render the requested sub mesh
  104867. * @param mesh Define the mesh the submesh belongs to
  104868. * @param subMesh Define the sub mesh to look readyness for
  104869. * @param useInstances Define whether or not the material is used with instances
  104870. * @returns true if ready, otherwise false
  104871. */
  104872. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104873. /**
  104874. * Clones the current material and its related sub materials
  104875. * @param name Define the name of the newly cloned material
  104876. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  104877. * @returns the cloned material
  104878. */
  104879. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  104880. /**
  104881. * Serializes the materials into a JSON representation.
  104882. * @returns the JSON representation
  104883. */
  104884. serialize(): any;
  104885. /**
  104886. * Dispose the material and release its associated resources
  104887. * @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)
  104888. * @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)
  104889. * @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)
  104890. */
  104891. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  104892. /**
  104893. * Creates a MultiMaterial from parsed MultiMaterial data.
  104894. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  104895. * @param scene defines the hosting scene
  104896. * @returns a new MultiMaterial
  104897. */
  104898. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  104899. }
  104900. }
  104901. declare module BABYLON {
  104902. /**
  104903. * Defines a subdivision inside a mesh
  104904. */
  104905. export class SubMesh implements ICullable {
  104906. /** the material index to use */
  104907. materialIndex: number;
  104908. /** vertex index start */
  104909. verticesStart: number;
  104910. /** vertices count */
  104911. verticesCount: number;
  104912. /** index start */
  104913. indexStart: number;
  104914. /** indices count */
  104915. indexCount: number;
  104916. /** @hidden */
  104917. _materialDefines: Nullable<MaterialDefines>;
  104918. /** @hidden */
  104919. _materialEffect: Nullable<Effect>;
  104920. /** @hidden */
  104921. _effectOverride: Nullable<Effect>;
  104922. /**
  104923. * Gets material defines used by the effect associated to the sub mesh
  104924. */
  104925. get materialDefines(): Nullable<MaterialDefines>;
  104926. /**
  104927. * Sets material defines used by the effect associated to the sub mesh
  104928. */
  104929. set materialDefines(defines: Nullable<MaterialDefines>);
  104930. /**
  104931. * Gets associated effect
  104932. */
  104933. get effect(): Nullable<Effect>;
  104934. /**
  104935. * Sets associated effect (effect used to render this submesh)
  104936. * @param effect defines the effect to associate with
  104937. * @param defines defines the set of defines used to compile this effect
  104938. */
  104939. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  104940. /** @hidden */
  104941. _linesIndexCount: number;
  104942. private _mesh;
  104943. private _renderingMesh;
  104944. private _boundingInfo;
  104945. private _linesIndexBuffer;
  104946. /** @hidden */
  104947. _lastColliderWorldVertices: Nullable<Vector3[]>;
  104948. /** @hidden */
  104949. _trianglePlanes: Plane[];
  104950. /** @hidden */
  104951. _lastColliderTransformMatrix: Nullable<Matrix>;
  104952. /** @hidden */
  104953. _renderId: number;
  104954. /** @hidden */
  104955. _alphaIndex: number;
  104956. /** @hidden */
  104957. _distanceToCamera: number;
  104958. /** @hidden */
  104959. _id: number;
  104960. private _currentMaterial;
  104961. /**
  104962. * Add a new submesh to a mesh
  104963. * @param materialIndex defines the material index to use
  104964. * @param verticesStart defines vertex index start
  104965. * @param verticesCount defines vertices count
  104966. * @param indexStart defines index start
  104967. * @param indexCount defines indices count
  104968. * @param mesh defines the parent mesh
  104969. * @param renderingMesh defines an optional rendering mesh
  104970. * @param createBoundingBox defines if bounding box should be created for this submesh
  104971. * @returns the new submesh
  104972. */
  104973. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  104974. /**
  104975. * Creates a new submesh
  104976. * @param materialIndex defines the material index to use
  104977. * @param verticesStart defines vertex index start
  104978. * @param verticesCount defines vertices count
  104979. * @param indexStart defines index start
  104980. * @param indexCount defines indices count
  104981. * @param mesh defines the parent mesh
  104982. * @param renderingMesh defines an optional rendering mesh
  104983. * @param createBoundingBox defines if bounding box should be created for this submesh
  104984. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  104985. */
  104986. constructor(
  104987. /** the material index to use */
  104988. materialIndex: number,
  104989. /** vertex index start */
  104990. verticesStart: number,
  104991. /** vertices count */
  104992. verticesCount: number,
  104993. /** index start */
  104994. indexStart: number,
  104995. /** indices count */
  104996. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  104997. /**
  104998. * Returns true if this submesh covers the entire parent mesh
  104999. * @ignorenaming
  105000. */
  105001. get IsGlobal(): boolean;
  105002. /**
  105003. * Returns the submesh BoudingInfo object
  105004. * @returns current bounding info (or mesh's one if the submesh is global)
  105005. */
  105006. getBoundingInfo(): BoundingInfo;
  105007. /**
  105008. * Sets the submesh BoundingInfo
  105009. * @param boundingInfo defines the new bounding info to use
  105010. * @returns the SubMesh
  105011. */
  105012. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  105013. /**
  105014. * Returns the mesh of the current submesh
  105015. * @return the parent mesh
  105016. */
  105017. getMesh(): AbstractMesh;
  105018. /**
  105019. * Returns the rendering mesh of the submesh
  105020. * @returns the rendering mesh (could be different from parent mesh)
  105021. */
  105022. getRenderingMesh(): Mesh;
  105023. /**
  105024. * Returns the replacement mesh of the submesh
  105025. * @returns the replacement mesh (could be different from parent mesh)
  105026. */
  105027. getReplacementMesh(): Nullable<AbstractMesh>;
  105028. /**
  105029. * Returns the effective mesh of the submesh
  105030. * @returns the effective mesh (could be different from parent mesh)
  105031. */
  105032. getEffectiveMesh(): AbstractMesh;
  105033. /**
  105034. * Returns the submesh material
  105035. * @returns null or the current material
  105036. */
  105037. getMaterial(): Nullable<Material>;
  105038. private _IsMultiMaterial;
  105039. /**
  105040. * Sets a new updated BoundingInfo object to the submesh
  105041. * @param data defines an optional position array to use to determine the bounding info
  105042. * @returns the SubMesh
  105043. */
  105044. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  105045. /** @hidden */
  105046. _checkCollision(collider: Collider): boolean;
  105047. /**
  105048. * Updates the submesh BoundingInfo
  105049. * @param world defines the world matrix to use to update the bounding info
  105050. * @returns the submesh
  105051. */
  105052. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  105053. /**
  105054. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  105055. * @param frustumPlanes defines the frustum planes
  105056. * @returns true if the submesh is intersecting with the frustum
  105057. */
  105058. isInFrustum(frustumPlanes: Plane[]): boolean;
  105059. /**
  105060. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  105061. * @param frustumPlanes defines the frustum planes
  105062. * @returns true if the submesh is inside the frustum
  105063. */
  105064. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  105065. /**
  105066. * Renders the submesh
  105067. * @param enableAlphaMode defines if alpha needs to be used
  105068. * @returns the submesh
  105069. */
  105070. render(enableAlphaMode: boolean): SubMesh;
  105071. /**
  105072. * @hidden
  105073. */
  105074. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  105075. /**
  105076. * Checks if the submesh intersects with a ray
  105077. * @param ray defines the ray to test
  105078. * @returns true is the passed ray intersects the submesh bounding box
  105079. */
  105080. canIntersects(ray: Ray): boolean;
  105081. /**
  105082. * Intersects current submesh with a ray
  105083. * @param ray defines the ray to test
  105084. * @param positions defines mesh's positions array
  105085. * @param indices defines mesh's indices array
  105086. * @param fastCheck defines if the first intersection will be used (and not the closest)
  105087. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105088. * @returns intersection info or null if no intersection
  105089. */
  105090. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  105091. /** @hidden */
  105092. private _intersectLines;
  105093. /** @hidden */
  105094. private _intersectUnIndexedLines;
  105095. /** @hidden */
  105096. private _intersectTriangles;
  105097. /** @hidden */
  105098. private _intersectUnIndexedTriangles;
  105099. /** @hidden */
  105100. _rebuild(): void;
  105101. /**
  105102. * Creates a new submesh from the passed mesh
  105103. * @param newMesh defines the new hosting mesh
  105104. * @param newRenderingMesh defines an optional rendering mesh
  105105. * @returns the new submesh
  105106. */
  105107. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  105108. /**
  105109. * Release associated resources
  105110. */
  105111. dispose(): void;
  105112. /**
  105113. * Gets the class name
  105114. * @returns the string "SubMesh".
  105115. */
  105116. getClassName(): string;
  105117. /**
  105118. * Creates a new submesh from indices data
  105119. * @param materialIndex the index of the main mesh material
  105120. * @param startIndex the index where to start the copy in the mesh indices array
  105121. * @param indexCount the number of indices to copy then from the startIndex
  105122. * @param mesh the main mesh to create the submesh from
  105123. * @param renderingMesh the optional rendering mesh
  105124. * @returns a new submesh
  105125. */
  105126. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  105127. }
  105128. }
  105129. declare module BABYLON {
  105130. /**
  105131. * Class used to represent data loading progression
  105132. */
  105133. export class SceneLoaderFlags {
  105134. private static _ForceFullSceneLoadingForIncremental;
  105135. private static _ShowLoadingScreen;
  105136. private static _CleanBoneMatrixWeights;
  105137. private static _loggingLevel;
  105138. /**
  105139. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105140. */
  105141. static get ForceFullSceneLoadingForIncremental(): boolean;
  105142. static set ForceFullSceneLoadingForIncremental(value: boolean);
  105143. /**
  105144. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105145. */
  105146. static get ShowLoadingScreen(): boolean;
  105147. static set ShowLoadingScreen(value: boolean);
  105148. /**
  105149. * Defines the current logging level (while loading the scene)
  105150. * @ignorenaming
  105151. */
  105152. static get loggingLevel(): number;
  105153. static set loggingLevel(value: number);
  105154. /**
  105155. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105156. */
  105157. static get CleanBoneMatrixWeights(): boolean;
  105158. static set CleanBoneMatrixWeights(value: boolean);
  105159. }
  105160. }
  105161. declare module BABYLON {
  105162. /**
  105163. * Class used to store geometry data (vertex buffers + index buffer)
  105164. */
  105165. export class Geometry implements IGetSetVerticesData {
  105166. /**
  105167. * Gets or sets the ID of the geometry
  105168. */
  105169. id: string;
  105170. /**
  105171. * Gets or sets the unique ID of the geometry
  105172. */
  105173. uniqueId: number;
  105174. /**
  105175. * Gets the delay loading state of the geometry (none by default which means not delayed)
  105176. */
  105177. delayLoadState: number;
  105178. /**
  105179. * Gets the file containing the data to load when running in delay load state
  105180. */
  105181. delayLoadingFile: Nullable<string>;
  105182. /**
  105183. * Callback called when the geometry is updated
  105184. */
  105185. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  105186. private _scene;
  105187. private _engine;
  105188. private _meshes;
  105189. private _totalVertices;
  105190. /** @hidden */
  105191. _indices: IndicesArray;
  105192. /** @hidden */
  105193. _vertexBuffers: {
  105194. [key: string]: VertexBuffer;
  105195. };
  105196. private _isDisposed;
  105197. private _extend;
  105198. private _boundingBias;
  105199. /** @hidden */
  105200. _delayInfo: Array<string>;
  105201. private _indexBuffer;
  105202. private _indexBufferIsUpdatable;
  105203. /** @hidden */
  105204. _boundingInfo: Nullable<BoundingInfo>;
  105205. /** @hidden */
  105206. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  105207. /** @hidden */
  105208. _softwareSkinningFrameId: number;
  105209. private _vertexArrayObjects;
  105210. private _updatable;
  105211. /** @hidden */
  105212. _positions: Nullable<Vector3[]>;
  105213. /**
  105214. * 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
  105215. */
  105216. get boundingBias(): Vector2;
  105217. /**
  105218. * 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
  105219. */
  105220. set boundingBias(value: Vector2);
  105221. /**
  105222. * Static function used to attach a new empty geometry to a mesh
  105223. * @param mesh defines the mesh to attach the geometry to
  105224. * @returns the new Geometry
  105225. */
  105226. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  105227. /** Get the list of meshes using this geometry */
  105228. get meshes(): Mesh[];
  105229. /**
  105230. * 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
  105231. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  105232. */
  105233. useBoundingInfoFromGeometry: boolean;
  105234. /**
  105235. * Creates a new geometry
  105236. * @param id defines the unique ID
  105237. * @param scene defines the hosting scene
  105238. * @param vertexData defines the VertexData used to get geometry data
  105239. * @param updatable defines if geometry must be updatable (false by default)
  105240. * @param mesh defines the mesh that will be associated with the geometry
  105241. */
  105242. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  105243. /**
  105244. * Gets the current extend of the geometry
  105245. */
  105246. get extend(): {
  105247. minimum: Vector3;
  105248. maximum: Vector3;
  105249. };
  105250. /**
  105251. * Gets the hosting scene
  105252. * @returns the hosting Scene
  105253. */
  105254. getScene(): Scene;
  105255. /**
  105256. * Gets the hosting engine
  105257. * @returns the hosting Engine
  105258. */
  105259. getEngine(): Engine;
  105260. /**
  105261. * Defines if the geometry is ready to use
  105262. * @returns true if the geometry is ready to be used
  105263. */
  105264. isReady(): boolean;
  105265. /**
  105266. * Gets a value indicating that the geometry should not be serialized
  105267. */
  105268. get doNotSerialize(): boolean;
  105269. /** @hidden */
  105270. _rebuild(): void;
  105271. /**
  105272. * Affects all geometry data in one call
  105273. * @param vertexData defines the geometry data
  105274. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  105275. */
  105276. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  105277. /**
  105278. * Set specific vertex data
  105279. * @param kind defines the data kind (Position, normal, etc...)
  105280. * @param data defines the vertex data to use
  105281. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  105282. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  105283. */
  105284. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  105285. /**
  105286. * Removes a specific vertex data
  105287. * @param kind defines the data kind (Position, normal, etc...)
  105288. */
  105289. removeVerticesData(kind: string): void;
  105290. /**
  105291. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  105292. * @param buffer defines the vertex buffer to use
  105293. * @param totalVertices defines the total number of vertices for position kind (could be null)
  105294. */
  105295. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  105296. /**
  105297. * Update a specific vertex buffer
  105298. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  105299. * It will do nothing if the buffer is not updatable
  105300. * @param kind defines the data kind (Position, normal, etc...)
  105301. * @param data defines the data to use
  105302. * @param offset defines the offset in the target buffer where to store the data
  105303. * @param useBytes set to true if the offset is in bytes
  105304. */
  105305. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  105306. /**
  105307. * Update a specific vertex buffer
  105308. * This function will create a new buffer if the current one is not updatable
  105309. * @param kind defines the data kind (Position, normal, etc...)
  105310. * @param data defines the data to use
  105311. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  105312. */
  105313. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  105314. private _updateBoundingInfo;
  105315. /** @hidden */
  105316. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  105317. /**
  105318. * Gets total number of vertices
  105319. * @returns the total number of vertices
  105320. */
  105321. getTotalVertices(): number;
  105322. /**
  105323. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  105324. * @param kind defines the data kind (Position, normal, etc...)
  105325. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105326. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105327. * @returns a float array containing vertex data
  105328. */
  105329. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105330. /**
  105331. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  105332. * @param kind defines the data kind (Position, normal, etc...)
  105333. * @returns true if the vertex buffer with the specified kind is updatable
  105334. */
  105335. isVertexBufferUpdatable(kind: string): boolean;
  105336. /**
  105337. * Gets a specific vertex buffer
  105338. * @param kind defines the data kind (Position, normal, etc...)
  105339. * @returns a VertexBuffer
  105340. */
  105341. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105342. /**
  105343. * Returns all vertex buffers
  105344. * @return an object holding all vertex buffers indexed by kind
  105345. */
  105346. getVertexBuffers(): Nullable<{
  105347. [key: string]: VertexBuffer;
  105348. }>;
  105349. /**
  105350. * Gets a boolean indicating if specific vertex buffer is present
  105351. * @param kind defines the data kind (Position, normal, etc...)
  105352. * @returns true if data is present
  105353. */
  105354. isVerticesDataPresent(kind: string): boolean;
  105355. /**
  105356. * Gets a list of all attached data kinds (Position, normal, etc...)
  105357. * @returns a list of string containing all kinds
  105358. */
  105359. getVerticesDataKinds(): string[];
  105360. /**
  105361. * Update index buffer
  105362. * @param indices defines the indices to store in the index buffer
  105363. * @param offset defines the offset in the target buffer where to store the data
  105364. * @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)
  105365. */
  105366. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  105367. /**
  105368. * Creates a new index buffer
  105369. * @param indices defines the indices to store in the index buffer
  105370. * @param totalVertices defines the total number of vertices (could be null)
  105371. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  105372. */
  105373. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  105374. /**
  105375. * Return the total number of indices
  105376. * @returns the total number of indices
  105377. */
  105378. getTotalIndices(): number;
  105379. /**
  105380. * Gets the index buffer array
  105381. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105382. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105383. * @returns the index buffer array
  105384. */
  105385. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105386. /**
  105387. * Gets the index buffer
  105388. * @return the index buffer
  105389. */
  105390. getIndexBuffer(): Nullable<DataBuffer>;
  105391. /** @hidden */
  105392. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  105393. /**
  105394. * Release the associated resources for a specific mesh
  105395. * @param mesh defines the source mesh
  105396. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  105397. */
  105398. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  105399. /**
  105400. * Apply current geometry to a given mesh
  105401. * @param mesh defines the mesh to apply geometry to
  105402. */
  105403. applyToMesh(mesh: Mesh): void;
  105404. private _updateExtend;
  105405. private _applyToMesh;
  105406. private notifyUpdate;
  105407. /**
  105408. * Load the geometry if it was flagged as delay loaded
  105409. * @param scene defines the hosting scene
  105410. * @param onLoaded defines a callback called when the geometry is loaded
  105411. */
  105412. load(scene: Scene, onLoaded?: () => void): void;
  105413. private _queueLoad;
  105414. /**
  105415. * Invert the geometry to move from a right handed system to a left handed one.
  105416. */
  105417. toLeftHanded(): void;
  105418. /** @hidden */
  105419. _resetPointsArrayCache(): void;
  105420. /** @hidden */
  105421. _generatePointsArray(): boolean;
  105422. /**
  105423. * Gets a value indicating if the geometry is disposed
  105424. * @returns true if the geometry was disposed
  105425. */
  105426. isDisposed(): boolean;
  105427. private _disposeVertexArrayObjects;
  105428. /**
  105429. * Free all associated resources
  105430. */
  105431. dispose(): void;
  105432. /**
  105433. * Clone the current geometry into a new geometry
  105434. * @param id defines the unique ID of the new geometry
  105435. * @returns a new geometry object
  105436. */
  105437. copy(id: string): Geometry;
  105438. /**
  105439. * Serialize the current geometry info (and not the vertices data) into a JSON object
  105440. * @return a JSON representation of the current geometry data (without the vertices data)
  105441. */
  105442. serialize(): any;
  105443. private toNumberArray;
  105444. /**
  105445. * Serialize all vertices data into a JSON oject
  105446. * @returns a JSON representation of the current geometry data
  105447. */
  105448. serializeVerticeData(): any;
  105449. /**
  105450. * Extracts a clone of a mesh geometry
  105451. * @param mesh defines the source mesh
  105452. * @param id defines the unique ID of the new geometry object
  105453. * @returns the new geometry object
  105454. */
  105455. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  105456. /**
  105457. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  105458. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  105459. * Be aware Math.random() could cause collisions, but:
  105460. * "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"
  105461. * @returns a string containing a new GUID
  105462. */
  105463. static RandomId(): string;
  105464. /** @hidden */
  105465. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  105466. private static _CleanMatricesWeights;
  105467. /**
  105468. * Create a new geometry from persisted data (Using .babylon file format)
  105469. * @param parsedVertexData defines the persisted data
  105470. * @param scene defines the hosting scene
  105471. * @param rootUrl defines the root url to use to load assets (like delayed data)
  105472. * @returns the new geometry object
  105473. */
  105474. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  105475. }
  105476. }
  105477. declare module BABYLON {
  105478. /**
  105479. * Define an interface for all classes that will get and set the data on vertices
  105480. */
  105481. export interface IGetSetVerticesData {
  105482. /**
  105483. * Gets a boolean indicating if specific vertex data is present
  105484. * @param kind defines the vertex data kind to use
  105485. * @returns true is data kind is present
  105486. */
  105487. isVerticesDataPresent(kind: string): boolean;
  105488. /**
  105489. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  105490. * @param kind defines the data kind (Position, normal, etc...)
  105491. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105492. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105493. * @returns a float array containing vertex data
  105494. */
  105495. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105496. /**
  105497. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105498. * @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.
  105499. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105500. * @returns the indices array or an empty array if the mesh has no geometry
  105501. */
  105502. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105503. /**
  105504. * Set specific vertex data
  105505. * @param kind defines the data kind (Position, normal, etc...)
  105506. * @param data defines the vertex data to use
  105507. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  105508. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  105509. */
  105510. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  105511. /**
  105512. * Update a specific associated vertex buffer
  105513. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105514. * - VertexBuffer.PositionKind
  105515. * - VertexBuffer.UVKind
  105516. * - VertexBuffer.UV2Kind
  105517. * - VertexBuffer.UV3Kind
  105518. * - VertexBuffer.UV4Kind
  105519. * - VertexBuffer.UV5Kind
  105520. * - VertexBuffer.UV6Kind
  105521. * - VertexBuffer.ColorKind
  105522. * - VertexBuffer.MatricesIndicesKind
  105523. * - VertexBuffer.MatricesIndicesExtraKind
  105524. * - VertexBuffer.MatricesWeightsKind
  105525. * - VertexBuffer.MatricesWeightsExtraKind
  105526. * @param data defines the data source
  105527. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105528. * @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)
  105529. */
  105530. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  105531. /**
  105532. * Creates a new index buffer
  105533. * @param indices defines the indices to store in the index buffer
  105534. * @param totalVertices defines the total number of vertices (could be null)
  105535. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  105536. */
  105537. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  105538. }
  105539. /**
  105540. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  105541. */
  105542. export class VertexData {
  105543. /**
  105544. * Mesh side orientation : usually the external or front surface
  105545. */
  105546. static readonly FRONTSIDE: number;
  105547. /**
  105548. * Mesh side orientation : usually the internal or back surface
  105549. */
  105550. static readonly BACKSIDE: number;
  105551. /**
  105552. * Mesh side orientation : both internal and external or front and back surfaces
  105553. */
  105554. static readonly DOUBLESIDE: number;
  105555. /**
  105556. * Mesh side orientation : by default, `FRONTSIDE`
  105557. */
  105558. static readonly DEFAULTSIDE: number;
  105559. /**
  105560. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  105561. */
  105562. positions: Nullable<FloatArray>;
  105563. /**
  105564. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  105565. */
  105566. normals: Nullable<FloatArray>;
  105567. /**
  105568. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  105569. */
  105570. tangents: Nullable<FloatArray>;
  105571. /**
  105572. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105573. */
  105574. uvs: Nullable<FloatArray>;
  105575. /**
  105576. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105577. */
  105578. uvs2: Nullable<FloatArray>;
  105579. /**
  105580. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105581. */
  105582. uvs3: Nullable<FloatArray>;
  105583. /**
  105584. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105585. */
  105586. uvs4: Nullable<FloatArray>;
  105587. /**
  105588. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105589. */
  105590. uvs5: Nullable<FloatArray>;
  105591. /**
  105592. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105593. */
  105594. uvs6: Nullable<FloatArray>;
  105595. /**
  105596. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  105597. */
  105598. colors: Nullable<FloatArray>;
  105599. /**
  105600. * 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).
  105601. */
  105602. matricesIndices: Nullable<FloatArray>;
  105603. /**
  105604. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  105605. */
  105606. matricesWeights: Nullable<FloatArray>;
  105607. /**
  105608. * An array extending the number of possible indices
  105609. */
  105610. matricesIndicesExtra: Nullable<FloatArray>;
  105611. /**
  105612. * An array extending the number of possible weights when the number of indices is extended
  105613. */
  105614. matricesWeightsExtra: Nullable<FloatArray>;
  105615. /**
  105616. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  105617. */
  105618. indices: Nullable<IndicesArray>;
  105619. /**
  105620. * Uses the passed data array to set the set the values for the specified kind of data
  105621. * @param data a linear array of floating numbers
  105622. * @param kind the type of data that is being set, eg positions, colors etc
  105623. */
  105624. set(data: FloatArray, kind: string): void;
  105625. /**
  105626. * Associates the vertexData to the passed Mesh.
  105627. * Sets it as updatable or not (default `false`)
  105628. * @param mesh the mesh the vertexData is applied to
  105629. * @param updatable when used and having the value true allows new data to update the vertexData
  105630. * @returns the VertexData
  105631. */
  105632. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  105633. /**
  105634. * Associates the vertexData to the passed Geometry.
  105635. * Sets it as updatable or not (default `false`)
  105636. * @param geometry the geometry the vertexData is applied to
  105637. * @param updatable when used and having the value true allows new data to update the vertexData
  105638. * @returns VertexData
  105639. */
  105640. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  105641. /**
  105642. * Updates the associated mesh
  105643. * @param mesh the mesh to be updated
  105644. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  105645. * @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
  105646. * @returns VertexData
  105647. */
  105648. updateMesh(mesh: Mesh): VertexData;
  105649. /**
  105650. * Updates the associated geometry
  105651. * @param geometry the geometry to be updated
  105652. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  105653. * @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
  105654. * @returns VertexData.
  105655. */
  105656. updateGeometry(geometry: Geometry): VertexData;
  105657. private _applyTo;
  105658. private _update;
  105659. /**
  105660. * Transforms each position and each normal of the vertexData according to the passed Matrix
  105661. * @param matrix the transforming matrix
  105662. * @returns the VertexData
  105663. */
  105664. transform(matrix: Matrix): VertexData;
  105665. /**
  105666. * Merges the passed VertexData into the current one
  105667. * @param other the VertexData to be merged into the current one
  105668. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  105669. * @returns the modified VertexData
  105670. */
  105671. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  105672. private _mergeElement;
  105673. private _validate;
  105674. /**
  105675. * Serializes the VertexData
  105676. * @returns a serialized object
  105677. */
  105678. serialize(): any;
  105679. /**
  105680. * Extracts the vertexData from a mesh
  105681. * @param mesh the mesh from which to extract the VertexData
  105682. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  105683. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  105684. * @returns the object VertexData associated to the passed mesh
  105685. */
  105686. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  105687. /**
  105688. * Extracts the vertexData from the geometry
  105689. * @param geometry the geometry from which to extract the VertexData
  105690. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  105691. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  105692. * @returns the object VertexData associated to the passed mesh
  105693. */
  105694. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  105695. private static _ExtractFrom;
  105696. /**
  105697. * Creates the VertexData for a Ribbon
  105698. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  105699. * * pathArray array of paths, each of which an array of successive Vector3
  105700. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  105701. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  105702. * * 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
  105703. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105704. * * 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)
  105705. * * 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)
  105706. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  105707. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  105708. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  105709. * @returns the VertexData of the ribbon
  105710. */
  105711. static CreateRibbon(options: {
  105712. pathArray: Vector3[][];
  105713. closeArray?: boolean;
  105714. closePath?: boolean;
  105715. offset?: number;
  105716. sideOrientation?: number;
  105717. frontUVs?: Vector4;
  105718. backUVs?: Vector4;
  105719. invertUV?: boolean;
  105720. uvs?: Vector2[];
  105721. colors?: Color4[];
  105722. }): VertexData;
  105723. /**
  105724. * Creates the VertexData for a box
  105725. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105726. * * size sets the width, height and depth of the box to the value of size, optional default 1
  105727. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  105728. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  105729. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  105730. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  105731. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  105732. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105733. * * 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)
  105734. * * 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)
  105735. * @returns the VertexData of the box
  105736. */
  105737. static CreateBox(options: {
  105738. size?: number;
  105739. width?: number;
  105740. height?: number;
  105741. depth?: number;
  105742. faceUV?: Vector4[];
  105743. faceColors?: Color4[];
  105744. sideOrientation?: number;
  105745. frontUVs?: Vector4;
  105746. backUVs?: Vector4;
  105747. }): VertexData;
  105748. /**
  105749. * Creates the VertexData for a tiled box
  105750. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105751. * * faceTiles sets the pattern, tile size and number of tiles for a face
  105752. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  105753. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  105754. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105755. * @returns the VertexData of the box
  105756. */
  105757. static CreateTiledBox(options: {
  105758. pattern?: number;
  105759. width?: number;
  105760. height?: number;
  105761. depth?: number;
  105762. tileSize?: number;
  105763. tileWidth?: number;
  105764. tileHeight?: number;
  105765. alignHorizontal?: number;
  105766. alignVertical?: number;
  105767. faceUV?: Vector4[];
  105768. faceColors?: Color4[];
  105769. sideOrientation?: number;
  105770. }): VertexData;
  105771. /**
  105772. * Creates the VertexData for a tiled plane
  105773. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105774. * * pattern a limited pattern arrangement depending on the number
  105775. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  105776. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  105777. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  105778. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105779. * * 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)
  105780. * * 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)
  105781. * @returns the VertexData of the tiled plane
  105782. */
  105783. static CreateTiledPlane(options: {
  105784. pattern?: number;
  105785. tileSize?: number;
  105786. tileWidth?: number;
  105787. tileHeight?: number;
  105788. size?: number;
  105789. width?: number;
  105790. height?: number;
  105791. alignHorizontal?: number;
  105792. alignVertical?: number;
  105793. sideOrientation?: number;
  105794. frontUVs?: Vector4;
  105795. backUVs?: Vector4;
  105796. }): VertexData;
  105797. /**
  105798. * Creates the VertexData for an ellipsoid, defaults to a sphere
  105799. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105800. * * segments sets the number of horizontal strips optional, default 32
  105801. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  105802. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  105803. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  105804. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  105805. * * 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
  105806. * * 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
  105807. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105808. * * 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)
  105809. * * 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)
  105810. * @returns the VertexData of the ellipsoid
  105811. */
  105812. static CreateSphere(options: {
  105813. segments?: number;
  105814. diameter?: number;
  105815. diameterX?: number;
  105816. diameterY?: number;
  105817. diameterZ?: number;
  105818. arc?: number;
  105819. slice?: number;
  105820. sideOrientation?: number;
  105821. frontUVs?: Vector4;
  105822. backUVs?: Vector4;
  105823. }): VertexData;
  105824. /**
  105825. * Creates the VertexData for a cylinder, cone or prism
  105826. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105827. * * height sets the height (y direction) of the cylinder, optional, default 2
  105828. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  105829. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  105830. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  105831. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  105832. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  105833. * * 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
  105834. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105835. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105836. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  105837. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  105838. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105839. * * 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)
  105840. * * 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)
  105841. * @returns the VertexData of the cylinder, cone or prism
  105842. */
  105843. static CreateCylinder(options: {
  105844. height?: number;
  105845. diameterTop?: number;
  105846. diameterBottom?: number;
  105847. diameter?: number;
  105848. tessellation?: number;
  105849. subdivisions?: number;
  105850. arc?: number;
  105851. faceColors?: Color4[];
  105852. faceUV?: Vector4[];
  105853. hasRings?: boolean;
  105854. enclose?: boolean;
  105855. sideOrientation?: number;
  105856. frontUVs?: Vector4;
  105857. backUVs?: Vector4;
  105858. }): VertexData;
  105859. /**
  105860. * Creates the VertexData for a torus
  105861. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105862. * * diameter the diameter of the torus, optional default 1
  105863. * * thickness the diameter of the tube forming the torus, optional default 0.5
  105864. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  105865. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105866. * * 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)
  105867. * * 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)
  105868. * @returns the VertexData of the torus
  105869. */
  105870. static CreateTorus(options: {
  105871. diameter?: number;
  105872. thickness?: number;
  105873. tessellation?: number;
  105874. sideOrientation?: number;
  105875. frontUVs?: Vector4;
  105876. backUVs?: Vector4;
  105877. }): VertexData;
  105878. /**
  105879. * Creates the VertexData of the LineSystem
  105880. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  105881. * - lines an array of lines, each line being an array of successive Vector3
  105882. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  105883. * @returns the VertexData of the LineSystem
  105884. */
  105885. static CreateLineSystem(options: {
  105886. lines: Vector3[][];
  105887. colors?: Nullable<Color4[][]>;
  105888. }): VertexData;
  105889. /**
  105890. * Create the VertexData for a DashedLines
  105891. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  105892. * - points an array successive Vector3
  105893. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  105894. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  105895. * - dashNb the intended total number of dashes, optional, default 200
  105896. * @returns the VertexData for the DashedLines
  105897. */
  105898. static CreateDashedLines(options: {
  105899. points: Vector3[];
  105900. dashSize?: number;
  105901. gapSize?: number;
  105902. dashNb?: number;
  105903. }): VertexData;
  105904. /**
  105905. * Creates the VertexData for a Ground
  105906. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  105907. * - width the width (x direction) of the ground, optional, default 1
  105908. * - height the height (z direction) of the ground, optional, default 1
  105909. * - subdivisions the number of subdivisions per side, optional, default 1
  105910. * @returns the VertexData of the Ground
  105911. */
  105912. static CreateGround(options: {
  105913. width?: number;
  105914. height?: number;
  105915. subdivisions?: number;
  105916. subdivisionsX?: number;
  105917. subdivisionsY?: number;
  105918. }): VertexData;
  105919. /**
  105920. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  105921. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  105922. * * xmin the ground minimum X coordinate, optional, default -1
  105923. * * zmin the ground minimum Z coordinate, optional, default -1
  105924. * * xmax the ground maximum X coordinate, optional, default 1
  105925. * * zmax the ground maximum Z coordinate, optional, default 1
  105926. * * 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}
  105927. * * 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}
  105928. * @returns the VertexData of the TiledGround
  105929. */
  105930. static CreateTiledGround(options: {
  105931. xmin: number;
  105932. zmin: number;
  105933. xmax: number;
  105934. zmax: number;
  105935. subdivisions?: {
  105936. w: number;
  105937. h: number;
  105938. };
  105939. precision?: {
  105940. w: number;
  105941. h: number;
  105942. };
  105943. }): VertexData;
  105944. /**
  105945. * Creates the VertexData of the Ground designed from a heightmap
  105946. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  105947. * * width the width (x direction) of the ground
  105948. * * height the height (z direction) of the ground
  105949. * * subdivisions the number of subdivisions per side
  105950. * * minHeight the minimum altitude on the ground, optional, default 0
  105951. * * maxHeight the maximum altitude on the ground, optional default 1
  105952. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  105953. * * buffer the array holding the image color data
  105954. * * bufferWidth the width of image
  105955. * * bufferHeight the height of image
  105956. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  105957. * @returns the VertexData of the Ground designed from a heightmap
  105958. */
  105959. static CreateGroundFromHeightMap(options: {
  105960. width: number;
  105961. height: number;
  105962. subdivisions: number;
  105963. minHeight: number;
  105964. maxHeight: number;
  105965. colorFilter: Color3;
  105966. buffer: Uint8Array;
  105967. bufferWidth: number;
  105968. bufferHeight: number;
  105969. alphaFilter: number;
  105970. }): VertexData;
  105971. /**
  105972. * Creates the VertexData for a Plane
  105973. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  105974. * * size sets the width and height of the plane to the value of size, optional default 1
  105975. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  105976. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  105977. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105978. * * 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)
  105979. * * 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)
  105980. * @returns the VertexData of the box
  105981. */
  105982. static CreatePlane(options: {
  105983. size?: number;
  105984. width?: number;
  105985. height?: number;
  105986. sideOrientation?: number;
  105987. frontUVs?: Vector4;
  105988. backUVs?: Vector4;
  105989. }): VertexData;
  105990. /**
  105991. * Creates the VertexData of the Disc or regular Polygon
  105992. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  105993. * * radius the radius of the disc, optional default 0.5
  105994. * * tessellation the number of polygon sides, optional, default 64
  105995. * * 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
  105996. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105997. * * 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)
  105998. * * 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)
  105999. * @returns the VertexData of the box
  106000. */
  106001. static CreateDisc(options: {
  106002. radius?: number;
  106003. tessellation?: number;
  106004. arc?: number;
  106005. sideOrientation?: number;
  106006. frontUVs?: Vector4;
  106007. backUVs?: Vector4;
  106008. }): VertexData;
  106009. /**
  106010. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  106011. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  106012. * @param polygon a mesh built from polygonTriangulation.build()
  106013. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106014. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106015. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106016. * @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)
  106017. * @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)
  106018. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  106019. * @returns the VertexData of the Polygon
  106020. */
  106021. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  106022. /**
  106023. * Creates the VertexData of the IcoSphere
  106024. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  106025. * * radius the radius of the IcoSphere, optional default 1
  106026. * * radiusX allows stretching in the x direction, optional, default radius
  106027. * * radiusY allows stretching in the y direction, optional, default radius
  106028. * * radiusZ allows stretching in the z direction, optional, default radius
  106029. * * flat when true creates a flat shaded mesh, optional, default true
  106030. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106031. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106032. * * 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)
  106033. * * 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)
  106034. * @returns the VertexData of the IcoSphere
  106035. */
  106036. static CreateIcoSphere(options: {
  106037. radius?: number;
  106038. radiusX?: number;
  106039. radiusY?: number;
  106040. radiusZ?: number;
  106041. flat?: boolean;
  106042. subdivisions?: number;
  106043. sideOrientation?: number;
  106044. frontUVs?: Vector4;
  106045. backUVs?: Vector4;
  106046. }): VertexData;
  106047. /**
  106048. * Creates the VertexData for a Polyhedron
  106049. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  106050. * * type provided types are:
  106051. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  106052. * * 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)
  106053. * * size the size of the IcoSphere, optional default 1
  106054. * * sizeX allows stretching in the x direction, optional, default size
  106055. * * sizeY allows stretching in the y direction, optional, default size
  106056. * * sizeZ allows stretching in the z direction, optional, default size
  106057. * * 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
  106058. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106059. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106060. * * flat when true creates a flat shaded mesh, optional, default true
  106061. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106062. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106063. * * 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)
  106064. * * 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)
  106065. * @returns the VertexData of the Polyhedron
  106066. */
  106067. static CreatePolyhedron(options: {
  106068. type?: number;
  106069. size?: number;
  106070. sizeX?: number;
  106071. sizeY?: number;
  106072. sizeZ?: number;
  106073. custom?: any;
  106074. faceUV?: Vector4[];
  106075. faceColors?: Color4[];
  106076. flat?: boolean;
  106077. sideOrientation?: number;
  106078. frontUVs?: Vector4;
  106079. backUVs?: Vector4;
  106080. }): VertexData;
  106081. /**
  106082. * Creates the VertexData for a TorusKnot
  106083. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  106084. * * radius the radius of the torus knot, optional, default 2
  106085. * * tube the thickness of the tube, optional, default 0.5
  106086. * * radialSegments the number of sides on each tube segments, optional, default 32
  106087. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  106088. * * p the number of windings around the z axis, optional, default 2
  106089. * * q the number of windings around the x axis, optional, default 3
  106090. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106091. * * 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)
  106092. * * 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)
  106093. * @returns the VertexData of the Torus Knot
  106094. */
  106095. static CreateTorusKnot(options: {
  106096. radius?: number;
  106097. tube?: number;
  106098. radialSegments?: number;
  106099. tubularSegments?: number;
  106100. p?: number;
  106101. q?: number;
  106102. sideOrientation?: number;
  106103. frontUVs?: Vector4;
  106104. backUVs?: Vector4;
  106105. }): VertexData;
  106106. /**
  106107. * Compute normals for given positions and indices
  106108. * @param positions an array of vertex positions, [...., x, y, z, ......]
  106109. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  106110. * @param normals an array of vertex normals, [...., x, y, z, ......]
  106111. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  106112. * * facetNormals : optional array of facet normals (vector3)
  106113. * * facetPositions : optional array of facet positions (vector3)
  106114. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  106115. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  106116. * * bInfo : optional bounding info, required for facetPartitioning computation
  106117. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  106118. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  106119. * * useRightHandedSystem: optional boolean to for right handed system computation
  106120. * * depthSort : optional boolean to enable the facet depth sort computation
  106121. * * distanceTo : optional Vector3 to compute the facet depth from this location
  106122. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  106123. */
  106124. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  106125. facetNormals?: any;
  106126. facetPositions?: any;
  106127. facetPartitioning?: any;
  106128. ratio?: number;
  106129. bInfo?: any;
  106130. bbSize?: Vector3;
  106131. subDiv?: any;
  106132. useRightHandedSystem?: boolean;
  106133. depthSort?: boolean;
  106134. distanceTo?: Vector3;
  106135. depthSortedFacets?: any;
  106136. }): void;
  106137. /** @hidden */
  106138. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  106139. /**
  106140. * Applies VertexData created from the imported parameters to the geometry
  106141. * @param parsedVertexData the parsed data from an imported file
  106142. * @param geometry the geometry to apply the VertexData to
  106143. */
  106144. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  106145. }
  106146. }
  106147. declare module BABYLON {
  106148. /**
  106149. * Defines a target to use with MorphTargetManager
  106150. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106151. */
  106152. export class MorphTarget implements IAnimatable {
  106153. /** defines the name of the target */
  106154. name: string;
  106155. /**
  106156. * Gets or sets the list of animations
  106157. */
  106158. animations: Animation[];
  106159. private _scene;
  106160. private _positions;
  106161. private _normals;
  106162. private _tangents;
  106163. private _uvs;
  106164. private _influence;
  106165. private _uniqueId;
  106166. /**
  106167. * Observable raised when the influence changes
  106168. */
  106169. onInfluenceChanged: Observable<boolean>;
  106170. /** @hidden */
  106171. _onDataLayoutChanged: Observable<void>;
  106172. /**
  106173. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  106174. */
  106175. get influence(): number;
  106176. set influence(influence: number);
  106177. /**
  106178. * Gets or sets the id of the morph Target
  106179. */
  106180. id: string;
  106181. private _animationPropertiesOverride;
  106182. /**
  106183. * Gets or sets the animation properties override
  106184. */
  106185. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106186. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106187. /**
  106188. * Creates a new MorphTarget
  106189. * @param name defines the name of the target
  106190. * @param influence defines the influence to use
  106191. * @param scene defines the scene the morphtarget belongs to
  106192. */
  106193. constructor(
  106194. /** defines the name of the target */
  106195. name: string, influence?: number, scene?: Nullable<Scene>);
  106196. /**
  106197. * Gets the unique ID of this manager
  106198. */
  106199. get uniqueId(): number;
  106200. /**
  106201. * Gets a boolean defining if the target contains position data
  106202. */
  106203. get hasPositions(): boolean;
  106204. /**
  106205. * Gets a boolean defining if the target contains normal data
  106206. */
  106207. get hasNormals(): boolean;
  106208. /**
  106209. * Gets a boolean defining if the target contains tangent data
  106210. */
  106211. get hasTangents(): boolean;
  106212. /**
  106213. * Gets a boolean defining if the target contains texture coordinates data
  106214. */
  106215. get hasUVs(): boolean;
  106216. /**
  106217. * Affects position data to this target
  106218. * @param data defines the position data to use
  106219. */
  106220. setPositions(data: Nullable<FloatArray>): void;
  106221. /**
  106222. * Gets the position data stored in this target
  106223. * @returns a FloatArray containing the position data (or null if not present)
  106224. */
  106225. getPositions(): Nullable<FloatArray>;
  106226. /**
  106227. * Affects normal data to this target
  106228. * @param data defines the normal data to use
  106229. */
  106230. setNormals(data: Nullable<FloatArray>): void;
  106231. /**
  106232. * Gets the normal data stored in this target
  106233. * @returns a FloatArray containing the normal data (or null if not present)
  106234. */
  106235. getNormals(): Nullable<FloatArray>;
  106236. /**
  106237. * Affects tangent data to this target
  106238. * @param data defines the tangent data to use
  106239. */
  106240. setTangents(data: Nullable<FloatArray>): void;
  106241. /**
  106242. * Gets the tangent data stored in this target
  106243. * @returns a FloatArray containing the tangent data (or null if not present)
  106244. */
  106245. getTangents(): Nullable<FloatArray>;
  106246. /**
  106247. * Affects texture coordinates data to this target
  106248. * @param data defines the texture coordinates data to use
  106249. */
  106250. setUVs(data: Nullable<FloatArray>): void;
  106251. /**
  106252. * Gets the texture coordinates data stored in this target
  106253. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  106254. */
  106255. getUVs(): Nullable<FloatArray>;
  106256. /**
  106257. * Clone the current target
  106258. * @returns a new MorphTarget
  106259. */
  106260. clone(): MorphTarget;
  106261. /**
  106262. * Serializes the current target into a Serialization object
  106263. * @returns the serialized object
  106264. */
  106265. serialize(): any;
  106266. /**
  106267. * Returns the string "MorphTarget"
  106268. * @returns "MorphTarget"
  106269. */
  106270. getClassName(): string;
  106271. /**
  106272. * Creates a new target from serialized data
  106273. * @param serializationObject defines the serialized data to use
  106274. * @returns a new MorphTarget
  106275. */
  106276. static Parse(serializationObject: any): MorphTarget;
  106277. /**
  106278. * Creates a MorphTarget from mesh data
  106279. * @param mesh defines the source mesh
  106280. * @param name defines the name to use for the new target
  106281. * @param influence defines the influence to attach to the target
  106282. * @returns a new MorphTarget
  106283. */
  106284. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  106285. }
  106286. }
  106287. declare module BABYLON {
  106288. /**
  106289. * This class is used to deform meshes using morphing between different targets
  106290. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106291. */
  106292. export class MorphTargetManager {
  106293. private _targets;
  106294. private _targetInfluenceChangedObservers;
  106295. private _targetDataLayoutChangedObservers;
  106296. private _activeTargets;
  106297. private _scene;
  106298. private _influences;
  106299. private _supportsNormals;
  106300. private _supportsTangents;
  106301. private _supportsUVs;
  106302. private _vertexCount;
  106303. private _uniqueId;
  106304. private _tempInfluences;
  106305. /**
  106306. * Gets or sets a boolean indicating if normals must be morphed
  106307. */
  106308. enableNormalMorphing: boolean;
  106309. /**
  106310. * Gets or sets a boolean indicating if tangents must be morphed
  106311. */
  106312. enableTangentMorphing: boolean;
  106313. /**
  106314. * Gets or sets a boolean indicating if UV must be morphed
  106315. */
  106316. enableUVMorphing: boolean;
  106317. /**
  106318. * Creates a new MorphTargetManager
  106319. * @param scene defines the current scene
  106320. */
  106321. constructor(scene?: Nullable<Scene>);
  106322. /**
  106323. * Gets the unique ID of this manager
  106324. */
  106325. get uniqueId(): number;
  106326. /**
  106327. * Gets the number of vertices handled by this manager
  106328. */
  106329. get vertexCount(): number;
  106330. /**
  106331. * Gets a boolean indicating if this manager supports morphing of normals
  106332. */
  106333. get supportsNormals(): boolean;
  106334. /**
  106335. * Gets a boolean indicating if this manager supports morphing of tangents
  106336. */
  106337. get supportsTangents(): boolean;
  106338. /**
  106339. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  106340. */
  106341. get supportsUVs(): boolean;
  106342. /**
  106343. * Gets the number of targets stored in this manager
  106344. */
  106345. get numTargets(): number;
  106346. /**
  106347. * Gets the number of influencers (ie. the number of targets with influences > 0)
  106348. */
  106349. get numInfluencers(): number;
  106350. /**
  106351. * Gets the list of influences (one per target)
  106352. */
  106353. get influences(): Float32Array;
  106354. /**
  106355. * Gets the active target at specified index. An active target is a target with an influence > 0
  106356. * @param index defines the index to check
  106357. * @returns the requested target
  106358. */
  106359. getActiveTarget(index: number): MorphTarget;
  106360. /**
  106361. * Gets the target at specified index
  106362. * @param index defines the index to check
  106363. * @returns the requested target
  106364. */
  106365. getTarget(index: number): MorphTarget;
  106366. /**
  106367. * Add a new target to this manager
  106368. * @param target defines the target to add
  106369. */
  106370. addTarget(target: MorphTarget): void;
  106371. /**
  106372. * Removes a target from the manager
  106373. * @param target defines the target to remove
  106374. */
  106375. removeTarget(target: MorphTarget): void;
  106376. /**
  106377. * Clone the current manager
  106378. * @returns a new MorphTargetManager
  106379. */
  106380. clone(): MorphTargetManager;
  106381. /**
  106382. * Serializes the current manager into a Serialization object
  106383. * @returns the serialized object
  106384. */
  106385. serialize(): any;
  106386. private _syncActiveTargets;
  106387. /**
  106388. * Syncrhonize the targets with all the meshes using this morph target manager
  106389. */
  106390. synchronize(): void;
  106391. /**
  106392. * Creates a new MorphTargetManager from serialized data
  106393. * @param serializationObject defines the serialized data
  106394. * @param scene defines the hosting scene
  106395. * @returns the new MorphTargetManager
  106396. */
  106397. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  106398. }
  106399. }
  106400. declare module BABYLON {
  106401. /**
  106402. * Class used to represent a specific level of detail of a mesh
  106403. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106404. */
  106405. export class MeshLODLevel {
  106406. /** Defines the distance where this level should start being displayed */
  106407. distance: number;
  106408. /** Defines the mesh to use to render this level */
  106409. mesh: Nullable<Mesh>;
  106410. /**
  106411. * Creates a new LOD level
  106412. * @param distance defines the distance where this level should star being displayed
  106413. * @param mesh defines the mesh to use to render this level
  106414. */
  106415. constructor(
  106416. /** Defines the distance where this level should start being displayed */
  106417. distance: number,
  106418. /** Defines the mesh to use to render this level */
  106419. mesh: Nullable<Mesh>);
  106420. }
  106421. }
  106422. declare module BABYLON {
  106423. /**
  106424. * Helper class used to generate a canvas to manipulate images
  106425. */
  106426. export class CanvasGenerator {
  106427. /**
  106428. * Create a new canvas (or offscreen canvas depending on the context)
  106429. * @param width defines the expected width
  106430. * @param height defines the expected height
  106431. * @return a new canvas or offscreen canvas
  106432. */
  106433. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  106434. }
  106435. }
  106436. declare module BABYLON {
  106437. /**
  106438. * Mesh representing the gorund
  106439. */
  106440. export class GroundMesh extends Mesh {
  106441. /** If octree should be generated */
  106442. generateOctree: boolean;
  106443. private _heightQuads;
  106444. /** @hidden */
  106445. _subdivisionsX: number;
  106446. /** @hidden */
  106447. _subdivisionsY: number;
  106448. /** @hidden */
  106449. _width: number;
  106450. /** @hidden */
  106451. _height: number;
  106452. /** @hidden */
  106453. _minX: number;
  106454. /** @hidden */
  106455. _maxX: number;
  106456. /** @hidden */
  106457. _minZ: number;
  106458. /** @hidden */
  106459. _maxZ: number;
  106460. constructor(name: string, scene: Scene);
  106461. /**
  106462. * "GroundMesh"
  106463. * @returns "GroundMesh"
  106464. */
  106465. getClassName(): string;
  106466. /**
  106467. * The minimum of x and y subdivisions
  106468. */
  106469. get subdivisions(): number;
  106470. /**
  106471. * X subdivisions
  106472. */
  106473. get subdivisionsX(): number;
  106474. /**
  106475. * Y subdivisions
  106476. */
  106477. get subdivisionsY(): number;
  106478. /**
  106479. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  106480. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  106481. * @param chunksCount the number of subdivisions for x and y
  106482. * @param octreeBlocksSize (Default: 32)
  106483. */
  106484. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  106485. /**
  106486. * Returns a height (y) value in the Worl system :
  106487. * the ground altitude at the coordinates (x, z) expressed in the World system.
  106488. * @param x x coordinate
  106489. * @param z z coordinate
  106490. * @returns the ground y position if (x, z) are outside the ground surface.
  106491. */
  106492. getHeightAtCoordinates(x: number, z: number): number;
  106493. /**
  106494. * Returns a normalized vector (Vector3) orthogonal to the ground
  106495. * at the ground coordinates (x, z) expressed in the World system.
  106496. * @param x x coordinate
  106497. * @param z z coordinate
  106498. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  106499. */
  106500. getNormalAtCoordinates(x: number, z: number): Vector3;
  106501. /**
  106502. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  106503. * at the ground coordinates (x, z) expressed in the World system.
  106504. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  106505. * @param x x coordinate
  106506. * @param z z coordinate
  106507. * @param ref vector to store the result
  106508. * @returns the GroundMesh.
  106509. */
  106510. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  106511. /**
  106512. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  106513. * if the ground has been updated.
  106514. * This can be used in the render loop.
  106515. * @returns the GroundMesh.
  106516. */
  106517. updateCoordinateHeights(): GroundMesh;
  106518. private _getFacetAt;
  106519. private _initHeightQuads;
  106520. private _computeHeightQuads;
  106521. /**
  106522. * Serializes this ground mesh
  106523. * @param serializationObject object to write serialization to
  106524. */
  106525. serialize(serializationObject: any): void;
  106526. /**
  106527. * Parses a serialized ground mesh
  106528. * @param parsedMesh the serialized mesh
  106529. * @param scene the scene to create the ground mesh in
  106530. * @returns the created ground mesh
  106531. */
  106532. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  106533. }
  106534. }
  106535. declare module BABYLON {
  106536. /**
  106537. * Interface for Physics-Joint data
  106538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106539. */
  106540. export interface PhysicsJointData {
  106541. /**
  106542. * The main pivot of the joint
  106543. */
  106544. mainPivot?: Vector3;
  106545. /**
  106546. * The connected pivot of the joint
  106547. */
  106548. connectedPivot?: Vector3;
  106549. /**
  106550. * The main axis of the joint
  106551. */
  106552. mainAxis?: Vector3;
  106553. /**
  106554. * The connected axis of the joint
  106555. */
  106556. connectedAxis?: Vector3;
  106557. /**
  106558. * The collision of the joint
  106559. */
  106560. collision?: boolean;
  106561. /**
  106562. * Native Oimo/Cannon/Energy data
  106563. */
  106564. nativeParams?: any;
  106565. }
  106566. /**
  106567. * This is a holder class for the physics joint created by the physics plugin
  106568. * It holds a set of functions to control the underlying joint
  106569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106570. */
  106571. export class PhysicsJoint {
  106572. /**
  106573. * The type of the physics joint
  106574. */
  106575. type: number;
  106576. /**
  106577. * The data for the physics joint
  106578. */
  106579. jointData: PhysicsJointData;
  106580. private _physicsJoint;
  106581. protected _physicsPlugin: IPhysicsEnginePlugin;
  106582. /**
  106583. * Initializes the physics joint
  106584. * @param type The type of the physics joint
  106585. * @param jointData The data for the physics joint
  106586. */
  106587. constructor(
  106588. /**
  106589. * The type of the physics joint
  106590. */
  106591. type: number,
  106592. /**
  106593. * The data for the physics joint
  106594. */
  106595. jointData: PhysicsJointData);
  106596. /**
  106597. * Gets the physics joint
  106598. */
  106599. get physicsJoint(): any;
  106600. /**
  106601. * Sets the physics joint
  106602. */
  106603. set physicsJoint(newJoint: any);
  106604. /**
  106605. * Sets the physics plugin
  106606. */
  106607. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  106608. /**
  106609. * Execute a function that is physics-plugin specific.
  106610. * @param {Function} func the function that will be executed.
  106611. * It accepts two parameters: the physics world and the physics joint
  106612. */
  106613. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  106614. /**
  106615. * Distance-Joint type
  106616. */
  106617. static DistanceJoint: number;
  106618. /**
  106619. * Hinge-Joint type
  106620. */
  106621. static HingeJoint: number;
  106622. /**
  106623. * Ball-and-Socket joint type
  106624. */
  106625. static BallAndSocketJoint: number;
  106626. /**
  106627. * Wheel-Joint type
  106628. */
  106629. static WheelJoint: number;
  106630. /**
  106631. * Slider-Joint type
  106632. */
  106633. static SliderJoint: number;
  106634. /**
  106635. * Prismatic-Joint type
  106636. */
  106637. static PrismaticJoint: number;
  106638. /**
  106639. * Universal-Joint type
  106640. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  106641. */
  106642. static UniversalJoint: number;
  106643. /**
  106644. * Hinge-Joint 2 type
  106645. */
  106646. static Hinge2Joint: number;
  106647. /**
  106648. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  106649. */
  106650. static PointToPointJoint: number;
  106651. /**
  106652. * Spring-Joint type
  106653. */
  106654. static SpringJoint: number;
  106655. /**
  106656. * Lock-Joint type
  106657. */
  106658. static LockJoint: number;
  106659. }
  106660. /**
  106661. * A class representing a physics distance joint
  106662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106663. */
  106664. export class DistanceJoint extends PhysicsJoint {
  106665. /**
  106666. *
  106667. * @param jointData The data for the Distance-Joint
  106668. */
  106669. constructor(jointData: DistanceJointData);
  106670. /**
  106671. * Update the predefined distance.
  106672. * @param maxDistance The maximum preferred distance
  106673. * @param minDistance The minimum preferred distance
  106674. */
  106675. updateDistance(maxDistance: number, minDistance?: number): void;
  106676. }
  106677. /**
  106678. * Represents a Motor-Enabled Joint
  106679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106680. */
  106681. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  106682. /**
  106683. * Initializes the Motor-Enabled Joint
  106684. * @param type The type of the joint
  106685. * @param jointData The physica joint data for the joint
  106686. */
  106687. constructor(type: number, jointData: PhysicsJointData);
  106688. /**
  106689. * Set the motor values.
  106690. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106691. * @param force the force to apply
  106692. * @param maxForce max force for this motor.
  106693. */
  106694. setMotor(force?: number, maxForce?: number): void;
  106695. /**
  106696. * Set the motor's limits.
  106697. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106698. * @param upperLimit The upper limit of the motor
  106699. * @param lowerLimit The lower limit of the motor
  106700. */
  106701. setLimit(upperLimit: number, lowerLimit?: number): void;
  106702. }
  106703. /**
  106704. * This class represents a single physics Hinge-Joint
  106705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106706. */
  106707. export class HingeJoint extends MotorEnabledJoint {
  106708. /**
  106709. * Initializes the Hinge-Joint
  106710. * @param jointData The joint data for the Hinge-Joint
  106711. */
  106712. constructor(jointData: PhysicsJointData);
  106713. /**
  106714. * Set the motor values.
  106715. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106716. * @param {number} force the force to apply
  106717. * @param {number} maxForce max force for this motor.
  106718. */
  106719. setMotor(force?: number, maxForce?: number): void;
  106720. /**
  106721. * Set the motor's limits.
  106722. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106723. * @param upperLimit The upper limit of the motor
  106724. * @param lowerLimit The lower limit of the motor
  106725. */
  106726. setLimit(upperLimit: number, lowerLimit?: number): void;
  106727. }
  106728. /**
  106729. * This class represents a dual hinge physics joint (same as wheel joint)
  106730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106731. */
  106732. export class Hinge2Joint extends MotorEnabledJoint {
  106733. /**
  106734. * Initializes the Hinge2-Joint
  106735. * @param jointData The joint data for the Hinge2-Joint
  106736. */
  106737. constructor(jointData: PhysicsJointData);
  106738. /**
  106739. * Set the motor values.
  106740. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106741. * @param {number} targetSpeed the speed the motor is to reach
  106742. * @param {number} maxForce max force for this motor.
  106743. * @param {motorIndex} the motor's index, 0 or 1.
  106744. */
  106745. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  106746. /**
  106747. * Set the motor limits.
  106748. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106749. * @param {number} upperLimit the upper limit
  106750. * @param {number} lowerLimit lower limit
  106751. * @param {motorIndex} the motor's index, 0 or 1.
  106752. */
  106753. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106754. }
  106755. /**
  106756. * Interface for a motor enabled joint
  106757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106758. */
  106759. export interface IMotorEnabledJoint {
  106760. /**
  106761. * Physics joint
  106762. */
  106763. physicsJoint: any;
  106764. /**
  106765. * Sets the motor of the motor-enabled joint
  106766. * @param force The force of the motor
  106767. * @param maxForce The maximum force of the motor
  106768. * @param motorIndex The index of the motor
  106769. */
  106770. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  106771. /**
  106772. * Sets the limit of the motor
  106773. * @param upperLimit The upper limit of the motor
  106774. * @param lowerLimit The lower limit of the motor
  106775. * @param motorIndex The index of the motor
  106776. */
  106777. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106778. }
  106779. /**
  106780. * Joint data for a Distance-Joint
  106781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106782. */
  106783. export interface DistanceJointData extends PhysicsJointData {
  106784. /**
  106785. * Max distance the 2 joint objects can be apart
  106786. */
  106787. maxDistance: number;
  106788. }
  106789. /**
  106790. * Joint data from a spring joint
  106791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106792. */
  106793. export interface SpringJointData extends PhysicsJointData {
  106794. /**
  106795. * Length of the spring
  106796. */
  106797. length: number;
  106798. /**
  106799. * Stiffness of the spring
  106800. */
  106801. stiffness: number;
  106802. /**
  106803. * Damping of the spring
  106804. */
  106805. damping: number;
  106806. /** this callback will be called when applying the force to the impostors. */
  106807. forceApplicationCallback: () => void;
  106808. }
  106809. }
  106810. declare module BABYLON {
  106811. /**
  106812. * Holds the data for the raycast result
  106813. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106814. */
  106815. export class PhysicsRaycastResult {
  106816. private _hasHit;
  106817. private _hitDistance;
  106818. private _hitNormalWorld;
  106819. private _hitPointWorld;
  106820. private _rayFromWorld;
  106821. private _rayToWorld;
  106822. /**
  106823. * Gets if there was a hit
  106824. */
  106825. get hasHit(): boolean;
  106826. /**
  106827. * Gets the distance from the hit
  106828. */
  106829. get hitDistance(): number;
  106830. /**
  106831. * Gets the hit normal/direction in the world
  106832. */
  106833. get hitNormalWorld(): Vector3;
  106834. /**
  106835. * Gets the hit point in the world
  106836. */
  106837. get hitPointWorld(): Vector3;
  106838. /**
  106839. * Gets the ray "start point" of the ray in the world
  106840. */
  106841. get rayFromWorld(): Vector3;
  106842. /**
  106843. * Gets the ray "end point" of the ray in the world
  106844. */
  106845. get rayToWorld(): Vector3;
  106846. /**
  106847. * Sets the hit data (normal & point in world space)
  106848. * @param hitNormalWorld defines the normal in world space
  106849. * @param hitPointWorld defines the point in world space
  106850. */
  106851. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  106852. /**
  106853. * Sets the distance from the start point to the hit point
  106854. * @param distance
  106855. */
  106856. setHitDistance(distance: number): void;
  106857. /**
  106858. * Calculates the distance manually
  106859. */
  106860. calculateHitDistance(): void;
  106861. /**
  106862. * Resets all the values to default
  106863. * @param from The from point on world space
  106864. * @param to The to point on world space
  106865. */
  106866. reset(from?: Vector3, to?: Vector3): void;
  106867. }
  106868. /**
  106869. * Interface for the size containing width and height
  106870. */
  106871. interface IXYZ {
  106872. /**
  106873. * X
  106874. */
  106875. x: number;
  106876. /**
  106877. * Y
  106878. */
  106879. y: number;
  106880. /**
  106881. * Z
  106882. */
  106883. z: number;
  106884. }
  106885. }
  106886. declare module BABYLON {
  106887. /**
  106888. * Interface used to describe a physics joint
  106889. */
  106890. export interface PhysicsImpostorJoint {
  106891. /** Defines the main impostor to which the joint is linked */
  106892. mainImpostor: PhysicsImpostor;
  106893. /** Defines the impostor that is connected to the main impostor using this joint */
  106894. connectedImpostor: PhysicsImpostor;
  106895. /** Defines the joint itself */
  106896. joint: PhysicsJoint;
  106897. }
  106898. /** @hidden */
  106899. export interface IPhysicsEnginePlugin {
  106900. world: any;
  106901. name: string;
  106902. setGravity(gravity: Vector3): void;
  106903. setTimeStep(timeStep: number): void;
  106904. getTimeStep(): number;
  106905. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  106906. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106907. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106908. generatePhysicsBody(impostor: PhysicsImpostor): void;
  106909. removePhysicsBody(impostor: PhysicsImpostor): void;
  106910. generateJoint(joint: PhysicsImpostorJoint): void;
  106911. removeJoint(joint: PhysicsImpostorJoint): void;
  106912. isSupported(): boolean;
  106913. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106914. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106915. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  106916. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  106917. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106918. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106919. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106920. getBodyMass(impostor: PhysicsImpostor): number;
  106921. getBodyFriction(impostor: PhysicsImpostor): number;
  106922. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106923. getBodyRestitution(impostor: PhysicsImpostor): number;
  106924. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106925. getBodyPressure?(impostor: PhysicsImpostor): number;
  106926. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  106927. getBodyStiffness?(impostor: PhysicsImpostor): number;
  106928. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  106929. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  106930. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  106931. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  106932. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  106933. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  106934. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  106935. sleepBody(impostor: PhysicsImpostor): void;
  106936. wakeUpBody(impostor: PhysicsImpostor): void;
  106937. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106938. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  106939. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  106940. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106941. getRadius(impostor: PhysicsImpostor): number;
  106942. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106943. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106944. dispose(): void;
  106945. }
  106946. /**
  106947. * Interface used to define a physics engine
  106948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106949. */
  106950. export interface IPhysicsEngine {
  106951. /**
  106952. * Gets the gravity vector used by the simulation
  106953. */
  106954. gravity: Vector3;
  106955. /**
  106956. * Sets the gravity vector used by the simulation
  106957. * @param gravity defines the gravity vector to use
  106958. */
  106959. setGravity(gravity: Vector3): void;
  106960. /**
  106961. * Set the time step of the physics engine.
  106962. * Default is 1/60.
  106963. * To slow it down, enter 1/600 for example.
  106964. * To speed it up, 1/30
  106965. * @param newTimeStep the new timestep to apply to this world.
  106966. */
  106967. setTimeStep(newTimeStep: number): void;
  106968. /**
  106969. * Get the time step of the physics engine.
  106970. * @returns the current time step
  106971. */
  106972. getTimeStep(): number;
  106973. /**
  106974. * Set the sub time step of the physics engine.
  106975. * Default is 0 meaning there is no sub steps
  106976. * To increase physics resolution precision, set a small value (like 1 ms)
  106977. * @param subTimeStep defines the new sub timestep used for physics resolution.
  106978. */
  106979. setSubTimeStep(subTimeStep: number): void;
  106980. /**
  106981. * Get the sub time step of the physics engine.
  106982. * @returns the current sub time step
  106983. */
  106984. getSubTimeStep(): number;
  106985. /**
  106986. * Release all resources
  106987. */
  106988. dispose(): void;
  106989. /**
  106990. * Gets the name of the current physics plugin
  106991. * @returns the name of the plugin
  106992. */
  106993. getPhysicsPluginName(): string;
  106994. /**
  106995. * Adding a new impostor for the impostor tracking.
  106996. * This will be done by the impostor itself.
  106997. * @param impostor the impostor to add
  106998. */
  106999. addImpostor(impostor: PhysicsImpostor): void;
  107000. /**
  107001. * Remove an impostor from the engine.
  107002. * This impostor and its mesh will not longer be updated by the physics engine.
  107003. * @param impostor the impostor to remove
  107004. */
  107005. removeImpostor(impostor: PhysicsImpostor): void;
  107006. /**
  107007. * Add a joint to the physics engine
  107008. * @param mainImpostor defines the main impostor to which the joint is added.
  107009. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107010. * @param joint defines the joint that will connect both impostors.
  107011. */
  107012. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107013. /**
  107014. * Removes a joint from the simulation
  107015. * @param mainImpostor defines the impostor used with the joint
  107016. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107017. * @param joint defines the joint to remove
  107018. */
  107019. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107020. /**
  107021. * Gets the current plugin used to run the simulation
  107022. * @returns current plugin
  107023. */
  107024. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107025. /**
  107026. * Gets the list of physic impostors
  107027. * @returns an array of PhysicsImpostor
  107028. */
  107029. getImpostors(): Array<PhysicsImpostor>;
  107030. /**
  107031. * Gets the impostor for a physics enabled object
  107032. * @param object defines the object impersonated by the impostor
  107033. * @returns the PhysicsImpostor or null if not found
  107034. */
  107035. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107036. /**
  107037. * Gets the impostor for a physics body object
  107038. * @param body defines physics body used by the impostor
  107039. * @returns the PhysicsImpostor or null if not found
  107040. */
  107041. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107042. /**
  107043. * Does a raycast in the physics world
  107044. * @param from when should the ray start?
  107045. * @param to when should the ray end?
  107046. * @returns PhysicsRaycastResult
  107047. */
  107048. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107049. /**
  107050. * Called by the scene. No need to call it.
  107051. * @param delta defines the timespam between frames
  107052. */
  107053. _step(delta: number): void;
  107054. }
  107055. }
  107056. declare module BABYLON {
  107057. /**
  107058. * The interface for the physics imposter parameters
  107059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107060. */
  107061. export interface PhysicsImpostorParameters {
  107062. /**
  107063. * The mass of the physics imposter
  107064. */
  107065. mass: number;
  107066. /**
  107067. * The friction of the physics imposter
  107068. */
  107069. friction?: number;
  107070. /**
  107071. * The coefficient of restitution of the physics imposter
  107072. */
  107073. restitution?: number;
  107074. /**
  107075. * The native options of the physics imposter
  107076. */
  107077. nativeOptions?: any;
  107078. /**
  107079. * Specifies if the parent should be ignored
  107080. */
  107081. ignoreParent?: boolean;
  107082. /**
  107083. * Specifies if bi-directional transformations should be disabled
  107084. */
  107085. disableBidirectionalTransformation?: boolean;
  107086. /**
  107087. * The pressure inside the physics imposter, soft object only
  107088. */
  107089. pressure?: number;
  107090. /**
  107091. * The stiffness the physics imposter, soft object only
  107092. */
  107093. stiffness?: number;
  107094. /**
  107095. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  107096. */
  107097. velocityIterations?: number;
  107098. /**
  107099. * The number of iterations used in maintaining consistent vertex positions, soft object only
  107100. */
  107101. positionIterations?: number;
  107102. /**
  107103. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  107104. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  107105. * Add to fix multiple points
  107106. */
  107107. fixedPoints?: number;
  107108. /**
  107109. * The collision margin around a soft object
  107110. */
  107111. margin?: number;
  107112. /**
  107113. * The collision margin around a soft object
  107114. */
  107115. damping?: number;
  107116. /**
  107117. * The path for a rope based on an extrusion
  107118. */
  107119. path?: any;
  107120. /**
  107121. * The shape of an extrusion used for a rope based on an extrusion
  107122. */
  107123. shape?: any;
  107124. }
  107125. /**
  107126. * Interface for a physics-enabled object
  107127. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107128. */
  107129. export interface IPhysicsEnabledObject {
  107130. /**
  107131. * The position of the physics-enabled object
  107132. */
  107133. position: Vector3;
  107134. /**
  107135. * The rotation of the physics-enabled object
  107136. */
  107137. rotationQuaternion: Nullable<Quaternion>;
  107138. /**
  107139. * The scale of the physics-enabled object
  107140. */
  107141. scaling: Vector3;
  107142. /**
  107143. * The rotation of the physics-enabled object
  107144. */
  107145. rotation?: Vector3;
  107146. /**
  107147. * The parent of the physics-enabled object
  107148. */
  107149. parent?: any;
  107150. /**
  107151. * The bounding info of the physics-enabled object
  107152. * @returns The bounding info of the physics-enabled object
  107153. */
  107154. getBoundingInfo(): BoundingInfo;
  107155. /**
  107156. * Computes the world matrix
  107157. * @param force Specifies if the world matrix should be computed by force
  107158. * @returns A world matrix
  107159. */
  107160. computeWorldMatrix(force: boolean): Matrix;
  107161. /**
  107162. * Gets the world matrix
  107163. * @returns A world matrix
  107164. */
  107165. getWorldMatrix?(): Matrix;
  107166. /**
  107167. * Gets the child meshes
  107168. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  107169. * @returns An array of abstract meshes
  107170. */
  107171. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  107172. /**
  107173. * Gets the vertex data
  107174. * @param kind The type of vertex data
  107175. * @returns A nullable array of numbers, or a float32 array
  107176. */
  107177. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  107178. /**
  107179. * Gets the indices from the mesh
  107180. * @returns A nullable array of index arrays
  107181. */
  107182. getIndices?(): Nullable<IndicesArray>;
  107183. /**
  107184. * Gets the scene from the mesh
  107185. * @returns the indices array or null
  107186. */
  107187. getScene?(): Scene;
  107188. /**
  107189. * Gets the absolute position from the mesh
  107190. * @returns the absolute position
  107191. */
  107192. getAbsolutePosition(): Vector3;
  107193. /**
  107194. * Gets the absolute pivot point from the mesh
  107195. * @returns the absolute pivot point
  107196. */
  107197. getAbsolutePivotPoint(): Vector3;
  107198. /**
  107199. * Rotates the mesh
  107200. * @param axis The axis of rotation
  107201. * @param amount The amount of rotation
  107202. * @param space The space of the rotation
  107203. * @returns The rotation transform node
  107204. */
  107205. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107206. /**
  107207. * Translates the mesh
  107208. * @param axis The axis of translation
  107209. * @param distance The distance of translation
  107210. * @param space The space of the translation
  107211. * @returns The transform node
  107212. */
  107213. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107214. /**
  107215. * Sets the absolute position of the mesh
  107216. * @param absolutePosition The absolute position of the mesh
  107217. * @returns The transform node
  107218. */
  107219. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107220. /**
  107221. * Gets the class name of the mesh
  107222. * @returns The class name
  107223. */
  107224. getClassName(): string;
  107225. }
  107226. /**
  107227. * Represents a physics imposter
  107228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107229. */
  107230. export class PhysicsImpostor {
  107231. /**
  107232. * The physics-enabled object used as the physics imposter
  107233. */
  107234. object: IPhysicsEnabledObject;
  107235. /**
  107236. * The type of the physics imposter
  107237. */
  107238. type: number;
  107239. private _options;
  107240. private _scene?;
  107241. /**
  107242. * The default object size of the imposter
  107243. */
  107244. static DEFAULT_OBJECT_SIZE: Vector3;
  107245. /**
  107246. * The identity quaternion of the imposter
  107247. */
  107248. static IDENTITY_QUATERNION: Quaternion;
  107249. /** @hidden */
  107250. _pluginData: any;
  107251. private _physicsEngine;
  107252. private _physicsBody;
  107253. private _bodyUpdateRequired;
  107254. private _onBeforePhysicsStepCallbacks;
  107255. private _onAfterPhysicsStepCallbacks;
  107256. /** @hidden */
  107257. _onPhysicsCollideCallbacks: Array<{
  107258. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  107259. otherImpostors: Array<PhysicsImpostor>;
  107260. }>;
  107261. private _deltaPosition;
  107262. private _deltaRotation;
  107263. private _deltaRotationConjugated;
  107264. /** @hidden */
  107265. _isFromLine: boolean;
  107266. private _parent;
  107267. private _isDisposed;
  107268. private static _tmpVecs;
  107269. private static _tmpQuat;
  107270. /**
  107271. * Specifies if the physics imposter is disposed
  107272. */
  107273. get isDisposed(): boolean;
  107274. /**
  107275. * Gets the mass of the physics imposter
  107276. */
  107277. get mass(): number;
  107278. set mass(value: number);
  107279. /**
  107280. * Gets the coefficient of friction
  107281. */
  107282. get friction(): number;
  107283. /**
  107284. * Sets the coefficient of friction
  107285. */
  107286. set friction(value: number);
  107287. /**
  107288. * Gets the coefficient of restitution
  107289. */
  107290. get restitution(): number;
  107291. /**
  107292. * Sets the coefficient of restitution
  107293. */
  107294. set restitution(value: number);
  107295. /**
  107296. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  107297. */
  107298. get pressure(): number;
  107299. /**
  107300. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  107301. */
  107302. set pressure(value: number);
  107303. /**
  107304. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  107305. */
  107306. get stiffness(): number;
  107307. /**
  107308. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  107309. */
  107310. set stiffness(value: number);
  107311. /**
  107312. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  107313. */
  107314. get velocityIterations(): number;
  107315. /**
  107316. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  107317. */
  107318. set velocityIterations(value: number);
  107319. /**
  107320. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  107321. */
  107322. get positionIterations(): number;
  107323. /**
  107324. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  107325. */
  107326. set positionIterations(value: number);
  107327. /**
  107328. * The unique id of the physics imposter
  107329. * set by the physics engine when adding this impostor to the array
  107330. */
  107331. uniqueId: number;
  107332. /**
  107333. * @hidden
  107334. */
  107335. soft: boolean;
  107336. /**
  107337. * @hidden
  107338. */
  107339. segments: number;
  107340. private _joints;
  107341. /**
  107342. * Initializes the physics imposter
  107343. * @param object The physics-enabled object used as the physics imposter
  107344. * @param type The type of the physics imposter
  107345. * @param _options The options for the physics imposter
  107346. * @param _scene The Babylon scene
  107347. */
  107348. constructor(
  107349. /**
  107350. * The physics-enabled object used as the physics imposter
  107351. */
  107352. object: IPhysicsEnabledObject,
  107353. /**
  107354. * The type of the physics imposter
  107355. */
  107356. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  107357. /**
  107358. * This function will completly initialize this impostor.
  107359. * It will create a new body - but only if this mesh has no parent.
  107360. * If it has, this impostor will not be used other than to define the impostor
  107361. * of the child mesh.
  107362. * @hidden
  107363. */
  107364. _init(): void;
  107365. private _getPhysicsParent;
  107366. /**
  107367. * Should a new body be generated.
  107368. * @returns boolean specifying if body initialization is required
  107369. */
  107370. isBodyInitRequired(): boolean;
  107371. /**
  107372. * Sets the updated scaling
  107373. * @param updated Specifies if the scaling is updated
  107374. */
  107375. setScalingUpdated(): void;
  107376. /**
  107377. * Force a regeneration of this or the parent's impostor's body.
  107378. * Use under cautious - This will remove all joints already implemented.
  107379. */
  107380. forceUpdate(): void;
  107381. /**
  107382. * Gets the body that holds this impostor. Either its own, or its parent.
  107383. */
  107384. get physicsBody(): any;
  107385. /**
  107386. * Get the parent of the physics imposter
  107387. * @returns Physics imposter or null
  107388. */
  107389. get parent(): Nullable<PhysicsImpostor>;
  107390. /**
  107391. * Sets the parent of the physics imposter
  107392. */
  107393. set parent(value: Nullable<PhysicsImpostor>);
  107394. /**
  107395. * Set the physics body. Used mainly by the physics engine/plugin
  107396. */
  107397. set physicsBody(physicsBody: any);
  107398. /**
  107399. * Resets the update flags
  107400. */
  107401. resetUpdateFlags(): void;
  107402. /**
  107403. * Gets the object extend size
  107404. * @returns the object extend size
  107405. */
  107406. getObjectExtendSize(): Vector3;
  107407. /**
  107408. * Gets the object center
  107409. * @returns The object center
  107410. */
  107411. getObjectCenter(): Vector3;
  107412. /**
  107413. * Get a specific parameter from the options parameters
  107414. * @param paramName The object parameter name
  107415. * @returns The object parameter
  107416. */
  107417. getParam(paramName: string): any;
  107418. /**
  107419. * Sets a specific parameter in the options given to the physics plugin
  107420. * @param paramName The parameter name
  107421. * @param value The value of the parameter
  107422. */
  107423. setParam(paramName: string, value: number): void;
  107424. /**
  107425. * Specifically change the body's mass option. Won't recreate the physics body object
  107426. * @param mass The mass of the physics imposter
  107427. */
  107428. setMass(mass: number): void;
  107429. /**
  107430. * Gets the linear velocity
  107431. * @returns linear velocity or null
  107432. */
  107433. getLinearVelocity(): Nullable<Vector3>;
  107434. /**
  107435. * Sets the linear velocity
  107436. * @param velocity linear velocity or null
  107437. */
  107438. setLinearVelocity(velocity: Nullable<Vector3>): void;
  107439. /**
  107440. * Gets the angular velocity
  107441. * @returns angular velocity or null
  107442. */
  107443. getAngularVelocity(): Nullable<Vector3>;
  107444. /**
  107445. * Sets the angular velocity
  107446. * @param velocity The velocity or null
  107447. */
  107448. setAngularVelocity(velocity: Nullable<Vector3>): void;
  107449. /**
  107450. * Execute a function with the physics plugin native code
  107451. * Provide a function the will have two variables - the world object and the physics body object
  107452. * @param func The function to execute with the physics plugin native code
  107453. */
  107454. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  107455. /**
  107456. * Register a function that will be executed before the physics world is stepping forward
  107457. * @param func The function to execute before the physics world is stepped forward
  107458. */
  107459. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107460. /**
  107461. * Unregister a function that will be executed before the physics world is stepping forward
  107462. * @param func The function to execute before the physics world is stepped forward
  107463. */
  107464. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107465. /**
  107466. * Register a function that will be executed after the physics step
  107467. * @param func The function to execute after physics step
  107468. */
  107469. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107470. /**
  107471. * Unregisters a function that will be executed after the physics step
  107472. * @param func The function to execute after physics step
  107473. */
  107474. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107475. /**
  107476. * register a function that will be executed when this impostor collides against a different body
  107477. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  107478. * @param func Callback that is executed on collision
  107479. */
  107480. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  107481. /**
  107482. * Unregisters the physics imposter on contact
  107483. * @param collideAgainst The physics object to collide against
  107484. * @param func Callback to execute on collision
  107485. */
  107486. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  107487. private _tmpQuat;
  107488. private _tmpQuat2;
  107489. /**
  107490. * Get the parent rotation
  107491. * @returns The parent rotation
  107492. */
  107493. getParentsRotation(): Quaternion;
  107494. /**
  107495. * this function is executed by the physics engine.
  107496. */
  107497. beforeStep: () => void;
  107498. /**
  107499. * this function is executed by the physics engine
  107500. */
  107501. afterStep: () => void;
  107502. /**
  107503. * Legacy collision detection event support
  107504. */
  107505. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  107506. /**
  107507. * event and body object due to cannon's event-based architecture.
  107508. */
  107509. onCollide: (e: {
  107510. body: any;
  107511. }) => void;
  107512. /**
  107513. * Apply a force
  107514. * @param force The force to apply
  107515. * @param contactPoint The contact point for the force
  107516. * @returns The physics imposter
  107517. */
  107518. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  107519. /**
  107520. * Apply an impulse
  107521. * @param force The impulse force
  107522. * @param contactPoint The contact point for the impulse force
  107523. * @returns The physics imposter
  107524. */
  107525. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  107526. /**
  107527. * A help function to create a joint
  107528. * @param otherImpostor A physics imposter used to create a joint
  107529. * @param jointType The type of joint
  107530. * @param jointData The data for the joint
  107531. * @returns The physics imposter
  107532. */
  107533. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  107534. /**
  107535. * Add a joint to this impostor with a different impostor
  107536. * @param otherImpostor A physics imposter used to add a joint
  107537. * @param joint The joint to add
  107538. * @returns The physics imposter
  107539. */
  107540. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  107541. /**
  107542. * Add an anchor to a cloth impostor
  107543. * @param otherImpostor rigid impostor to anchor to
  107544. * @param width ratio across width from 0 to 1
  107545. * @param height ratio up height from 0 to 1
  107546. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107547. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  107548. * @returns impostor the soft imposter
  107549. */
  107550. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  107551. /**
  107552. * Add a hook to a rope impostor
  107553. * @param otherImpostor rigid impostor to anchor to
  107554. * @param length ratio across rope from 0 to 1
  107555. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  107556. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107557. * @returns impostor the rope imposter
  107558. */
  107559. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  107560. /**
  107561. * Will keep this body still, in a sleep mode.
  107562. * @returns the physics imposter
  107563. */
  107564. sleep(): PhysicsImpostor;
  107565. /**
  107566. * Wake the body up.
  107567. * @returns The physics imposter
  107568. */
  107569. wakeUp(): PhysicsImpostor;
  107570. /**
  107571. * Clones the physics imposter
  107572. * @param newObject The physics imposter clones to this physics-enabled object
  107573. * @returns A nullable physics imposter
  107574. */
  107575. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107576. /**
  107577. * Disposes the physics imposter
  107578. */
  107579. dispose(): void;
  107580. /**
  107581. * Sets the delta position
  107582. * @param position The delta position amount
  107583. */
  107584. setDeltaPosition(position: Vector3): void;
  107585. /**
  107586. * Sets the delta rotation
  107587. * @param rotation The delta rotation amount
  107588. */
  107589. setDeltaRotation(rotation: Quaternion): void;
  107590. /**
  107591. * Gets the box size of the physics imposter and stores the result in the input parameter
  107592. * @param result Stores the box size
  107593. * @returns The physics imposter
  107594. */
  107595. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  107596. /**
  107597. * Gets the radius of the physics imposter
  107598. * @returns Radius of the physics imposter
  107599. */
  107600. getRadius(): number;
  107601. /**
  107602. * Sync a bone with this impostor
  107603. * @param bone The bone to sync to the impostor.
  107604. * @param boneMesh The mesh that the bone is influencing.
  107605. * @param jointPivot The pivot of the joint / bone in local space.
  107606. * @param distToJoint Optional distance from the impostor to the joint.
  107607. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  107608. */
  107609. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  107610. /**
  107611. * Sync impostor to a bone
  107612. * @param bone The bone that the impostor will be synced to.
  107613. * @param boneMesh The mesh that the bone is influencing.
  107614. * @param jointPivot The pivot of the joint / bone in local space.
  107615. * @param distToJoint Optional distance from the impostor to the joint.
  107616. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  107617. * @param boneAxis Optional vector3 axis the bone is aligned with
  107618. */
  107619. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  107620. /**
  107621. * No-Imposter type
  107622. */
  107623. static NoImpostor: number;
  107624. /**
  107625. * Sphere-Imposter type
  107626. */
  107627. static SphereImpostor: number;
  107628. /**
  107629. * Box-Imposter type
  107630. */
  107631. static BoxImpostor: number;
  107632. /**
  107633. * Plane-Imposter type
  107634. */
  107635. static PlaneImpostor: number;
  107636. /**
  107637. * Mesh-imposter type
  107638. */
  107639. static MeshImpostor: number;
  107640. /**
  107641. * Capsule-Impostor type (Ammo.js plugin only)
  107642. */
  107643. static CapsuleImpostor: number;
  107644. /**
  107645. * Cylinder-Imposter type
  107646. */
  107647. static CylinderImpostor: number;
  107648. /**
  107649. * Particle-Imposter type
  107650. */
  107651. static ParticleImpostor: number;
  107652. /**
  107653. * Heightmap-Imposter type
  107654. */
  107655. static HeightmapImpostor: number;
  107656. /**
  107657. * ConvexHull-Impostor type (Ammo.js plugin only)
  107658. */
  107659. static ConvexHullImpostor: number;
  107660. /**
  107661. * Custom-Imposter type (Ammo.js plugin only)
  107662. */
  107663. static CustomImpostor: number;
  107664. /**
  107665. * Rope-Imposter type
  107666. */
  107667. static RopeImpostor: number;
  107668. /**
  107669. * Cloth-Imposter type
  107670. */
  107671. static ClothImpostor: number;
  107672. /**
  107673. * Softbody-Imposter type
  107674. */
  107675. static SoftbodyImpostor: number;
  107676. }
  107677. }
  107678. declare module BABYLON {
  107679. /**
  107680. * @hidden
  107681. **/
  107682. export class _CreationDataStorage {
  107683. closePath?: boolean;
  107684. closeArray?: boolean;
  107685. idx: number[];
  107686. dashSize: number;
  107687. gapSize: number;
  107688. path3D: Path3D;
  107689. pathArray: Vector3[][];
  107690. arc: number;
  107691. radius: number;
  107692. cap: number;
  107693. tessellation: number;
  107694. }
  107695. /**
  107696. * @hidden
  107697. **/
  107698. class _InstanceDataStorage {
  107699. visibleInstances: any;
  107700. batchCache: _InstancesBatch;
  107701. instancesBufferSize: number;
  107702. instancesBuffer: Nullable<Buffer>;
  107703. instancesData: Float32Array;
  107704. overridenInstanceCount: number;
  107705. isFrozen: boolean;
  107706. previousBatch: Nullable<_InstancesBatch>;
  107707. hardwareInstancedRendering: boolean;
  107708. sideOrientation: number;
  107709. manualUpdate: boolean;
  107710. }
  107711. /**
  107712. * @hidden
  107713. **/
  107714. export class _InstancesBatch {
  107715. mustReturn: boolean;
  107716. visibleInstances: Nullable<InstancedMesh[]>[];
  107717. renderSelf: boolean[];
  107718. hardwareInstancedRendering: boolean[];
  107719. }
  107720. /**
  107721. * @hidden
  107722. **/
  107723. class _ThinInstanceDataStorage {
  107724. instancesCount: number;
  107725. matrixBuffer: Nullable<Buffer>;
  107726. matrixBufferSize: number;
  107727. matrixData: Nullable<Float32Array>;
  107728. boundingVectors: Array<Vector3>;
  107729. worldMatrices: Nullable<Matrix[]>;
  107730. }
  107731. /**
  107732. * Class used to represent renderable models
  107733. */
  107734. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  107735. /**
  107736. * Mesh side orientation : usually the external or front surface
  107737. */
  107738. static readonly FRONTSIDE: number;
  107739. /**
  107740. * Mesh side orientation : usually the internal or back surface
  107741. */
  107742. static readonly BACKSIDE: number;
  107743. /**
  107744. * Mesh side orientation : both internal and external or front and back surfaces
  107745. */
  107746. static readonly DOUBLESIDE: number;
  107747. /**
  107748. * Mesh side orientation : by default, `FRONTSIDE`
  107749. */
  107750. static readonly DEFAULTSIDE: number;
  107751. /**
  107752. * Mesh cap setting : no cap
  107753. */
  107754. static readonly NO_CAP: number;
  107755. /**
  107756. * Mesh cap setting : one cap at the beginning of the mesh
  107757. */
  107758. static readonly CAP_START: number;
  107759. /**
  107760. * Mesh cap setting : one cap at the end of the mesh
  107761. */
  107762. static readonly CAP_END: number;
  107763. /**
  107764. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  107765. */
  107766. static readonly CAP_ALL: number;
  107767. /**
  107768. * Mesh pattern setting : no flip or rotate
  107769. */
  107770. static readonly NO_FLIP: number;
  107771. /**
  107772. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  107773. */
  107774. static readonly FLIP_TILE: number;
  107775. /**
  107776. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  107777. */
  107778. static readonly ROTATE_TILE: number;
  107779. /**
  107780. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  107781. */
  107782. static readonly FLIP_ROW: number;
  107783. /**
  107784. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  107785. */
  107786. static readonly ROTATE_ROW: number;
  107787. /**
  107788. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  107789. */
  107790. static readonly FLIP_N_ROTATE_TILE: number;
  107791. /**
  107792. * Mesh pattern setting : rotate pattern and rotate
  107793. */
  107794. static readonly FLIP_N_ROTATE_ROW: number;
  107795. /**
  107796. * Mesh tile positioning : part tiles same on left/right or top/bottom
  107797. */
  107798. static readonly CENTER: number;
  107799. /**
  107800. * Mesh tile positioning : part tiles on left
  107801. */
  107802. static readonly LEFT: number;
  107803. /**
  107804. * Mesh tile positioning : part tiles on right
  107805. */
  107806. static readonly RIGHT: number;
  107807. /**
  107808. * Mesh tile positioning : part tiles on top
  107809. */
  107810. static readonly TOP: number;
  107811. /**
  107812. * Mesh tile positioning : part tiles on bottom
  107813. */
  107814. static readonly BOTTOM: number;
  107815. /**
  107816. * Gets the default side orientation.
  107817. * @param orientation the orientation to value to attempt to get
  107818. * @returns the default orientation
  107819. * @hidden
  107820. */
  107821. static _GetDefaultSideOrientation(orientation?: number): number;
  107822. private _internalMeshDataInfo;
  107823. get computeBonesUsingShaders(): boolean;
  107824. set computeBonesUsingShaders(value: boolean);
  107825. /**
  107826. * An event triggered before rendering the mesh
  107827. */
  107828. get onBeforeRenderObservable(): Observable<Mesh>;
  107829. /**
  107830. * An event triggered before binding the mesh
  107831. */
  107832. get onBeforeBindObservable(): Observable<Mesh>;
  107833. /**
  107834. * An event triggered after rendering the mesh
  107835. */
  107836. get onAfterRenderObservable(): Observable<Mesh>;
  107837. /**
  107838. * An event triggered before drawing the mesh
  107839. */
  107840. get onBeforeDrawObservable(): Observable<Mesh>;
  107841. private _onBeforeDrawObserver;
  107842. /**
  107843. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  107844. */
  107845. set onBeforeDraw(callback: () => void);
  107846. get hasInstances(): boolean;
  107847. get hasThinInstances(): boolean;
  107848. /**
  107849. * Gets the delay loading state of the mesh (when delay loading is turned on)
  107850. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  107851. */
  107852. delayLoadState: number;
  107853. /**
  107854. * Gets the list of instances created from this mesh
  107855. * it is not supposed to be modified manually.
  107856. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  107857. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  107858. */
  107859. instances: InstancedMesh[];
  107860. /**
  107861. * Gets the file containing delay loading data for this mesh
  107862. */
  107863. delayLoadingFile: string;
  107864. /** @hidden */
  107865. _binaryInfo: any;
  107866. /**
  107867. * User defined function used to change how LOD level selection is done
  107868. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107869. */
  107870. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  107871. /**
  107872. * Gets or sets the morph target manager
  107873. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107874. */
  107875. get morphTargetManager(): Nullable<MorphTargetManager>;
  107876. set morphTargetManager(value: Nullable<MorphTargetManager>);
  107877. /** @hidden */
  107878. _creationDataStorage: Nullable<_CreationDataStorage>;
  107879. /** @hidden */
  107880. _geometry: Nullable<Geometry>;
  107881. /** @hidden */
  107882. _delayInfo: Array<string>;
  107883. /** @hidden */
  107884. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  107885. /** @hidden */
  107886. _instanceDataStorage: _InstanceDataStorage;
  107887. /** @hidden */
  107888. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  107889. private _effectiveMaterial;
  107890. /** @hidden */
  107891. _shouldGenerateFlatShading: boolean;
  107892. /** @hidden */
  107893. _originalBuilderSideOrientation: number;
  107894. /**
  107895. * Use this property to change the original side orientation defined at construction time
  107896. */
  107897. overrideMaterialSideOrientation: Nullable<number>;
  107898. /**
  107899. * Gets the source mesh (the one used to clone this one from)
  107900. */
  107901. get source(): Nullable<Mesh>;
  107902. /**
  107903. * Gets or sets a boolean indicating that this mesh does not use index buffer
  107904. */
  107905. get isUnIndexed(): boolean;
  107906. set isUnIndexed(value: boolean);
  107907. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  107908. get worldMatrixInstancedBuffer(): Float32Array;
  107909. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  107910. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  107911. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  107912. /**
  107913. * @constructor
  107914. * @param name The value used by scene.getMeshByName() to do a lookup.
  107915. * @param scene The scene to add this mesh to.
  107916. * @param parent The parent of this mesh, if it has one
  107917. * @param source An optional Mesh from which geometry is shared, cloned.
  107918. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  107919. * When false, achieved by calling a clone(), also passing False.
  107920. * This will make creation of children, recursive.
  107921. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  107922. */
  107923. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  107924. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  107925. doNotInstantiate: boolean;
  107926. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  107927. /**
  107928. * Gets the class name
  107929. * @returns the string "Mesh".
  107930. */
  107931. getClassName(): string;
  107932. /** @hidden */
  107933. get _isMesh(): boolean;
  107934. /**
  107935. * Returns a description of this mesh
  107936. * @param fullDetails define if full details about this mesh must be used
  107937. * @returns a descriptive string representing this mesh
  107938. */
  107939. toString(fullDetails?: boolean): string;
  107940. /** @hidden */
  107941. _unBindEffect(): void;
  107942. /**
  107943. * Gets a boolean indicating if this mesh has LOD
  107944. */
  107945. get hasLODLevels(): boolean;
  107946. /**
  107947. * Gets the list of MeshLODLevel associated with the current mesh
  107948. * @returns an array of MeshLODLevel
  107949. */
  107950. getLODLevels(): MeshLODLevel[];
  107951. private _sortLODLevels;
  107952. /**
  107953. * Add a mesh as LOD level triggered at the given distance.
  107954. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107955. * @param distance The distance from the center of the object to show this level
  107956. * @param mesh The mesh to be added as LOD level (can be null)
  107957. * @return This mesh (for chaining)
  107958. */
  107959. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  107960. /**
  107961. * Returns the LOD level mesh at the passed distance or null if not found.
  107962. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107963. * @param distance The distance from the center of the object to show this level
  107964. * @returns a Mesh or `null`
  107965. */
  107966. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  107967. /**
  107968. * Remove a mesh from the LOD array
  107969. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107970. * @param mesh defines the mesh to be removed
  107971. * @return This mesh (for chaining)
  107972. */
  107973. removeLODLevel(mesh: Mesh): Mesh;
  107974. /**
  107975. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  107976. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107977. * @param camera defines the camera to use to compute distance
  107978. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  107979. * @return This mesh (for chaining)
  107980. */
  107981. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  107982. /**
  107983. * Gets the mesh internal Geometry object
  107984. */
  107985. get geometry(): Nullable<Geometry>;
  107986. /**
  107987. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  107988. * @returns the total number of vertices
  107989. */
  107990. getTotalVertices(): number;
  107991. /**
  107992. * Returns the content of an associated vertex buffer
  107993. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107994. * - VertexBuffer.PositionKind
  107995. * - VertexBuffer.UVKind
  107996. * - VertexBuffer.UV2Kind
  107997. * - VertexBuffer.UV3Kind
  107998. * - VertexBuffer.UV4Kind
  107999. * - VertexBuffer.UV5Kind
  108000. * - VertexBuffer.UV6Kind
  108001. * - VertexBuffer.ColorKind
  108002. * - VertexBuffer.MatricesIndicesKind
  108003. * - VertexBuffer.MatricesIndicesExtraKind
  108004. * - VertexBuffer.MatricesWeightsKind
  108005. * - VertexBuffer.MatricesWeightsExtraKind
  108006. * @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
  108007. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  108008. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  108009. */
  108010. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  108011. /**
  108012. * Returns the mesh VertexBuffer object from the requested `kind`
  108013. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108014. * - VertexBuffer.PositionKind
  108015. * - VertexBuffer.NormalKind
  108016. * - VertexBuffer.UVKind
  108017. * - VertexBuffer.UV2Kind
  108018. * - VertexBuffer.UV3Kind
  108019. * - VertexBuffer.UV4Kind
  108020. * - VertexBuffer.UV5Kind
  108021. * - VertexBuffer.UV6Kind
  108022. * - VertexBuffer.ColorKind
  108023. * - VertexBuffer.MatricesIndicesKind
  108024. * - VertexBuffer.MatricesIndicesExtraKind
  108025. * - VertexBuffer.MatricesWeightsKind
  108026. * - VertexBuffer.MatricesWeightsExtraKind
  108027. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  108028. */
  108029. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  108030. /**
  108031. * Tests if a specific vertex buffer is associated with this mesh
  108032. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108033. * - VertexBuffer.PositionKind
  108034. * - VertexBuffer.NormalKind
  108035. * - VertexBuffer.UVKind
  108036. * - VertexBuffer.UV2Kind
  108037. * - VertexBuffer.UV3Kind
  108038. * - VertexBuffer.UV4Kind
  108039. * - VertexBuffer.UV5Kind
  108040. * - VertexBuffer.UV6Kind
  108041. * - VertexBuffer.ColorKind
  108042. * - VertexBuffer.MatricesIndicesKind
  108043. * - VertexBuffer.MatricesIndicesExtraKind
  108044. * - VertexBuffer.MatricesWeightsKind
  108045. * - VertexBuffer.MatricesWeightsExtraKind
  108046. * @returns a boolean
  108047. */
  108048. isVerticesDataPresent(kind: string): boolean;
  108049. /**
  108050. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  108051. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108052. * - VertexBuffer.PositionKind
  108053. * - VertexBuffer.UVKind
  108054. * - VertexBuffer.UV2Kind
  108055. * - VertexBuffer.UV3Kind
  108056. * - VertexBuffer.UV4Kind
  108057. * - VertexBuffer.UV5Kind
  108058. * - VertexBuffer.UV6Kind
  108059. * - VertexBuffer.ColorKind
  108060. * - VertexBuffer.MatricesIndicesKind
  108061. * - VertexBuffer.MatricesIndicesExtraKind
  108062. * - VertexBuffer.MatricesWeightsKind
  108063. * - VertexBuffer.MatricesWeightsExtraKind
  108064. * @returns a boolean
  108065. */
  108066. isVertexBufferUpdatable(kind: string): boolean;
  108067. /**
  108068. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  108069. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108070. * - VertexBuffer.PositionKind
  108071. * - VertexBuffer.NormalKind
  108072. * - VertexBuffer.UVKind
  108073. * - VertexBuffer.UV2Kind
  108074. * - VertexBuffer.UV3Kind
  108075. * - VertexBuffer.UV4Kind
  108076. * - VertexBuffer.UV5Kind
  108077. * - VertexBuffer.UV6Kind
  108078. * - VertexBuffer.ColorKind
  108079. * - VertexBuffer.MatricesIndicesKind
  108080. * - VertexBuffer.MatricesIndicesExtraKind
  108081. * - VertexBuffer.MatricesWeightsKind
  108082. * - VertexBuffer.MatricesWeightsExtraKind
  108083. * @returns an array of strings
  108084. */
  108085. getVerticesDataKinds(): string[];
  108086. /**
  108087. * Returns a positive integer : the total number of indices in this mesh geometry.
  108088. * @returns the numner of indices or zero if the mesh has no geometry.
  108089. */
  108090. getTotalIndices(): number;
  108091. /**
  108092. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  108093. * @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.
  108094. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  108095. * @returns the indices array or an empty array if the mesh has no geometry
  108096. */
  108097. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  108098. get isBlocked(): boolean;
  108099. /**
  108100. * Determine if the current mesh is ready to be rendered
  108101. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  108102. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  108103. * @returns true if all associated assets are ready (material, textures, shaders)
  108104. */
  108105. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  108106. /**
  108107. * 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.
  108108. */
  108109. get areNormalsFrozen(): boolean;
  108110. /**
  108111. * 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.
  108112. * @returns the current mesh
  108113. */
  108114. freezeNormals(): Mesh;
  108115. /**
  108116. * 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
  108117. * @returns the current mesh
  108118. */
  108119. unfreezeNormals(): Mesh;
  108120. /**
  108121. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  108122. */
  108123. set overridenInstanceCount(count: number);
  108124. /** @hidden */
  108125. _preActivate(): Mesh;
  108126. /** @hidden */
  108127. _preActivateForIntermediateRendering(renderId: number): Mesh;
  108128. /** @hidden */
  108129. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  108130. protected _afterComputeWorldMatrix(): void;
  108131. /** @hidden */
  108132. _postActivate(): void;
  108133. /**
  108134. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108135. * This means the mesh underlying bounding box and sphere are recomputed.
  108136. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108137. * @returns the current mesh
  108138. */
  108139. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  108140. /** @hidden */
  108141. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  108142. /**
  108143. * This function will subdivide the mesh into multiple submeshes
  108144. * @param count defines the expected number of submeshes
  108145. */
  108146. subdivide(count: number): void;
  108147. /**
  108148. * Copy a FloatArray into a specific associated vertex buffer
  108149. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108150. * - VertexBuffer.PositionKind
  108151. * - VertexBuffer.UVKind
  108152. * - VertexBuffer.UV2Kind
  108153. * - VertexBuffer.UV3Kind
  108154. * - VertexBuffer.UV4Kind
  108155. * - VertexBuffer.UV5Kind
  108156. * - VertexBuffer.UV6Kind
  108157. * - VertexBuffer.ColorKind
  108158. * - VertexBuffer.MatricesIndicesKind
  108159. * - VertexBuffer.MatricesIndicesExtraKind
  108160. * - VertexBuffer.MatricesWeightsKind
  108161. * - VertexBuffer.MatricesWeightsExtraKind
  108162. * @param data defines the data source
  108163. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108164. * @param stride defines the data stride size (can be null)
  108165. * @returns the current mesh
  108166. */
  108167. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108168. /**
  108169. * Delete a vertex buffer associated with this mesh
  108170. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  108171. * - VertexBuffer.PositionKind
  108172. * - VertexBuffer.UVKind
  108173. * - VertexBuffer.UV2Kind
  108174. * - VertexBuffer.UV3Kind
  108175. * - VertexBuffer.UV4Kind
  108176. * - VertexBuffer.UV5Kind
  108177. * - VertexBuffer.UV6Kind
  108178. * - VertexBuffer.ColorKind
  108179. * - VertexBuffer.MatricesIndicesKind
  108180. * - VertexBuffer.MatricesIndicesExtraKind
  108181. * - VertexBuffer.MatricesWeightsKind
  108182. * - VertexBuffer.MatricesWeightsExtraKind
  108183. */
  108184. removeVerticesData(kind: string): void;
  108185. /**
  108186. * Flags an associated vertex buffer as updatable
  108187. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  108188. * - VertexBuffer.PositionKind
  108189. * - VertexBuffer.UVKind
  108190. * - VertexBuffer.UV2Kind
  108191. * - VertexBuffer.UV3Kind
  108192. * - VertexBuffer.UV4Kind
  108193. * - VertexBuffer.UV5Kind
  108194. * - VertexBuffer.UV6Kind
  108195. * - VertexBuffer.ColorKind
  108196. * - VertexBuffer.MatricesIndicesKind
  108197. * - VertexBuffer.MatricesIndicesExtraKind
  108198. * - VertexBuffer.MatricesWeightsKind
  108199. * - VertexBuffer.MatricesWeightsExtraKind
  108200. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108201. */
  108202. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  108203. /**
  108204. * Sets the mesh global Vertex Buffer
  108205. * @param buffer defines the buffer to use
  108206. * @returns the current mesh
  108207. */
  108208. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  108209. /**
  108210. * Update a specific associated vertex buffer
  108211. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108212. * - VertexBuffer.PositionKind
  108213. * - VertexBuffer.UVKind
  108214. * - VertexBuffer.UV2Kind
  108215. * - VertexBuffer.UV3Kind
  108216. * - VertexBuffer.UV4Kind
  108217. * - VertexBuffer.UV5Kind
  108218. * - VertexBuffer.UV6Kind
  108219. * - VertexBuffer.ColorKind
  108220. * - VertexBuffer.MatricesIndicesKind
  108221. * - VertexBuffer.MatricesIndicesExtraKind
  108222. * - VertexBuffer.MatricesWeightsKind
  108223. * - VertexBuffer.MatricesWeightsExtraKind
  108224. * @param data defines the data source
  108225. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  108226. * @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)
  108227. * @returns the current mesh
  108228. */
  108229. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108230. /**
  108231. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  108232. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  108233. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  108234. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  108235. * @returns the current mesh
  108236. */
  108237. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  108238. /**
  108239. * Creates a un-shared specific occurence of the geometry for the mesh.
  108240. * @returns the current mesh
  108241. */
  108242. makeGeometryUnique(): Mesh;
  108243. /**
  108244. * Set the index buffer of this mesh
  108245. * @param indices defines the source data
  108246. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  108247. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  108248. * @returns the current mesh
  108249. */
  108250. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  108251. /**
  108252. * Update the current index buffer
  108253. * @param indices defines the source data
  108254. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  108255. * @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)
  108256. * @returns the current mesh
  108257. */
  108258. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  108259. /**
  108260. * Invert the geometry to move from a right handed system to a left handed one.
  108261. * @returns the current mesh
  108262. */
  108263. toLeftHanded(): Mesh;
  108264. /** @hidden */
  108265. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  108266. /** @hidden */
  108267. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  108268. /**
  108269. * Registers for this mesh a javascript function called just before the rendering process
  108270. * @param func defines the function to call before rendering this mesh
  108271. * @returns the current mesh
  108272. */
  108273. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  108274. /**
  108275. * Disposes a previously registered javascript function called before the rendering
  108276. * @param func defines the function to remove
  108277. * @returns the current mesh
  108278. */
  108279. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  108280. /**
  108281. * Registers for this mesh a javascript function called just after the rendering is complete
  108282. * @param func defines the function to call after rendering this mesh
  108283. * @returns the current mesh
  108284. */
  108285. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  108286. /**
  108287. * Disposes a previously registered javascript function called after the rendering.
  108288. * @param func defines the function to remove
  108289. * @returns the current mesh
  108290. */
  108291. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  108292. /** @hidden */
  108293. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  108294. /** @hidden */
  108295. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  108296. /** @hidden */
  108297. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  108298. /** @hidden */
  108299. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  108300. /** @hidden */
  108301. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  108302. /** @hidden */
  108303. _rebuild(): void;
  108304. /** @hidden */
  108305. _freeze(): void;
  108306. /** @hidden */
  108307. _unFreeze(): void;
  108308. /**
  108309. * 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
  108310. * @param subMesh defines the subMesh to render
  108311. * @param enableAlphaMode defines if alpha mode can be changed
  108312. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  108313. * @returns the current mesh
  108314. */
  108315. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  108316. private _onBeforeDraw;
  108317. /**
  108318. * Renormalize the mesh and patch it up if there are no weights
  108319. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  108320. * However in the case of zero weights then we set just a single influence to 1.
  108321. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  108322. */
  108323. cleanMatrixWeights(): void;
  108324. private normalizeSkinFourWeights;
  108325. private normalizeSkinWeightsAndExtra;
  108326. /**
  108327. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  108328. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  108329. * the user know there was an issue with importing the mesh
  108330. * @returns a validation object with skinned, valid and report string
  108331. */
  108332. validateSkinning(): {
  108333. skinned: boolean;
  108334. valid: boolean;
  108335. report: string;
  108336. };
  108337. /** @hidden */
  108338. _checkDelayState(): Mesh;
  108339. private _queueLoad;
  108340. /**
  108341. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  108342. * A mesh is in the frustum if its bounding box intersects the frustum
  108343. * @param frustumPlanes defines the frustum to test
  108344. * @returns true if the mesh is in the frustum planes
  108345. */
  108346. isInFrustum(frustumPlanes: Plane[]): boolean;
  108347. /**
  108348. * Sets the mesh material by the material or multiMaterial `id` property
  108349. * @param id is a string identifying the material or the multiMaterial
  108350. * @returns the current mesh
  108351. */
  108352. setMaterialByID(id: string): Mesh;
  108353. /**
  108354. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  108355. * @returns an array of IAnimatable
  108356. */
  108357. getAnimatables(): IAnimatable[];
  108358. /**
  108359. * Modifies the mesh geometry according to the passed transformation matrix.
  108360. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  108361. * The mesh normals are modified using the same transformation.
  108362. * Note that, under the hood, this method sets a new VertexBuffer each call.
  108363. * @param transform defines the transform matrix to use
  108364. * @see https://doc.babylonjs.com/resources/baking_transformations
  108365. * @returns the current mesh
  108366. */
  108367. bakeTransformIntoVertices(transform: Matrix): Mesh;
  108368. /**
  108369. * Modifies the mesh geometry according to its own current World Matrix.
  108370. * The mesh World Matrix is then reset.
  108371. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  108372. * Note that, under the hood, this method sets a new VertexBuffer each call.
  108373. * @see https://doc.babylonjs.com/resources/baking_transformations
  108374. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  108375. * @returns the current mesh
  108376. */
  108377. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  108378. /** @hidden */
  108379. get _positions(): Nullable<Vector3[]>;
  108380. /** @hidden */
  108381. _resetPointsArrayCache(): Mesh;
  108382. /** @hidden */
  108383. _generatePointsArray(): boolean;
  108384. /**
  108385. * Returns a new Mesh object generated from the current mesh properties.
  108386. * This method must not get confused with createInstance()
  108387. * @param name is a string, the name given to the new mesh
  108388. * @param newParent can be any Node object (default `null`)
  108389. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  108390. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  108391. * @returns a new mesh
  108392. */
  108393. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  108394. /**
  108395. * Releases resources associated with this mesh.
  108396. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108397. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108398. */
  108399. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108400. /** @hidden */
  108401. _disposeInstanceSpecificData(): void;
  108402. /** @hidden */
  108403. _disposeThinInstanceSpecificData(): void;
  108404. /**
  108405. * Modifies the mesh geometry according to a displacement map.
  108406. * 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.
  108407. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  108408. * @param url is a string, the URL from the image file is to be downloaded.
  108409. * @param minHeight is the lower limit of the displacement.
  108410. * @param maxHeight is the upper limit of the displacement.
  108411. * @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.
  108412. * @param uvOffset is an optional vector2 used to offset UV.
  108413. * @param uvScale is an optional vector2 used to scale UV.
  108414. * @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.
  108415. * @returns the Mesh.
  108416. */
  108417. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  108418. /**
  108419. * Modifies the mesh geometry according to a displacementMap buffer.
  108420. * 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.
  108421. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  108422. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  108423. * @param heightMapWidth is the width of the buffer image.
  108424. * @param heightMapHeight is the height of the buffer image.
  108425. * @param minHeight is the lower limit of the displacement.
  108426. * @param maxHeight is the upper limit of the displacement.
  108427. * @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.
  108428. * @param uvOffset is an optional vector2 used to offset UV.
  108429. * @param uvScale is an optional vector2 used to scale UV.
  108430. * @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.
  108431. * @returns the Mesh.
  108432. */
  108433. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  108434. /**
  108435. * Modify the mesh to get a flat shading rendering.
  108436. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  108437. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  108438. * @returns current mesh
  108439. */
  108440. convertToFlatShadedMesh(): Mesh;
  108441. /**
  108442. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  108443. * In other words, more vertices, no more indices and a single bigger VBO.
  108444. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  108445. * @returns current mesh
  108446. */
  108447. convertToUnIndexedMesh(): Mesh;
  108448. /**
  108449. * Inverses facet orientations.
  108450. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108451. * @param flipNormals will also inverts the normals
  108452. * @returns current mesh
  108453. */
  108454. flipFaces(flipNormals?: boolean): Mesh;
  108455. /**
  108456. * Increase the number of facets and hence vertices in a mesh
  108457. * Vertex normals are interpolated from existing vertex normals
  108458. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108459. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  108460. */
  108461. increaseVertices(numberPerEdge: number): void;
  108462. /**
  108463. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  108464. * This will undo any application of covertToFlatShadedMesh
  108465. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108466. */
  108467. forceSharedVertices(): void;
  108468. /** @hidden */
  108469. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  108470. /** @hidden */
  108471. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  108472. /**
  108473. * Creates a new InstancedMesh object from the mesh model.
  108474. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108475. * @param name defines the name of the new instance
  108476. * @returns a new InstancedMesh
  108477. */
  108478. createInstance(name: string): InstancedMesh;
  108479. /**
  108480. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  108481. * After this call, all the mesh instances have the same submeshes than the current mesh.
  108482. * @returns the current mesh
  108483. */
  108484. synchronizeInstances(): Mesh;
  108485. /**
  108486. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  108487. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  108488. * This should be used together with the simplification to avoid disappearing triangles.
  108489. * @param successCallback an optional success callback to be called after the optimization finished.
  108490. * @returns the current mesh
  108491. */
  108492. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  108493. /**
  108494. * Serialize current mesh
  108495. * @param serializationObject defines the object which will receive the serialization data
  108496. */
  108497. serialize(serializationObject: any): void;
  108498. /** @hidden */
  108499. _syncGeometryWithMorphTargetManager(): void;
  108500. /** @hidden */
  108501. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  108502. /**
  108503. * Returns a new Mesh object parsed from the source provided.
  108504. * @param parsedMesh is the source
  108505. * @param scene defines the hosting scene
  108506. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  108507. * @returns a new Mesh
  108508. */
  108509. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  108510. /**
  108511. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  108512. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108513. * @param name defines the name of the mesh to create
  108514. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  108515. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  108516. * @param closePath creates a seam between the first and the last points of each path of the path array
  108517. * @param offset is taken in account only if the `pathArray` is containing a single path
  108518. * @param scene defines the hosting scene
  108519. * @param updatable defines if the mesh must be flagged as updatable
  108520. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108521. * @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)
  108522. * @returns a new Mesh
  108523. */
  108524. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108525. /**
  108526. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  108527. * @param name defines the name of the mesh to create
  108528. * @param radius sets the radius size (float) of the polygon (default 0.5)
  108529. * @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
  108530. * @param scene defines the hosting scene
  108531. * @param updatable defines if the mesh must be flagged as updatable
  108532. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108533. * @returns a new Mesh
  108534. */
  108535. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  108536. /**
  108537. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  108538. * @param name defines the name of the mesh to create
  108539. * @param size sets the size (float) of each box side (default 1)
  108540. * @param scene defines the hosting scene
  108541. * @param updatable defines if the mesh must be flagged as updatable
  108542. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108543. * @returns a new Mesh
  108544. */
  108545. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  108546. /**
  108547. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  108548. * @param name defines the name of the mesh to create
  108549. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  108550. * @param diameter sets the diameter size (float) of the sphere (default 1)
  108551. * @param scene defines the hosting scene
  108552. * @param updatable defines if the mesh must be flagged as updatable
  108553. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108554. * @returns a new Mesh
  108555. */
  108556. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108557. /**
  108558. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  108559. * @param name defines the name of the mesh to create
  108560. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  108561. * @param diameter sets the diameter size (float) of the sphere (default 1)
  108562. * @param scene defines the hosting scene
  108563. * @returns a new Mesh
  108564. */
  108565. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  108566. /**
  108567. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  108568. * @param name defines the name of the mesh to create
  108569. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  108570. * @param diameterTop set the top cap diameter (floats, default 1)
  108571. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  108572. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  108573. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  108574. * @param scene defines the hosting scene
  108575. * @param updatable defines if the mesh must be flagged as updatable
  108576. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108577. * @returns a new Mesh
  108578. */
  108579. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  108580. /**
  108581. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  108582. * @param name defines the name of the mesh to create
  108583. * @param diameter sets the diameter size (float) of the torus (default 1)
  108584. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  108585. * @param tessellation sets the number of torus sides (postive integer, default 16)
  108586. * @param scene defines the hosting scene
  108587. * @param updatable defines if the mesh must be flagged as updatable
  108588. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108589. * @returns a new Mesh
  108590. */
  108591. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108592. /**
  108593. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  108594. * @param name defines the name of the mesh to create
  108595. * @param radius sets the global radius size (float) of the torus knot (default 2)
  108596. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  108597. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  108598. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  108599. * @param p the number of windings on X axis (positive integers, default 2)
  108600. * @param q the number of windings on Y axis (positive integers, default 3)
  108601. * @param scene defines the hosting scene
  108602. * @param updatable defines if the mesh must be flagged as updatable
  108603. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108604. * @returns a new Mesh
  108605. */
  108606. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108607. /**
  108608. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  108609. * @param name defines the name of the mesh to create
  108610. * @param points is an array successive Vector3
  108611. * @param scene defines the hosting scene
  108612. * @param updatable defines if the mesh must be flagged as updatable
  108613. * @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).
  108614. * @returns a new Mesh
  108615. */
  108616. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  108617. /**
  108618. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  108619. * @param name defines the name of the mesh to create
  108620. * @param points is an array successive Vector3
  108621. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  108622. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  108623. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  108624. * @param scene defines the hosting scene
  108625. * @param updatable defines if the mesh must be flagged as updatable
  108626. * @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)
  108627. * @returns a new Mesh
  108628. */
  108629. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  108630. /**
  108631. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  108632. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  108633. * 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.
  108634. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108635. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108636. * Remember you can only change the shape positions, not their number when updating a polygon.
  108637. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  108638. * @param name defines the name of the mesh to create
  108639. * @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
  108640. * @param scene defines the hosting scene
  108641. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  108642. * @param updatable defines if the mesh must be flagged as updatable
  108643. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108644. * @param earcutInjection can be used to inject your own earcut reference
  108645. * @returns a new Mesh
  108646. */
  108647. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  108648. /**
  108649. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  108650. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  108651. * @param name defines the name of the mesh to create
  108652. * @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
  108653. * @param depth defines the height of extrusion
  108654. * @param scene defines the hosting scene
  108655. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  108656. * @param updatable defines if the mesh must be flagged as updatable
  108657. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108658. * @param earcutInjection can be used to inject your own earcut reference
  108659. * @returns a new Mesh
  108660. */
  108661. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  108662. /**
  108663. * Creates an extruded shape mesh.
  108664. * 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
  108665. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108666. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108667. * @param name defines the name of the mesh to create
  108668. * @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
  108669. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  108670. * @param scale is the value to scale the shape
  108671. * @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
  108672. * @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
  108673. * @param scene defines the hosting scene
  108674. * @param updatable defines if the mesh must be flagged as updatable
  108675. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108676. * @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)
  108677. * @returns a new Mesh
  108678. */
  108679. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108680. /**
  108681. * Creates an custom extruded shape mesh.
  108682. * The custom extrusion is a parametric shape.
  108683. * It has no predefined shape. Its final shape will depend on the input parameters.
  108684. * Please consider using the same method from the MeshBuilder class instead
  108685. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108686. * @param name defines the name of the mesh to create
  108687. * @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
  108688. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  108689. * @param scaleFunction is a custom Javascript function called on each path point
  108690. * @param rotationFunction is a custom Javascript function called on each path point
  108691. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108692. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  108693. * @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
  108694. * @param scene defines the hosting scene
  108695. * @param updatable defines if the mesh must be flagged as updatable
  108696. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108697. * @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)
  108698. * @returns a new Mesh
  108699. */
  108700. 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;
  108701. /**
  108702. * Creates lathe mesh.
  108703. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  108704. * Please consider using the same method from the MeshBuilder class instead
  108705. * @param name defines the name of the mesh to create
  108706. * @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
  108707. * @param radius is the radius value of the lathe
  108708. * @param tessellation is the side number of the lathe.
  108709. * @param scene defines the hosting scene
  108710. * @param updatable defines if the mesh must be flagged as updatable
  108711. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108712. * @returns a new Mesh
  108713. */
  108714. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108715. /**
  108716. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  108717. * @param name defines the name of the mesh to create
  108718. * @param size sets the size (float) of both sides of the plane at once (default 1)
  108719. * @param scene defines the hosting scene
  108720. * @param updatable defines if the mesh must be flagged as updatable
  108721. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108722. * @returns a new Mesh
  108723. */
  108724. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108725. /**
  108726. * Creates a ground mesh.
  108727. * Please consider using the same method from the MeshBuilder class instead
  108728. * @param name defines the name of the mesh to create
  108729. * @param width set the width of the ground
  108730. * @param height set the height of the ground
  108731. * @param subdivisions sets the number of subdivisions per side
  108732. * @param scene defines the hosting scene
  108733. * @param updatable defines if the mesh must be flagged as updatable
  108734. * @returns a new Mesh
  108735. */
  108736. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  108737. /**
  108738. * Creates a tiled ground mesh.
  108739. * Please consider using the same method from the MeshBuilder class instead
  108740. * @param name defines the name of the mesh to create
  108741. * @param xmin set the ground minimum X coordinate
  108742. * @param zmin set the ground minimum Y coordinate
  108743. * @param xmax set the ground maximum X coordinate
  108744. * @param zmax set the ground maximum Z coordinate
  108745. * @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
  108746. * @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
  108747. * @param scene defines the hosting scene
  108748. * @param updatable defines if the mesh must be flagged as updatable
  108749. * @returns a new Mesh
  108750. */
  108751. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  108752. w: number;
  108753. h: number;
  108754. }, precision: {
  108755. w: number;
  108756. h: number;
  108757. }, scene: Scene, updatable?: boolean): Mesh;
  108758. /**
  108759. * Creates a ground mesh from a height map.
  108760. * Please consider using the same method from the MeshBuilder class instead
  108761. * @see https://doc.babylonjs.com/babylon101/height_map
  108762. * @param name defines the name of the mesh to create
  108763. * @param url sets the URL of the height map image resource
  108764. * @param width set the ground width size
  108765. * @param height set the ground height size
  108766. * @param subdivisions sets the number of subdivision per side
  108767. * @param minHeight is the minimum altitude on the ground
  108768. * @param maxHeight is the maximum altitude on the ground
  108769. * @param scene defines the hosting scene
  108770. * @param updatable defines if the mesh must be flagged as updatable
  108771. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  108772. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108773. * @returns a new Mesh
  108774. */
  108775. 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;
  108776. /**
  108777. * Creates a tube mesh.
  108778. * The tube is a parametric shape.
  108779. * It has no predefined shape. Its final shape will depend on the input parameters.
  108780. * Please consider using the same method from the MeshBuilder class instead
  108781. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108782. * @param name defines the name of the mesh to create
  108783. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  108784. * @param radius sets the tube radius size
  108785. * @param tessellation is the number of sides on the tubular surface
  108786. * @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
  108787. * @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
  108788. * @param scene defines the hosting scene
  108789. * @param updatable defines if the mesh must be flagged as updatable
  108790. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108791. * @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)
  108792. * @returns a new Mesh
  108793. */
  108794. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  108795. (i: number, distance: number): number;
  108796. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108797. /**
  108798. * Creates a polyhedron mesh.
  108799. * Please consider using the same method from the MeshBuilder class instead.
  108800. * * 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
  108801. * * The parameter `size` (positive float, default 1) sets the polygon size
  108802. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108803. * * 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`
  108804. * * 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
  108805. * * 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)`)
  108806. * * 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
  108807. * * 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
  108808. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108811. * @param name defines the name of the mesh to create
  108812. * @param options defines the options used to create the mesh
  108813. * @param scene defines the hosting scene
  108814. * @returns a new Mesh
  108815. */
  108816. static CreatePolyhedron(name: string, options: {
  108817. type?: number;
  108818. size?: number;
  108819. sizeX?: number;
  108820. sizeY?: number;
  108821. sizeZ?: number;
  108822. custom?: any;
  108823. faceUV?: Vector4[];
  108824. faceColors?: Color4[];
  108825. updatable?: boolean;
  108826. sideOrientation?: number;
  108827. }, scene: Scene): Mesh;
  108828. /**
  108829. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  108830. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  108831. * * 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`)
  108832. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  108833. * * 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
  108834. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108835. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108837. * @param name defines the name of the mesh
  108838. * @param options defines the options used to create the mesh
  108839. * @param scene defines the hosting scene
  108840. * @returns a new Mesh
  108841. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  108842. */
  108843. static CreateIcoSphere(name: string, options: {
  108844. radius?: number;
  108845. flat?: boolean;
  108846. subdivisions?: number;
  108847. sideOrientation?: number;
  108848. updatable?: boolean;
  108849. }, scene: Scene): Mesh;
  108850. /**
  108851. * Creates a decal mesh.
  108852. * Please consider using the same method from the MeshBuilder class instead.
  108853. * A decal is a mesh usually applied as a model onto the surface of another mesh
  108854. * @param name defines the name of the mesh
  108855. * @param sourceMesh defines the mesh receiving the decal
  108856. * @param position sets the position of the decal in world coordinates
  108857. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  108858. * @param size sets the decal scaling
  108859. * @param angle sets the angle to rotate the decal
  108860. * @returns a new Mesh
  108861. */
  108862. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  108863. /**
  108864. * Prepare internal position array for software CPU skinning
  108865. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  108866. */
  108867. setPositionsForCPUSkinning(): Float32Array;
  108868. /**
  108869. * Prepare internal normal array for software CPU skinning
  108870. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  108871. */
  108872. setNormalsForCPUSkinning(): Float32Array;
  108873. /**
  108874. * Updates the vertex buffer by applying transformation from the bones
  108875. * @param skeleton defines the skeleton to apply to current mesh
  108876. * @returns the current mesh
  108877. */
  108878. applySkeleton(skeleton: Skeleton): Mesh;
  108879. /**
  108880. * 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
  108881. * @param meshes defines the list of meshes to scan
  108882. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  108883. */
  108884. static MinMax(meshes: AbstractMesh[]): {
  108885. min: Vector3;
  108886. max: Vector3;
  108887. };
  108888. /**
  108889. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  108890. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  108891. * @returns a vector3
  108892. */
  108893. static Center(meshesOrMinMaxVector: {
  108894. min: Vector3;
  108895. max: Vector3;
  108896. } | AbstractMesh[]): Vector3;
  108897. /**
  108898. * Merge the array of meshes into a single mesh for performance reasons.
  108899. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  108900. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  108901. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  108902. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  108903. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  108904. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  108905. * @returns a new mesh
  108906. */
  108907. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  108908. /** @hidden */
  108909. addInstance(instance: InstancedMesh): void;
  108910. /** @hidden */
  108911. removeInstance(instance: InstancedMesh): void;
  108912. }
  108913. }
  108914. declare module BABYLON {
  108915. /**
  108916. * This is the base class of all the camera used in the application.
  108917. * @see https://doc.babylonjs.com/features/cameras
  108918. */
  108919. export class Camera extends Node {
  108920. /** @hidden */
  108921. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  108922. /**
  108923. * This is the default projection mode used by the cameras.
  108924. * It helps recreating a feeling of perspective and better appreciate depth.
  108925. * This is the best way to simulate real life cameras.
  108926. */
  108927. static readonly PERSPECTIVE_CAMERA: number;
  108928. /**
  108929. * This helps creating camera with an orthographic mode.
  108930. * 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.
  108931. */
  108932. static readonly ORTHOGRAPHIC_CAMERA: number;
  108933. /**
  108934. * This is the default FOV mode for perspective cameras.
  108935. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  108936. */
  108937. static readonly FOVMODE_VERTICAL_FIXED: number;
  108938. /**
  108939. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  108940. */
  108941. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  108942. /**
  108943. * This specifies ther is no need for a camera rig.
  108944. * Basically only one eye is rendered corresponding to the camera.
  108945. */
  108946. static readonly RIG_MODE_NONE: number;
  108947. /**
  108948. * Simulates a camera Rig with one blue eye and one red eye.
  108949. * This can be use with 3d blue and red glasses.
  108950. */
  108951. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  108952. /**
  108953. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  108954. */
  108955. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  108956. /**
  108957. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  108958. */
  108959. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  108960. /**
  108961. * Defines that both eyes of the camera will be rendered over under each other.
  108962. */
  108963. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  108964. /**
  108965. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  108966. */
  108967. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  108968. /**
  108969. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  108970. */
  108971. static readonly RIG_MODE_VR: number;
  108972. /**
  108973. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  108974. */
  108975. static readonly RIG_MODE_WEBVR: number;
  108976. /**
  108977. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  108978. */
  108979. static readonly RIG_MODE_CUSTOM: number;
  108980. /**
  108981. * Defines if by default attaching controls should prevent the default javascript event to continue.
  108982. */
  108983. static ForceAttachControlToAlwaysPreventDefault: boolean;
  108984. /**
  108985. * Define the input manager associated with the camera.
  108986. */
  108987. inputs: CameraInputsManager<Camera>;
  108988. /** @hidden */
  108989. _position: Vector3;
  108990. /**
  108991. * Define the current local position of the camera in the scene
  108992. */
  108993. get position(): Vector3;
  108994. set position(newPosition: Vector3);
  108995. /**
  108996. * The vector the camera should consider as up.
  108997. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  108998. */
  108999. upVector: Vector3;
  109000. /**
  109001. * Define the current limit on the left side for an orthographic camera
  109002. * In scene unit
  109003. */
  109004. orthoLeft: Nullable<number>;
  109005. /**
  109006. * Define the current limit on the right side for an orthographic camera
  109007. * In scene unit
  109008. */
  109009. orthoRight: Nullable<number>;
  109010. /**
  109011. * Define the current limit on the bottom side for an orthographic camera
  109012. * In scene unit
  109013. */
  109014. orthoBottom: Nullable<number>;
  109015. /**
  109016. * Define the current limit on the top side for an orthographic camera
  109017. * In scene unit
  109018. */
  109019. orthoTop: Nullable<number>;
  109020. /**
  109021. * Field Of View is set in Radians. (default is 0.8)
  109022. */
  109023. fov: number;
  109024. /**
  109025. * Define the minimum distance the camera can see from.
  109026. * This is important to note that the depth buffer are not infinite and the closer it starts
  109027. * the more your scene might encounter depth fighting issue.
  109028. */
  109029. minZ: number;
  109030. /**
  109031. * Define the maximum distance the camera can see to.
  109032. * This is important to note that the depth buffer are not infinite and the further it end
  109033. * the more your scene might encounter depth fighting issue.
  109034. */
  109035. maxZ: number;
  109036. /**
  109037. * Define the default inertia of the camera.
  109038. * This helps giving a smooth feeling to the camera movement.
  109039. */
  109040. inertia: number;
  109041. /**
  109042. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  109043. */
  109044. mode: number;
  109045. /**
  109046. * Define whether the camera is intermediate.
  109047. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  109048. */
  109049. isIntermediate: boolean;
  109050. /**
  109051. * Define the viewport of the camera.
  109052. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  109053. */
  109054. viewport: Viewport;
  109055. /**
  109056. * Restricts the camera to viewing objects with the same layerMask.
  109057. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  109058. */
  109059. layerMask: number;
  109060. /**
  109061. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  109062. */
  109063. fovMode: number;
  109064. /**
  109065. * Rig mode of the camera.
  109066. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  109067. * This is normally controlled byt the camera themselves as internal use.
  109068. */
  109069. cameraRigMode: number;
  109070. /**
  109071. * Defines the distance between both "eyes" in case of a RIG
  109072. */
  109073. interaxialDistance: number;
  109074. /**
  109075. * Defines if stereoscopic rendering is done side by side or over under.
  109076. */
  109077. isStereoscopicSideBySide: boolean;
  109078. /**
  109079. * 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
  109080. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  109081. * else in the scene. (Eg. security camera)
  109082. *
  109083. * 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)
  109084. */
  109085. customRenderTargets: RenderTargetTexture[];
  109086. /**
  109087. * When set, the camera will render to this render target instead of the default canvas
  109088. *
  109089. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  109090. */
  109091. outputRenderTarget: Nullable<RenderTargetTexture>;
  109092. /**
  109093. * Observable triggered when the camera view matrix has changed.
  109094. */
  109095. onViewMatrixChangedObservable: Observable<Camera>;
  109096. /**
  109097. * Observable triggered when the camera Projection matrix has changed.
  109098. */
  109099. onProjectionMatrixChangedObservable: Observable<Camera>;
  109100. /**
  109101. * Observable triggered when the inputs have been processed.
  109102. */
  109103. onAfterCheckInputsObservable: Observable<Camera>;
  109104. /**
  109105. * Observable triggered when reset has been called and applied to the camera.
  109106. */
  109107. onRestoreStateObservable: Observable<Camera>;
  109108. /**
  109109. * Is this camera a part of a rig system?
  109110. */
  109111. isRigCamera: boolean;
  109112. /**
  109113. * If isRigCamera set to true this will be set with the parent camera.
  109114. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  109115. */
  109116. rigParent?: Camera;
  109117. /** @hidden */
  109118. _cameraRigParams: any;
  109119. /** @hidden */
  109120. _rigCameras: Camera[];
  109121. /** @hidden */
  109122. _rigPostProcess: Nullable<PostProcess>;
  109123. protected _webvrViewMatrix: Matrix;
  109124. /** @hidden */
  109125. _skipRendering: boolean;
  109126. /** @hidden */
  109127. _projectionMatrix: Matrix;
  109128. /** @hidden */
  109129. _postProcesses: Nullable<PostProcess>[];
  109130. /** @hidden */
  109131. _activeMeshes: SmartArray<AbstractMesh>;
  109132. protected _globalPosition: Vector3;
  109133. /** @hidden */
  109134. _computedViewMatrix: Matrix;
  109135. private _doNotComputeProjectionMatrix;
  109136. private _transformMatrix;
  109137. private _frustumPlanes;
  109138. private _refreshFrustumPlanes;
  109139. private _storedFov;
  109140. private _stateStored;
  109141. /**
  109142. * Instantiates a new camera object.
  109143. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  109144. * @see https://doc.babylonjs.com/features/cameras
  109145. * @param name Defines the name of the camera in the scene
  109146. * @param position Defines the position of the camera
  109147. * @param scene Defines the scene the camera belongs too
  109148. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  109149. */
  109150. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109151. /**
  109152. * Store current camera state (fov, position, etc..)
  109153. * @returns the camera
  109154. */
  109155. storeState(): Camera;
  109156. /**
  109157. * Restores the camera state values if it has been stored. You must call storeState() first
  109158. */
  109159. protected _restoreStateValues(): boolean;
  109160. /**
  109161. * Restored camera state. You must call storeState() first.
  109162. * @returns true if restored and false otherwise
  109163. */
  109164. restoreState(): boolean;
  109165. /**
  109166. * Gets the class name of the camera.
  109167. * @returns the class name
  109168. */
  109169. getClassName(): string;
  109170. /** @hidden */
  109171. readonly _isCamera: boolean;
  109172. /**
  109173. * Gets a string representation of the camera useful for debug purpose.
  109174. * @param fullDetails Defines that a more verboe level of logging is required
  109175. * @returns the string representation
  109176. */
  109177. toString(fullDetails?: boolean): string;
  109178. /**
  109179. * Gets the current world space position of the camera.
  109180. */
  109181. get globalPosition(): Vector3;
  109182. /**
  109183. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  109184. * @returns the active meshe list
  109185. */
  109186. getActiveMeshes(): SmartArray<AbstractMesh>;
  109187. /**
  109188. * Check whether a mesh is part of the current active mesh list of the camera
  109189. * @param mesh Defines the mesh to check
  109190. * @returns true if active, false otherwise
  109191. */
  109192. isActiveMesh(mesh: Mesh): boolean;
  109193. /**
  109194. * Is this camera ready to be used/rendered
  109195. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  109196. * @return true if the camera is ready
  109197. */
  109198. isReady(completeCheck?: boolean): boolean;
  109199. /** @hidden */
  109200. _initCache(): void;
  109201. /** @hidden */
  109202. _updateCache(ignoreParentClass?: boolean): void;
  109203. /** @hidden */
  109204. _isSynchronized(): boolean;
  109205. /** @hidden */
  109206. _isSynchronizedViewMatrix(): boolean;
  109207. /** @hidden */
  109208. _isSynchronizedProjectionMatrix(): boolean;
  109209. /**
  109210. * Attach the input controls to a specific dom element to get the input from.
  109211. * @param element Defines the element the controls should be listened from
  109212. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109213. */
  109214. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109215. /**
  109216. * Detach the current controls from the specified dom element.
  109217. * @param element Defines the element to stop listening the inputs from
  109218. */
  109219. detachControl(element: HTMLElement): void;
  109220. /**
  109221. * Update the camera state according to the different inputs gathered during the frame.
  109222. */
  109223. update(): void;
  109224. /** @hidden */
  109225. _checkInputs(): void;
  109226. /** @hidden */
  109227. get rigCameras(): Camera[];
  109228. /**
  109229. * Gets the post process used by the rig cameras
  109230. */
  109231. get rigPostProcess(): Nullable<PostProcess>;
  109232. /**
  109233. * Internal, gets the first post proces.
  109234. * @returns the first post process to be run on this camera.
  109235. */
  109236. _getFirstPostProcess(): Nullable<PostProcess>;
  109237. private _cascadePostProcessesToRigCams;
  109238. /**
  109239. * Attach a post process to the camera.
  109240. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109241. * @param postProcess The post process to attach to the camera
  109242. * @param insertAt The position of the post process in case several of them are in use in the scene
  109243. * @returns the position the post process has been inserted at
  109244. */
  109245. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  109246. /**
  109247. * Detach a post process to the camera.
  109248. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109249. * @param postProcess The post process to detach from the camera
  109250. */
  109251. detachPostProcess(postProcess: PostProcess): void;
  109252. /**
  109253. * Gets the current world matrix of the camera
  109254. */
  109255. getWorldMatrix(): Matrix;
  109256. /** @hidden */
  109257. _getViewMatrix(): Matrix;
  109258. /**
  109259. * Gets the current view matrix of the camera.
  109260. * @param force forces the camera to recompute the matrix without looking at the cached state
  109261. * @returns the view matrix
  109262. */
  109263. getViewMatrix(force?: boolean): Matrix;
  109264. /**
  109265. * Freeze the projection matrix.
  109266. * It will prevent the cache check of the camera projection compute and can speed up perf
  109267. * if no parameter of the camera are meant to change
  109268. * @param projection Defines manually a projection if necessary
  109269. */
  109270. freezeProjectionMatrix(projection?: Matrix): void;
  109271. /**
  109272. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  109273. */
  109274. unfreezeProjectionMatrix(): void;
  109275. /**
  109276. * Gets the current projection matrix of the camera.
  109277. * @param force forces the camera to recompute the matrix without looking at the cached state
  109278. * @returns the projection matrix
  109279. */
  109280. getProjectionMatrix(force?: boolean): Matrix;
  109281. /**
  109282. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  109283. * @returns a Matrix
  109284. */
  109285. getTransformationMatrix(): Matrix;
  109286. private _updateFrustumPlanes;
  109287. /**
  109288. * Checks if a cullable object (mesh...) is in the camera frustum
  109289. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  109290. * @param target The object to check
  109291. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  109292. * @returns true if the object is in frustum otherwise false
  109293. */
  109294. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  109295. /**
  109296. * Checks if a cullable object (mesh...) is in the camera frustum
  109297. * Unlike isInFrustum this cheks the full bounding box
  109298. * @param target The object to check
  109299. * @returns true if the object is in frustum otherwise false
  109300. */
  109301. isCompletelyInFrustum(target: ICullable): boolean;
  109302. /**
  109303. * Gets a ray in the forward direction from the camera.
  109304. * @param length Defines the length of the ray to create
  109305. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  109306. * @param origin Defines the start point of the ray which defaults to the camera position
  109307. * @returns the forward ray
  109308. */
  109309. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  109310. /**
  109311. * Gets a ray in the forward direction from the camera.
  109312. * @param refRay the ray to (re)use when setting the values
  109313. * @param length Defines the length of the ray to create
  109314. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  109315. * @param origin Defines the start point of the ray which defaults to the camera position
  109316. * @returns the forward ray
  109317. */
  109318. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  109319. /**
  109320. * Releases resources associated with this node.
  109321. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109322. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109323. */
  109324. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109325. /** @hidden */
  109326. _isLeftCamera: boolean;
  109327. /**
  109328. * Gets the left camera of a rig setup in case of Rigged Camera
  109329. */
  109330. get isLeftCamera(): boolean;
  109331. /** @hidden */
  109332. _isRightCamera: boolean;
  109333. /**
  109334. * Gets the right camera of a rig setup in case of Rigged Camera
  109335. */
  109336. get isRightCamera(): boolean;
  109337. /**
  109338. * Gets the left camera of a rig setup in case of Rigged Camera
  109339. */
  109340. get leftCamera(): Nullable<FreeCamera>;
  109341. /**
  109342. * Gets the right camera of a rig setup in case of Rigged Camera
  109343. */
  109344. get rightCamera(): Nullable<FreeCamera>;
  109345. /**
  109346. * Gets the left camera target of a rig setup in case of Rigged Camera
  109347. * @returns the target position
  109348. */
  109349. getLeftTarget(): Nullable<Vector3>;
  109350. /**
  109351. * Gets the right camera target of a rig setup in case of Rigged Camera
  109352. * @returns the target position
  109353. */
  109354. getRightTarget(): Nullable<Vector3>;
  109355. /**
  109356. * @hidden
  109357. */
  109358. setCameraRigMode(mode: number, rigParams: any): void;
  109359. /** @hidden */
  109360. static _setStereoscopicRigMode(camera: Camera): void;
  109361. /** @hidden */
  109362. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  109363. /** @hidden */
  109364. static _setVRRigMode(camera: Camera, rigParams: any): void;
  109365. /** @hidden */
  109366. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  109367. /** @hidden */
  109368. _getVRProjectionMatrix(): Matrix;
  109369. protected _updateCameraRotationMatrix(): void;
  109370. protected _updateWebVRCameraRotationMatrix(): void;
  109371. /**
  109372. * This function MUST be overwritten by the different WebVR cameras available.
  109373. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  109374. * @hidden
  109375. */
  109376. _getWebVRProjectionMatrix(): Matrix;
  109377. /**
  109378. * This function MUST be overwritten by the different WebVR cameras available.
  109379. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  109380. * @hidden
  109381. */
  109382. _getWebVRViewMatrix(): Matrix;
  109383. /** @hidden */
  109384. setCameraRigParameter(name: string, value: any): void;
  109385. /**
  109386. * needs to be overridden by children so sub has required properties to be copied
  109387. * @hidden
  109388. */
  109389. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  109390. /**
  109391. * May need to be overridden by children
  109392. * @hidden
  109393. */
  109394. _updateRigCameras(): void;
  109395. /** @hidden */
  109396. _setupInputs(): void;
  109397. /**
  109398. * Serialiaze the camera setup to a json represention
  109399. * @returns the JSON representation
  109400. */
  109401. serialize(): any;
  109402. /**
  109403. * Clones the current camera.
  109404. * @param name The cloned camera name
  109405. * @returns the cloned camera
  109406. */
  109407. clone(name: string): Camera;
  109408. /**
  109409. * Gets the direction of the camera relative to a given local axis.
  109410. * @param localAxis Defines the reference axis to provide a relative direction.
  109411. * @return the direction
  109412. */
  109413. getDirection(localAxis: Vector3): Vector3;
  109414. /**
  109415. * Returns the current camera absolute rotation
  109416. */
  109417. get absoluteRotation(): Quaternion;
  109418. /**
  109419. * Gets the direction of the camera relative to a given local axis into a passed vector.
  109420. * @param localAxis Defines the reference axis to provide a relative direction.
  109421. * @param result Defines the vector to store the result in
  109422. */
  109423. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  109424. /**
  109425. * Gets a camera constructor for a given camera type
  109426. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  109427. * @param name The name of the camera the result will be able to instantiate
  109428. * @param scene The scene the result will construct the camera in
  109429. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  109430. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  109431. * @returns a factory method to construc the camera
  109432. */
  109433. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  109434. /**
  109435. * Compute the world matrix of the camera.
  109436. * @returns the camera world matrix
  109437. */
  109438. computeWorldMatrix(): Matrix;
  109439. /**
  109440. * Parse a JSON and creates the camera from the parsed information
  109441. * @param parsedCamera The JSON to parse
  109442. * @param scene The scene to instantiate the camera in
  109443. * @returns the newly constructed camera
  109444. */
  109445. static Parse(parsedCamera: any, scene: Scene): Camera;
  109446. }
  109447. }
  109448. declare module BABYLON {
  109449. /**
  109450. * Class containing static functions to help procedurally build meshes
  109451. */
  109452. export class DiscBuilder {
  109453. /**
  109454. * Creates a plane polygonal mesh. By default, this is a disc
  109455. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109456. * * 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
  109457. * * 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
  109458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109459. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109461. * @param name defines the name of the mesh
  109462. * @param options defines the options used to create the mesh
  109463. * @param scene defines the hosting scene
  109464. * @returns the plane polygonal mesh
  109465. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109466. */
  109467. static CreateDisc(name: string, options: {
  109468. radius?: number;
  109469. tessellation?: number;
  109470. arc?: number;
  109471. updatable?: boolean;
  109472. sideOrientation?: number;
  109473. frontUVs?: Vector4;
  109474. backUVs?: Vector4;
  109475. }, scene?: Nullable<Scene>): Mesh;
  109476. }
  109477. }
  109478. declare module BABYLON {
  109479. /**
  109480. * Options to be used when creating a FresnelParameters.
  109481. */
  109482. export type IFresnelParametersCreationOptions = {
  109483. /**
  109484. * Define the color used on edges (grazing angle)
  109485. */
  109486. leftColor?: Color3;
  109487. /**
  109488. * Define the color used on center
  109489. */
  109490. rightColor?: Color3;
  109491. /**
  109492. * Define bias applied to computed fresnel term
  109493. */
  109494. bias?: number;
  109495. /**
  109496. * Defined the power exponent applied to fresnel term
  109497. */
  109498. power?: number;
  109499. /**
  109500. * Define if the fresnel effect is enable or not.
  109501. */
  109502. isEnabled?: boolean;
  109503. };
  109504. /**
  109505. * Serialized format for FresnelParameters.
  109506. */
  109507. export type IFresnelParametersSerialized = {
  109508. /**
  109509. * Define the color used on edges (grazing angle) [as an array]
  109510. */
  109511. leftColor: number[];
  109512. /**
  109513. * Define the color used on center [as an array]
  109514. */
  109515. rightColor: number[];
  109516. /**
  109517. * Define bias applied to computed fresnel term
  109518. */
  109519. bias: number;
  109520. /**
  109521. * Defined the power exponent applied to fresnel term
  109522. */
  109523. power?: number;
  109524. /**
  109525. * Define if the fresnel effect is enable or not.
  109526. */
  109527. isEnabled: boolean;
  109528. };
  109529. /**
  109530. * This represents all the required information to add a fresnel effect on a material:
  109531. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109532. */
  109533. export class FresnelParameters {
  109534. private _isEnabled;
  109535. /**
  109536. * Define if the fresnel effect is enable or not.
  109537. */
  109538. get isEnabled(): boolean;
  109539. set isEnabled(value: boolean);
  109540. /**
  109541. * Define the color used on edges (grazing angle)
  109542. */
  109543. leftColor: Color3;
  109544. /**
  109545. * Define the color used on center
  109546. */
  109547. rightColor: Color3;
  109548. /**
  109549. * Define bias applied to computed fresnel term
  109550. */
  109551. bias: number;
  109552. /**
  109553. * Defined the power exponent applied to fresnel term
  109554. */
  109555. power: number;
  109556. /**
  109557. * Creates a new FresnelParameters object.
  109558. *
  109559. * @param options provide your own settings to optionally to override defaults
  109560. */
  109561. constructor(options?: IFresnelParametersCreationOptions);
  109562. /**
  109563. * Clones the current fresnel and its valuues
  109564. * @returns a clone fresnel configuration
  109565. */
  109566. clone(): FresnelParameters;
  109567. /**
  109568. * Determines equality between FresnelParameters objects
  109569. * @param otherFresnelParameters defines the second operand
  109570. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  109571. */
  109572. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  109573. /**
  109574. * Serializes the current fresnel parameters to a JSON representation.
  109575. * @return the JSON serialization
  109576. */
  109577. serialize(): IFresnelParametersSerialized;
  109578. /**
  109579. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  109580. * @param parsedFresnelParameters Define the JSON representation
  109581. * @returns the parsed parameters
  109582. */
  109583. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  109584. }
  109585. }
  109586. declare module BABYLON {
  109587. /**
  109588. * This groups all the flags used to control the materials channel.
  109589. */
  109590. export class MaterialFlags {
  109591. private static _DiffuseTextureEnabled;
  109592. /**
  109593. * Are diffuse textures enabled in the application.
  109594. */
  109595. static get DiffuseTextureEnabled(): boolean;
  109596. static set DiffuseTextureEnabled(value: boolean);
  109597. private static _DetailTextureEnabled;
  109598. /**
  109599. * Are detail textures enabled in the application.
  109600. */
  109601. static get DetailTextureEnabled(): boolean;
  109602. static set DetailTextureEnabled(value: boolean);
  109603. private static _AmbientTextureEnabled;
  109604. /**
  109605. * Are ambient textures enabled in the application.
  109606. */
  109607. static get AmbientTextureEnabled(): boolean;
  109608. static set AmbientTextureEnabled(value: boolean);
  109609. private static _OpacityTextureEnabled;
  109610. /**
  109611. * Are opacity textures enabled in the application.
  109612. */
  109613. static get OpacityTextureEnabled(): boolean;
  109614. static set OpacityTextureEnabled(value: boolean);
  109615. private static _ReflectionTextureEnabled;
  109616. /**
  109617. * Are reflection textures enabled in the application.
  109618. */
  109619. static get ReflectionTextureEnabled(): boolean;
  109620. static set ReflectionTextureEnabled(value: boolean);
  109621. private static _EmissiveTextureEnabled;
  109622. /**
  109623. * Are emissive textures enabled in the application.
  109624. */
  109625. static get EmissiveTextureEnabled(): boolean;
  109626. static set EmissiveTextureEnabled(value: boolean);
  109627. private static _SpecularTextureEnabled;
  109628. /**
  109629. * Are specular textures enabled in the application.
  109630. */
  109631. static get SpecularTextureEnabled(): boolean;
  109632. static set SpecularTextureEnabled(value: boolean);
  109633. private static _BumpTextureEnabled;
  109634. /**
  109635. * Are bump textures enabled in the application.
  109636. */
  109637. static get BumpTextureEnabled(): boolean;
  109638. static set BumpTextureEnabled(value: boolean);
  109639. private static _LightmapTextureEnabled;
  109640. /**
  109641. * Are lightmap textures enabled in the application.
  109642. */
  109643. static get LightmapTextureEnabled(): boolean;
  109644. static set LightmapTextureEnabled(value: boolean);
  109645. private static _RefractionTextureEnabled;
  109646. /**
  109647. * Are refraction textures enabled in the application.
  109648. */
  109649. static get RefractionTextureEnabled(): boolean;
  109650. static set RefractionTextureEnabled(value: boolean);
  109651. private static _ColorGradingTextureEnabled;
  109652. /**
  109653. * Are color grading textures enabled in the application.
  109654. */
  109655. static get ColorGradingTextureEnabled(): boolean;
  109656. static set ColorGradingTextureEnabled(value: boolean);
  109657. private static _FresnelEnabled;
  109658. /**
  109659. * Are fresnels enabled in the application.
  109660. */
  109661. static get FresnelEnabled(): boolean;
  109662. static set FresnelEnabled(value: boolean);
  109663. private static _ClearCoatTextureEnabled;
  109664. /**
  109665. * Are clear coat textures enabled in the application.
  109666. */
  109667. static get ClearCoatTextureEnabled(): boolean;
  109668. static set ClearCoatTextureEnabled(value: boolean);
  109669. private static _ClearCoatBumpTextureEnabled;
  109670. /**
  109671. * Are clear coat bump textures enabled in the application.
  109672. */
  109673. static get ClearCoatBumpTextureEnabled(): boolean;
  109674. static set ClearCoatBumpTextureEnabled(value: boolean);
  109675. private static _ClearCoatTintTextureEnabled;
  109676. /**
  109677. * Are clear coat tint textures enabled in the application.
  109678. */
  109679. static get ClearCoatTintTextureEnabled(): boolean;
  109680. static set ClearCoatTintTextureEnabled(value: boolean);
  109681. private static _SheenTextureEnabled;
  109682. /**
  109683. * Are sheen textures enabled in the application.
  109684. */
  109685. static get SheenTextureEnabled(): boolean;
  109686. static set SheenTextureEnabled(value: boolean);
  109687. private static _AnisotropicTextureEnabled;
  109688. /**
  109689. * Are anisotropic textures enabled in the application.
  109690. */
  109691. static get AnisotropicTextureEnabled(): boolean;
  109692. static set AnisotropicTextureEnabled(value: boolean);
  109693. private static _ThicknessTextureEnabled;
  109694. /**
  109695. * Are thickness textures enabled in the application.
  109696. */
  109697. static get ThicknessTextureEnabled(): boolean;
  109698. static set ThicknessTextureEnabled(value: boolean);
  109699. }
  109700. }
  109701. declare module BABYLON {
  109702. /** @hidden */
  109703. export var defaultFragmentDeclaration: {
  109704. name: string;
  109705. shader: string;
  109706. };
  109707. }
  109708. declare module BABYLON {
  109709. /** @hidden */
  109710. export var defaultUboDeclaration: {
  109711. name: string;
  109712. shader: string;
  109713. };
  109714. }
  109715. declare module BABYLON {
  109716. /** @hidden */
  109717. export var prePassDeclaration: {
  109718. name: string;
  109719. shader: string;
  109720. };
  109721. }
  109722. declare module BABYLON {
  109723. /** @hidden */
  109724. export var lightFragmentDeclaration: {
  109725. name: string;
  109726. shader: string;
  109727. };
  109728. }
  109729. declare module BABYLON {
  109730. /** @hidden */
  109731. export var lightUboDeclaration: {
  109732. name: string;
  109733. shader: string;
  109734. };
  109735. }
  109736. declare module BABYLON {
  109737. /** @hidden */
  109738. export var lightsFragmentFunctions: {
  109739. name: string;
  109740. shader: string;
  109741. };
  109742. }
  109743. declare module BABYLON {
  109744. /** @hidden */
  109745. export var shadowsFragmentFunctions: {
  109746. name: string;
  109747. shader: string;
  109748. };
  109749. }
  109750. declare module BABYLON {
  109751. /** @hidden */
  109752. export var fresnelFunction: {
  109753. name: string;
  109754. shader: string;
  109755. };
  109756. }
  109757. declare module BABYLON {
  109758. /** @hidden */
  109759. export var bumpFragmentMainFunctions: {
  109760. name: string;
  109761. shader: string;
  109762. };
  109763. }
  109764. declare module BABYLON {
  109765. /** @hidden */
  109766. export var bumpFragmentFunctions: {
  109767. name: string;
  109768. shader: string;
  109769. };
  109770. }
  109771. declare module BABYLON {
  109772. /** @hidden */
  109773. export var logDepthDeclaration: {
  109774. name: string;
  109775. shader: string;
  109776. };
  109777. }
  109778. declare module BABYLON {
  109779. /** @hidden */
  109780. export var bumpFragment: {
  109781. name: string;
  109782. shader: string;
  109783. };
  109784. }
  109785. declare module BABYLON {
  109786. /** @hidden */
  109787. export var depthPrePass: {
  109788. name: string;
  109789. shader: string;
  109790. };
  109791. }
  109792. declare module BABYLON {
  109793. /** @hidden */
  109794. export var lightFragment: {
  109795. name: string;
  109796. shader: string;
  109797. };
  109798. }
  109799. declare module BABYLON {
  109800. /** @hidden */
  109801. export var logDepthFragment: {
  109802. name: string;
  109803. shader: string;
  109804. };
  109805. }
  109806. declare module BABYLON {
  109807. /** @hidden */
  109808. export var defaultPixelShader: {
  109809. name: string;
  109810. shader: string;
  109811. };
  109812. }
  109813. declare module BABYLON {
  109814. /** @hidden */
  109815. export var defaultVertexDeclaration: {
  109816. name: string;
  109817. shader: string;
  109818. };
  109819. }
  109820. declare module BABYLON {
  109821. /** @hidden */
  109822. export var bumpVertexDeclaration: {
  109823. name: string;
  109824. shader: string;
  109825. };
  109826. }
  109827. declare module BABYLON {
  109828. /** @hidden */
  109829. export var bumpVertex: {
  109830. name: string;
  109831. shader: string;
  109832. };
  109833. }
  109834. declare module BABYLON {
  109835. /** @hidden */
  109836. export var fogVertex: {
  109837. name: string;
  109838. shader: string;
  109839. };
  109840. }
  109841. declare module BABYLON {
  109842. /** @hidden */
  109843. export var shadowsVertex: {
  109844. name: string;
  109845. shader: string;
  109846. };
  109847. }
  109848. declare module BABYLON {
  109849. /** @hidden */
  109850. export var pointCloudVertex: {
  109851. name: string;
  109852. shader: string;
  109853. };
  109854. }
  109855. declare module BABYLON {
  109856. /** @hidden */
  109857. export var logDepthVertex: {
  109858. name: string;
  109859. shader: string;
  109860. };
  109861. }
  109862. declare module BABYLON {
  109863. /** @hidden */
  109864. export var defaultVertexShader: {
  109865. name: string;
  109866. shader: string;
  109867. };
  109868. }
  109869. declare module BABYLON {
  109870. /**
  109871. * @hidden
  109872. */
  109873. export interface IMaterialDetailMapDefines {
  109874. DETAIL: boolean;
  109875. DETAILDIRECTUV: number;
  109876. DETAIL_NORMALBLENDMETHOD: number;
  109877. /** @hidden */
  109878. _areTexturesDirty: boolean;
  109879. }
  109880. /**
  109881. * Define the code related to the detail map parameters of a material
  109882. *
  109883. * Inspired from:
  109884. * 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
  109885. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  109886. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  109887. */
  109888. export class DetailMapConfiguration {
  109889. private _texture;
  109890. /**
  109891. * The detail texture of the material.
  109892. */
  109893. texture: Nullable<BaseTexture>;
  109894. /**
  109895. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  109896. * Bigger values mean stronger blending
  109897. */
  109898. diffuseBlendLevel: number;
  109899. /**
  109900. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  109901. * Bigger values mean stronger blending. Only used with PBR materials
  109902. */
  109903. roughnessBlendLevel: number;
  109904. /**
  109905. * Defines how strong the bump effect from the detail map is
  109906. * Bigger values mean stronger effect
  109907. */
  109908. bumpLevel: number;
  109909. private _normalBlendMethod;
  109910. /**
  109911. * The method used to blend the bump and detail normals together
  109912. */
  109913. normalBlendMethod: number;
  109914. private _isEnabled;
  109915. /**
  109916. * Enable or disable the detail map on this material
  109917. */
  109918. isEnabled: boolean;
  109919. /** @hidden */
  109920. private _internalMarkAllSubMeshesAsTexturesDirty;
  109921. /** @hidden */
  109922. _markAllSubMeshesAsTexturesDirty(): void;
  109923. /**
  109924. * Instantiate a new detail map
  109925. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109926. */
  109927. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109928. /**
  109929. * Gets whether the submesh is ready to be used or not.
  109930. * @param defines the list of "defines" to update.
  109931. * @param scene defines the scene the material belongs to.
  109932. * @returns - boolean indicating that the submesh is ready or not.
  109933. */
  109934. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  109935. /**
  109936. * Update the defines for detail map usage
  109937. * @param defines the list of "defines" to update.
  109938. * @param scene defines the scene the material belongs to.
  109939. */
  109940. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  109941. /**
  109942. * Binds the material data.
  109943. * @param uniformBuffer defines the Uniform buffer to fill in.
  109944. * @param scene defines the scene the material belongs to.
  109945. * @param isFrozen defines whether the material is frozen or not.
  109946. */
  109947. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109948. /**
  109949. * Checks to see if a texture is used in the material.
  109950. * @param texture - Base texture to use.
  109951. * @returns - Boolean specifying if a texture is used in the material.
  109952. */
  109953. hasTexture(texture: BaseTexture): boolean;
  109954. /**
  109955. * Returns an array of the actively used textures.
  109956. * @param activeTextures Array of BaseTextures
  109957. */
  109958. getActiveTextures(activeTextures: BaseTexture[]): void;
  109959. /**
  109960. * Returns the animatable textures.
  109961. * @param animatables Array of animatable textures.
  109962. */
  109963. getAnimatables(animatables: IAnimatable[]): void;
  109964. /**
  109965. * Disposes the resources of the material.
  109966. * @param forceDisposeTextures - Forces the disposal of all textures.
  109967. */
  109968. dispose(forceDisposeTextures?: boolean): void;
  109969. /**
  109970. * Get the current class name useful for serialization or dynamic coding.
  109971. * @returns "DetailMap"
  109972. */
  109973. getClassName(): string;
  109974. /**
  109975. * Add the required uniforms to the current list.
  109976. * @param uniforms defines the current uniform list.
  109977. */
  109978. static AddUniforms(uniforms: string[]): void;
  109979. /**
  109980. * Add the required samplers to the current list.
  109981. * @param samplers defines the current sampler list.
  109982. */
  109983. static AddSamplers(samplers: string[]): void;
  109984. /**
  109985. * Add the required uniforms to the current buffer.
  109986. * @param uniformBuffer defines the current uniform buffer.
  109987. */
  109988. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109989. /**
  109990. * Makes a duplicate of the current instance into another one.
  109991. * @param detailMap define the instance where to copy the info
  109992. */
  109993. copyTo(detailMap: DetailMapConfiguration): void;
  109994. /**
  109995. * Serializes this detail map instance
  109996. * @returns - An object with the serialized instance.
  109997. */
  109998. serialize(): any;
  109999. /**
  110000. * Parses a detail map setting from a serialized object.
  110001. * @param source - Serialized object.
  110002. * @param scene Defines the scene we are parsing for
  110003. * @param rootUrl Defines the rootUrl to load from
  110004. */
  110005. parse(source: any, scene: Scene, rootUrl: string): void;
  110006. }
  110007. }
  110008. declare module BABYLON {
  110009. /** @hidden */
  110010. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  110011. MAINUV1: boolean;
  110012. MAINUV2: boolean;
  110013. DIFFUSE: boolean;
  110014. DIFFUSEDIRECTUV: number;
  110015. DETAIL: boolean;
  110016. DETAILDIRECTUV: number;
  110017. DETAIL_NORMALBLENDMETHOD: number;
  110018. AMBIENT: boolean;
  110019. AMBIENTDIRECTUV: number;
  110020. OPACITY: boolean;
  110021. OPACITYDIRECTUV: number;
  110022. OPACITYRGB: boolean;
  110023. REFLECTION: boolean;
  110024. EMISSIVE: boolean;
  110025. EMISSIVEDIRECTUV: number;
  110026. SPECULAR: boolean;
  110027. SPECULARDIRECTUV: number;
  110028. BUMP: boolean;
  110029. BUMPDIRECTUV: number;
  110030. PARALLAX: boolean;
  110031. PARALLAXOCCLUSION: boolean;
  110032. SPECULAROVERALPHA: boolean;
  110033. CLIPPLANE: boolean;
  110034. CLIPPLANE2: boolean;
  110035. CLIPPLANE3: boolean;
  110036. CLIPPLANE4: boolean;
  110037. CLIPPLANE5: boolean;
  110038. CLIPPLANE6: boolean;
  110039. ALPHATEST: boolean;
  110040. DEPTHPREPASS: boolean;
  110041. ALPHAFROMDIFFUSE: boolean;
  110042. POINTSIZE: boolean;
  110043. FOG: boolean;
  110044. SPECULARTERM: boolean;
  110045. DIFFUSEFRESNEL: boolean;
  110046. OPACITYFRESNEL: boolean;
  110047. REFLECTIONFRESNEL: boolean;
  110048. REFRACTIONFRESNEL: boolean;
  110049. EMISSIVEFRESNEL: boolean;
  110050. FRESNEL: boolean;
  110051. NORMAL: boolean;
  110052. UV1: boolean;
  110053. UV2: boolean;
  110054. VERTEXCOLOR: boolean;
  110055. VERTEXALPHA: boolean;
  110056. NUM_BONE_INFLUENCERS: number;
  110057. BonesPerMesh: number;
  110058. BONETEXTURE: boolean;
  110059. INSTANCES: boolean;
  110060. THIN_INSTANCES: boolean;
  110061. GLOSSINESS: boolean;
  110062. ROUGHNESS: boolean;
  110063. EMISSIVEASILLUMINATION: boolean;
  110064. LINKEMISSIVEWITHDIFFUSE: boolean;
  110065. REFLECTIONFRESNELFROMSPECULAR: boolean;
  110066. LIGHTMAP: boolean;
  110067. LIGHTMAPDIRECTUV: number;
  110068. OBJECTSPACE_NORMALMAP: boolean;
  110069. USELIGHTMAPASSHADOWMAP: boolean;
  110070. REFLECTIONMAP_3D: boolean;
  110071. REFLECTIONMAP_SPHERICAL: boolean;
  110072. REFLECTIONMAP_PLANAR: boolean;
  110073. REFLECTIONMAP_CUBIC: boolean;
  110074. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110075. REFLECTIONMAP_PROJECTION: boolean;
  110076. REFLECTIONMAP_SKYBOX: boolean;
  110077. REFLECTIONMAP_EXPLICIT: boolean;
  110078. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110079. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110080. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110081. INVERTCUBICMAP: boolean;
  110082. LOGARITHMICDEPTH: boolean;
  110083. REFRACTION: boolean;
  110084. REFRACTIONMAP_3D: boolean;
  110085. REFLECTIONOVERALPHA: boolean;
  110086. TWOSIDEDLIGHTING: boolean;
  110087. SHADOWFLOAT: boolean;
  110088. MORPHTARGETS: boolean;
  110089. MORPHTARGETS_NORMAL: boolean;
  110090. MORPHTARGETS_TANGENT: boolean;
  110091. MORPHTARGETS_UV: boolean;
  110092. NUM_MORPH_INFLUENCERS: number;
  110093. NONUNIFORMSCALING: boolean;
  110094. PREMULTIPLYALPHA: boolean;
  110095. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  110096. ALPHABLEND: boolean;
  110097. PREPASS: boolean;
  110098. SCENE_MRT_COUNT: number;
  110099. RGBDLIGHTMAP: boolean;
  110100. RGBDREFLECTION: boolean;
  110101. RGBDREFRACTION: boolean;
  110102. IMAGEPROCESSING: boolean;
  110103. VIGNETTE: boolean;
  110104. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110105. VIGNETTEBLENDMODEOPAQUE: boolean;
  110106. TONEMAPPING: boolean;
  110107. TONEMAPPING_ACES: boolean;
  110108. CONTRAST: boolean;
  110109. COLORCURVES: boolean;
  110110. COLORGRADING: boolean;
  110111. COLORGRADING3D: boolean;
  110112. SAMPLER3DGREENDEPTH: boolean;
  110113. SAMPLER3DBGRMAP: boolean;
  110114. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110115. MULTIVIEW: boolean;
  110116. /**
  110117. * If the reflection texture on this material is in linear color space
  110118. * @hidden
  110119. */
  110120. IS_REFLECTION_LINEAR: boolean;
  110121. /**
  110122. * If the refraction texture on this material is in linear color space
  110123. * @hidden
  110124. */
  110125. IS_REFRACTION_LINEAR: boolean;
  110126. EXPOSURE: boolean;
  110127. constructor();
  110128. setReflectionMode(modeToEnable: string): void;
  110129. }
  110130. /**
  110131. * This is the default material used in Babylon. It is the best trade off between quality
  110132. * and performances.
  110133. * @see https://doc.babylonjs.com/babylon101/materials
  110134. */
  110135. export class StandardMaterial extends PushMaterial {
  110136. private _diffuseTexture;
  110137. /**
  110138. * The basic texture of the material as viewed under a light.
  110139. */
  110140. diffuseTexture: Nullable<BaseTexture>;
  110141. private _ambientTexture;
  110142. /**
  110143. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  110144. */
  110145. ambientTexture: Nullable<BaseTexture>;
  110146. private _opacityTexture;
  110147. /**
  110148. * Define the transparency of the material from a texture.
  110149. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  110150. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  110151. */
  110152. opacityTexture: Nullable<BaseTexture>;
  110153. private _reflectionTexture;
  110154. /**
  110155. * Define the texture used to display the reflection.
  110156. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110157. */
  110158. reflectionTexture: Nullable<BaseTexture>;
  110159. private _emissiveTexture;
  110160. /**
  110161. * Define texture of the material as if self lit.
  110162. * This will be mixed in the final result even in the absence of light.
  110163. */
  110164. emissiveTexture: Nullable<BaseTexture>;
  110165. private _specularTexture;
  110166. /**
  110167. * Define how the color and intensity of the highlight given by the light in the material.
  110168. */
  110169. specularTexture: Nullable<BaseTexture>;
  110170. private _bumpTexture;
  110171. /**
  110172. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  110173. * 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.
  110174. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  110175. */
  110176. bumpTexture: Nullable<BaseTexture>;
  110177. private _lightmapTexture;
  110178. /**
  110179. * Complex lighting can be computationally expensive to compute at runtime.
  110180. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  110181. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  110182. */
  110183. lightmapTexture: Nullable<BaseTexture>;
  110184. private _refractionTexture;
  110185. /**
  110186. * Define the texture used to display the refraction.
  110187. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110188. */
  110189. refractionTexture: Nullable<BaseTexture>;
  110190. /**
  110191. * The color of the material lit by the environmental background lighting.
  110192. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  110193. */
  110194. ambientColor: Color3;
  110195. /**
  110196. * The basic color of the material as viewed under a light.
  110197. */
  110198. diffuseColor: Color3;
  110199. /**
  110200. * Define how the color and intensity of the highlight given by the light in the material.
  110201. */
  110202. specularColor: Color3;
  110203. /**
  110204. * Define the color of the material as if self lit.
  110205. * This will be mixed in the final result even in the absence of light.
  110206. */
  110207. emissiveColor: Color3;
  110208. /**
  110209. * Defines how sharp are the highlights in the material.
  110210. * The bigger the value the sharper giving a more glossy feeling to the result.
  110211. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  110212. */
  110213. specularPower: number;
  110214. private _useAlphaFromDiffuseTexture;
  110215. /**
  110216. * Does the transparency come from the diffuse texture alpha channel.
  110217. */
  110218. useAlphaFromDiffuseTexture: boolean;
  110219. private _useEmissiveAsIllumination;
  110220. /**
  110221. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  110222. */
  110223. useEmissiveAsIllumination: boolean;
  110224. private _linkEmissiveWithDiffuse;
  110225. /**
  110226. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  110227. * the emissive level when the final color is close to one.
  110228. */
  110229. linkEmissiveWithDiffuse: boolean;
  110230. private _useSpecularOverAlpha;
  110231. /**
  110232. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  110233. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110234. */
  110235. useSpecularOverAlpha: boolean;
  110236. private _useReflectionOverAlpha;
  110237. /**
  110238. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110239. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110240. */
  110241. useReflectionOverAlpha: boolean;
  110242. private _disableLighting;
  110243. /**
  110244. * Does lights from the scene impacts this material.
  110245. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  110246. */
  110247. disableLighting: boolean;
  110248. private _useObjectSpaceNormalMap;
  110249. /**
  110250. * Allows using an object space normal map (instead of tangent space).
  110251. */
  110252. useObjectSpaceNormalMap: boolean;
  110253. private _useParallax;
  110254. /**
  110255. * Is parallax enabled or not.
  110256. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  110257. */
  110258. useParallax: boolean;
  110259. private _useParallaxOcclusion;
  110260. /**
  110261. * Is parallax occlusion enabled or not.
  110262. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  110263. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  110264. */
  110265. useParallaxOcclusion: boolean;
  110266. /**
  110267. * 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.
  110268. */
  110269. parallaxScaleBias: number;
  110270. private _roughness;
  110271. /**
  110272. * Helps to define how blurry the reflections should appears in the material.
  110273. */
  110274. roughness: number;
  110275. /**
  110276. * In case of refraction, define the value of the index of refraction.
  110277. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110278. */
  110279. indexOfRefraction: number;
  110280. /**
  110281. * Invert the refraction texture alongside the y axis.
  110282. * It can be useful with procedural textures or probe for instance.
  110283. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110284. */
  110285. invertRefractionY: boolean;
  110286. /**
  110287. * Defines the alpha limits in alpha test mode.
  110288. */
  110289. alphaCutOff: number;
  110290. private _useLightmapAsShadowmap;
  110291. /**
  110292. * In case of light mapping, define whether the map contains light or shadow informations.
  110293. */
  110294. useLightmapAsShadowmap: boolean;
  110295. private _diffuseFresnelParameters;
  110296. /**
  110297. * Define the diffuse fresnel parameters of the material.
  110298. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110299. */
  110300. diffuseFresnelParameters: FresnelParameters;
  110301. private _opacityFresnelParameters;
  110302. /**
  110303. * Define the opacity fresnel parameters of the material.
  110304. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110305. */
  110306. opacityFresnelParameters: FresnelParameters;
  110307. private _reflectionFresnelParameters;
  110308. /**
  110309. * Define the reflection fresnel parameters of the material.
  110310. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110311. */
  110312. reflectionFresnelParameters: FresnelParameters;
  110313. private _refractionFresnelParameters;
  110314. /**
  110315. * Define the refraction fresnel parameters of the material.
  110316. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110317. */
  110318. refractionFresnelParameters: FresnelParameters;
  110319. private _emissiveFresnelParameters;
  110320. /**
  110321. * Define the emissive fresnel parameters of the material.
  110322. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110323. */
  110324. emissiveFresnelParameters: FresnelParameters;
  110325. private _useReflectionFresnelFromSpecular;
  110326. /**
  110327. * If true automatically deducts the fresnels values from the material specularity.
  110328. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110329. */
  110330. useReflectionFresnelFromSpecular: boolean;
  110331. private _useGlossinessFromSpecularMapAlpha;
  110332. /**
  110333. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  110334. */
  110335. useGlossinessFromSpecularMapAlpha: boolean;
  110336. private _maxSimultaneousLights;
  110337. /**
  110338. * Defines the maximum number of lights that can be used in the material
  110339. */
  110340. maxSimultaneousLights: number;
  110341. private _invertNormalMapX;
  110342. /**
  110343. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  110344. */
  110345. invertNormalMapX: boolean;
  110346. private _invertNormalMapY;
  110347. /**
  110348. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  110349. */
  110350. invertNormalMapY: boolean;
  110351. private _twoSidedLighting;
  110352. /**
  110353. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110354. */
  110355. twoSidedLighting: boolean;
  110356. /**
  110357. * Default configuration related to image processing available in the standard Material.
  110358. */
  110359. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110360. /**
  110361. * Gets the image processing configuration used either in this material.
  110362. */
  110363. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  110364. /**
  110365. * Sets the Default image processing configuration used either in the this material.
  110366. *
  110367. * If sets to null, the scene one is in use.
  110368. */
  110369. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  110370. /**
  110371. * Keep track of the image processing observer to allow dispose and replace.
  110372. */
  110373. private _imageProcessingObserver;
  110374. /**
  110375. * Attaches a new image processing configuration to the Standard Material.
  110376. * @param configuration
  110377. */
  110378. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110379. /**
  110380. * Gets wether the color curves effect is enabled.
  110381. */
  110382. get cameraColorCurvesEnabled(): boolean;
  110383. /**
  110384. * Sets wether the color curves effect is enabled.
  110385. */
  110386. set cameraColorCurvesEnabled(value: boolean);
  110387. /**
  110388. * Gets wether the color grading effect is enabled.
  110389. */
  110390. get cameraColorGradingEnabled(): boolean;
  110391. /**
  110392. * Gets wether the color grading effect is enabled.
  110393. */
  110394. set cameraColorGradingEnabled(value: boolean);
  110395. /**
  110396. * Gets wether tonemapping is enabled or not.
  110397. */
  110398. get cameraToneMappingEnabled(): boolean;
  110399. /**
  110400. * Sets wether tonemapping is enabled or not
  110401. */
  110402. set cameraToneMappingEnabled(value: boolean);
  110403. /**
  110404. * The camera exposure used on this material.
  110405. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110406. * This corresponds to a photographic exposure.
  110407. */
  110408. get cameraExposure(): number;
  110409. /**
  110410. * The camera exposure used on this material.
  110411. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110412. * This corresponds to a photographic exposure.
  110413. */
  110414. set cameraExposure(value: number);
  110415. /**
  110416. * Gets The camera contrast used on this material.
  110417. */
  110418. get cameraContrast(): number;
  110419. /**
  110420. * Sets The camera contrast used on this material.
  110421. */
  110422. set cameraContrast(value: number);
  110423. /**
  110424. * Gets the Color Grading 2D Lookup Texture.
  110425. */
  110426. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  110427. /**
  110428. * Sets the Color Grading 2D Lookup Texture.
  110429. */
  110430. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  110431. /**
  110432. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110433. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110434. * 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;
  110435. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110436. */
  110437. get cameraColorCurves(): Nullable<ColorCurves>;
  110438. /**
  110439. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110440. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110441. * 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;
  110442. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110443. */
  110444. set cameraColorCurves(value: Nullable<ColorCurves>);
  110445. /**
  110446. * Can this material render to several textures at once
  110447. */
  110448. get canRenderToMRT(): boolean;
  110449. /**
  110450. * Defines the detail map parameters for the material.
  110451. */
  110452. readonly detailMap: DetailMapConfiguration;
  110453. protected _renderTargets: SmartArray<RenderTargetTexture>;
  110454. protected _worldViewProjectionMatrix: Matrix;
  110455. protected _globalAmbientColor: Color3;
  110456. protected _useLogarithmicDepth: boolean;
  110457. protected _rebuildInParallel: boolean;
  110458. /**
  110459. * Instantiates a new standard material.
  110460. * This is the default material used in Babylon. It is the best trade off between quality
  110461. * and performances.
  110462. * @see https://doc.babylonjs.com/babylon101/materials
  110463. * @param name Define the name of the material in the scene
  110464. * @param scene Define the scene the material belong to
  110465. */
  110466. constructor(name: string, scene: Scene);
  110467. /**
  110468. * Gets a boolean indicating that current material needs to register RTT
  110469. */
  110470. get hasRenderTargetTextures(): boolean;
  110471. /**
  110472. * Gets the current class name of the material e.g. "StandardMaterial"
  110473. * Mainly use in serialization.
  110474. * @returns the class name
  110475. */
  110476. getClassName(): string;
  110477. /**
  110478. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  110479. * You can try switching to logarithmic depth.
  110480. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  110481. */
  110482. get useLogarithmicDepth(): boolean;
  110483. set useLogarithmicDepth(value: boolean);
  110484. /**
  110485. * Specifies if the material will require alpha blending
  110486. * @returns a boolean specifying if alpha blending is needed
  110487. */
  110488. needAlphaBlending(): boolean;
  110489. /**
  110490. * Specifies if this material should be rendered in alpha test mode
  110491. * @returns a boolean specifying if an alpha test is needed.
  110492. */
  110493. needAlphaTesting(): boolean;
  110494. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  110495. /**
  110496. * Get the texture used for alpha test purpose.
  110497. * @returns the diffuse texture in case of the standard material.
  110498. */
  110499. getAlphaTestTexture(): Nullable<BaseTexture>;
  110500. /**
  110501. * Get if the submesh is ready to be used and all its information available.
  110502. * Child classes can use it to update shaders
  110503. * @param mesh defines the mesh to check
  110504. * @param subMesh defines which submesh to check
  110505. * @param useInstances specifies that instances should be used
  110506. * @returns a boolean indicating that the submesh is ready or not
  110507. */
  110508. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110509. /**
  110510. * Builds the material UBO layouts.
  110511. * Used internally during the effect preparation.
  110512. */
  110513. buildUniformLayout(): void;
  110514. /**
  110515. * Unbinds the material from the mesh
  110516. */
  110517. unbind(): void;
  110518. /**
  110519. * Binds the submesh to this material by preparing the effect and shader to draw
  110520. * @param world defines the world transformation matrix
  110521. * @param mesh defines the mesh containing the submesh
  110522. * @param subMesh defines the submesh to bind the material to
  110523. */
  110524. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110525. /**
  110526. * Get the list of animatables in the material.
  110527. * @returns the list of animatables object used in the material
  110528. */
  110529. getAnimatables(): IAnimatable[];
  110530. /**
  110531. * Gets the active textures from the material
  110532. * @returns an array of textures
  110533. */
  110534. getActiveTextures(): BaseTexture[];
  110535. /**
  110536. * Specifies if the material uses a texture
  110537. * @param texture defines the texture to check against the material
  110538. * @returns a boolean specifying if the material uses the texture
  110539. */
  110540. hasTexture(texture: BaseTexture): boolean;
  110541. /**
  110542. * Disposes the material
  110543. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110544. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110545. */
  110546. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110547. /**
  110548. * Makes a duplicate of the material, and gives it a new name
  110549. * @param name defines the new name for the duplicated material
  110550. * @returns the cloned material
  110551. */
  110552. clone(name: string): StandardMaterial;
  110553. /**
  110554. * Serializes this material in a JSON representation
  110555. * @returns the serialized material object
  110556. */
  110557. serialize(): any;
  110558. /**
  110559. * Creates a standard material from parsed material data
  110560. * @param source defines the JSON representation of the material
  110561. * @param scene defines the hosting scene
  110562. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  110563. * @returns a new standard material
  110564. */
  110565. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  110566. /**
  110567. * Are diffuse textures enabled in the application.
  110568. */
  110569. static get DiffuseTextureEnabled(): boolean;
  110570. static set DiffuseTextureEnabled(value: boolean);
  110571. /**
  110572. * Are detail textures enabled in the application.
  110573. */
  110574. static get DetailTextureEnabled(): boolean;
  110575. static set DetailTextureEnabled(value: boolean);
  110576. /**
  110577. * Are ambient textures enabled in the application.
  110578. */
  110579. static get AmbientTextureEnabled(): boolean;
  110580. static set AmbientTextureEnabled(value: boolean);
  110581. /**
  110582. * Are opacity textures enabled in the application.
  110583. */
  110584. static get OpacityTextureEnabled(): boolean;
  110585. static set OpacityTextureEnabled(value: boolean);
  110586. /**
  110587. * Are reflection textures enabled in the application.
  110588. */
  110589. static get ReflectionTextureEnabled(): boolean;
  110590. static set ReflectionTextureEnabled(value: boolean);
  110591. /**
  110592. * Are emissive textures enabled in the application.
  110593. */
  110594. static get EmissiveTextureEnabled(): boolean;
  110595. static set EmissiveTextureEnabled(value: boolean);
  110596. /**
  110597. * Are specular textures enabled in the application.
  110598. */
  110599. static get SpecularTextureEnabled(): boolean;
  110600. static set SpecularTextureEnabled(value: boolean);
  110601. /**
  110602. * Are bump textures enabled in the application.
  110603. */
  110604. static get BumpTextureEnabled(): boolean;
  110605. static set BumpTextureEnabled(value: boolean);
  110606. /**
  110607. * Are lightmap textures enabled in the application.
  110608. */
  110609. static get LightmapTextureEnabled(): boolean;
  110610. static set LightmapTextureEnabled(value: boolean);
  110611. /**
  110612. * Are refraction textures enabled in the application.
  110613. */
  110614. static get RefractionTextureEnabled(): boolean;
  110615. static set RefractionTextureEnabled(value: boolean);
  110616. /**
  110617. * Are color grading textures enabled in the application.
  110618. */
  110619. static get ColorGradingTextureEnabled(): boolean;
  110620. static set ColorGradingTextureEnabled(value: boolean);
  110621. /**
  110622. * Are fresnels enabled in the application.
  110623. */
  110624. static get FresnelEnabled(): boolean;
  110625. static set FresnelEnabled(value: boolean);
  110626. }
  110627. }
  110628. declare module BABYLON {
  110629. /**
  110630. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  110631. *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.
  110632. * The SPS is also a particle system. It provides some methods to manage the particles.
  110633. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  110634. *
  110635. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  110636. */
  110637. export class SolidParticleSystem implements IDisposable {
  110638. /**
  110639. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  110640. * Example : var p = SPS.particles[i];
  110641. */
  110642. particles: SolidParticle[];
  110643. /**
  110644. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  110645. */
  110646. nbParticles: number;
  110647. /**
  110648. * If the particles must ever face the camera (default false). Useful for planar particles.
  110649. */
  110650. billboard: boolean;
  110651. /**
  110652. * Recompute normals when adding a shape
  110653. */
  110654. recomputeNormals: boolean;
  110655. /**
  110656. * This a counter ofr your own usage. It's not set by any SPS functions.
  110657. */
  110658. counter: number;
  110659. /**
  110660. * The SPS name. This name is also given to the underlying mesh.
  110661. */
  110662. name: string;
  110663. /**
  110664. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  110665. */
  110666. mesh: Mesh;
  110667. /**
  110668. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  110669. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  110670. */
  110671. vars: any;
  110672. /**
  110673. * This array is populated when the SPS is set as 'pickable'.
  110674. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  110675. * Each element of this array is an object `{idx: int, faceId: int}`.
  110676. * `idx` is the picked particle index in the `SPS.particles` array
  110677. * `faceId` is the picked face index counted within this particle.
  110678. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  110679. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  110680. * Use the method SPS.pickedParticle(pickingInfo) instead.
  110681. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  110682. */
  110683. pickedParticles: {
  110684. idx: number;
  110685. faceId: number;
  110686. }[];
  110687. /**
  110688. * This array is populated when the SPS is set as 'pickable'
  110689. * Each key of this array is a submesh index.
  110690. * Each element of this array is a second array defined like this :
  110691. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  110692. * Each element of this second array is an object `{idx: int, faceId: int}`.
  110693. * `idx` is the picked particle index in the `SPS.particles` array
  110694. * `faceId` is the picked face index counted within this particle.
  110695. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  110696. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  110697. */
  110698. pickedBySubMesh: {
  110699. idx: number;
  110700. faceId: number;
  110701. }[][];
  110702. /**
  110703. * This array is populated when `enableDepthSort` is set to true.
  110704. * Each element of this array is an instance of the class DepthSortedParticle.
  110705. */
  110706. depthSortedParticles: DepthSortedParticle[];
  110707. /**
  110708. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  110709. * @hidden
  110710. */
  110711. _bSphereOnly: boolean;
  110712. /**
  110713. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  110714. * @hidden
  110715. */
  110716. _bSphereRadiusFactor: number;
  110717. private _scene;
  110718. private _positions;
  110719. private _indices;
  110720. private _normals;
  110721. private _colors;
  110722. private _uvs;
  110723. private _indices32;
  110724. private _positions32;
  110725. private _normals32;
  110726. private _fixedNormal32;
  110727. private _colors32;
  110728. private _uvs32;
  110729. private _index;
  110730. private _updatable;
  110731. private _pickable;
  110732. private _isVisibilityBoxLocked;
  110733. private _alwaysVisible;
  110734. private _depthSort;
  110735. private _expandable;
  110736. private _shapeCounter;
  110737. private _copy;
  110738. private _color;
  110739. private _computeParticleColor;
  110740. private _computeParticleTexture;
  110741. private _computeParticleRotation;
  110742. private _computeParticleVertex;
  110743. private _computeBoundingBox;
  110744. private _depthSortParticles;
  110745. private _camera;
  110746. private _mustUnrotateFixedNormals;
  110747. private _particlesIntersect;
  110748. private _needs32Bits;
  110749. private _isNotBuilt;
  110750. private _lastParticleId;
  110751. private _idxOfId;
  110752. private _multimaterialEnabled;
  110753. private _useModelMaterial;
  110754. private _indicesByMaterial;
  110755. private _materialIndexes;
  110756. private _depthSortFunction;
  110757. private _materialSortFunction;
  110758. private _materials;
  110759. private _multimaterial;
  110760. private _materialIndexesById;
  110761. private _defaultMaterial;
  110762. private _autoUpdateSubMeshes;
  110763. private _tmpVertex;
  110764. /**
  110765. * Creates a SPS (Solid Particle System) object.
  110766. * @param name (String) is the SPS name, this will be the underlying mesh name.
  110767. * @param scene (Scene) is the scene in which the SPS is added.
  110768. * @param options defines the options of the sps e.g.
  110769. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  110770. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  110771. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  110772. * * 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.
  110773. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  110774. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  110775. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  110776. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  110777. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  110778. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  110779. */
  110780. constructor(name: string, scene: Scene, options?: {
  110781. updatable?: boolean;
  110782. isPickable?: boolean;
  110783. enableDepthSort?: boolean;
  110784. particleIntersection?: boolean;
  110785. boundingSphereOnly?: boolean;
  110786. bSphereRadiusFactor?: number;
  110787. expandable?: boolean;
  110788. useModelMaterial?: boolean;
  110789. enableMultiMaterial?: boolean;
  110790. });
  110791. /**
  110792. * Builds the SPS underlying mesh. Returns a standard Mesh.
  110793. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  110794. * @returns the created mesh
  110795. */
  110796. buildMesh(): Mesh;
  110797. /**
  110798. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  110799. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  110800. * Thus the particles generated from `digest()` have their property `position` set yet.
  110801. * @param mesh ( Mesh ) is the mesh to be digested
  110802. * @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
  110803. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  110804. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  110805. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  110806. * @returns the current SPS
  110807. */
  110808. digest(mesh: Mesh, options?: {
  110809. facetNb?: number;
  110810. number?: number;
  110811. delta?: number;
  110812. storage?: [];
  110813. }): SolidParticleSystem;
  110814. /**
  110815. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  110816. * @hidden
  110817. */
  110818. private _unrotateFixedNormals;
  110819. /**
  110820. * Resets the temporary working copy particle
  110821. * @hidden
  110822. */
  110823. private _resetCopy;
  110824. /**
  110825. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  110826. * @param p the current index in the positions array to be updated
  110827. * @param ind the current index in the indices array
  110828. * @param shape a Vector3 array, the shape geometry
  110829. * @param positions the positions array to be updated
  110830. * @param meshInd the shape indices array
  110831. * @param indices the indices array to be updated
  110832. * @param meshUV the shape uv array
  110833. * @param uvs the uv array to be updated
  110834. * @param meshCol the shape color array
  110835. * @param colors the color array to be updated
  110836. * @param meshNor the shape normals array
  110837. * @param normals the normals array to be updated
  110838. * @param idx the particle index
  110839. * @param idxInShape the particle index in its shape
  110840. * @param options the addShape() method passed options
  110841. * @model the particle model
  110842. * @hidden
  110843. */
  110844. private _meshBuilder;
  110845. /**
  110846. * Returns a shape Vector3 array from positions float array
  110847. * @param positions float array
  110848. * @returns a vector3 array
  110849. * @hidden
  110850. */
  110851. private _posToShape;
  110852. /**
  110853. * Returns a shapeUV array from a float uvs (array deep copy)
  110854. * @param uvs as a float array
  110855. * @returns a shapeUV array
  110856. * @hidden
  110857. */
  110858. private _uvsToShapeUV;
  110859. /**
  110860. * Adds a new particle object in the particles array
  110861. * @param idx particle index in particles array
  110862. * @param id particle id
  110863. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  110864. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  110865. * @param model particle ModelShape object
  110866. * @param shapeId model shape identifier
  110867. * @param idxInShape index of the particle in the current model
  110868. * @param bInfo model bounding info object
  110869. * @param storage target storage array, if any
  110870. * @hidden
  110871. */
  110872. private _addParticle;
  110873. /**
  110874. * Adds some particles to the SPS from the model shape. Returns the shape id.
  110875. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  110876. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  110877. * @param nb (positive integer) the number of particles to be created from this model
  110878. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  110879. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  110880. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  110881. * @returns the number of shapes in the system
  110882. */
  110883. addShape(mesh: Mesh, nb: number, options?: {
  110884. positionFunction?: any;
  110885. vertexFunction?: any;
  110886. storage?: [];
  110887. }): number;
  110888. /**
  110889. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  110890. * @hidden
  110891. */
  110892. private _rebuildParticle;
  110893. /**
  110894. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  110895. * @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.
  110896. * @returns the SPS.
  110897. */
  110898. rebuildMesh(reset?: boolean): SolidParticleSystem;
  110899. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  110900. * Returns an array with the removed particles.
  110901. * 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.
  110902. * The SPS can't be empty so at least one particle needs to remain in place.
  110903. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  110904. * @param start index of the first particle to remove
  110905. * @param end index of the last particle to remove (included)
  110906. * @returns an array populated with the removed particles
  110907. */
  110908. removeParticles(start: number, end: number): SolidParticle[];
  110909. /**
  110910. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  110911. * @param solidParticleArray an array populated with Solid Particles objects
  110912. * @returns the SPS
  110913. */
  110914. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  110915. /**
  110916. * Creates a new particle and modifies the SPS mesh geometry :
  110917. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  110918. * - calls _addParticle() to populate the particle array
  110919. * factorized code from addShape() and insertParticlesFromArray()
  110920. * @param idx particle index in the particles array
  110921. * @param i particle index in its shape
  110922. * @param modelShape particle ModelShape object
  110923. * @param shape shape vertex array
  110924. * @param meshInd shape indices array
  110925. * @param meshUV shape uv array
  110926. * @param meshCol shape color array
  110927. * @param meshNor shape normals array
  110928. * @param bbInfo shape bounding info
  110929. * @param storage target particle storage
  110930. * @options addShape() passed options
  110931. * @hidden
  110932. */
  110933. private _insertNewParticle;
  110934. /**
  110935. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  110936. * This method calls `updateParticle()` for each particle of the SPS.
  110937. * For an animated SPS, it is usually called within the render loop.
  110938. * 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.
  110939. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  110940. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  110941. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  110942. * @returns the SPS.
  110943. */
  110944. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  110945. /**
  110946. * Disposes the SPS.
  110947. */
  110948. dispose(): void;
  110949. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  110950. * idx is the particle index in the SPS
  110951. * faceId is the picked face index counted within this particle.
  110952. * Returns null if the pickInfo can't identify a picked particle.
  110953. * @param pickingInfo (PickingInfo object)
  110954. * @returns {idx: number, faceId: number} or null
  110955. */
  110956. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  110957. idx: number;
  110958. faceId: number;
  110959. }>;
  110960. /**
  110961. * Returns a SolidParticle object from its identifier : particle.id
  110962. * @param id (integer) the particle Id
  110963. * @returns the searched particle or null if not found in the SPS.
  110964. */
  110965. getParticleById(id: number): Nullable<SolidParticle>;
  110966. /**
  110967. * Returns a new array populated with the particles having the passed shapeId.
  110968. * @param shapeId (integer) the shape identifier
  110969. * @returns a new solid particle array
  110970. */
  110971. getParticlesByShapeId(shapeId: number): SolidParticle[];
  110972. /**
  110973. * Populates the passed array "ref" with the particles having the passed shapeId.
  110974. * @param shapeId the shape identifier
  110975. * @returns the SPS
  110976. * @param ref
  110977. */
  110978. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  110979. /**
  110980. * Computes the required SubMeshes according the materials assigned to the particles.
  110981. * @returns the solid particle system.
  110982. * Does nothing if called before the SPS mesh is built.
  110983. */
  110984. computeSubMeshes(): SolidParticleSystem;
  110985. /**
  110986. * Sorts the solid particles by material when MultiMaterial is enabled.
  110987. * Updates the indices32 array.
  110988. * Updates the indicesByMaterial array.
  110989. * Updates the mesh indices array.
  110990. * @returns the SPS
  110991. * @hidden
  110992. */
  110993. private _sortParticlesByMaterial;
  110994. /**
  110995. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  110996. * @hidden
  110997. */
  110998. private _setMaterialIndexesById;
  110999. /**
  111000. * Returns an array with unique values of Materials from the passed array
  111001. * @param array the material array to be checked and filtered
  111002. * @hidden
  111003. */
  111004. private _filterUniqueMaterialId;
  111005. /**
  111006. * Sets a new Standard Material as _defaultMaterial if not already set.
  111007. * @hidden
  111008. */
  111009. private _setDefaultMaterial;
  111010. /**
  111011. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  111012. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111013. * @returns the SPS.
  111014. */
  111015. refreshVisibleSize(): SolidParticleSystem;
  111016. /**
  111017. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  111018. * @param size the size (float) of the visibility box
  111019. * note : this doesn't lock the SPS mesh bounding box.
  111020. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111021. */
  111022. setVisibilityBox(size: number): void;
  111023. /**
  111024. * Gets whether the SPS as always visible or not
  111025. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111026. */
  111027. get isAlwaysVisible(): boolean;
  111028. /**
  111029. * Sets the SPS as always visible or not
  111030. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111031. */
  111032. set isAlwaysVisible(val: boolean);
  111033. /**
  111034. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111035. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111036. */
  111037. set isVisibilityBoxLocked(val: boolean);
  111038. /**
  111039. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111040. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111041. */
  111042. get isVisibilityBoxLocked(): boolean;
  111043. /**
  111044. * Tells to `setParticles()` to compute the particle rotations or not.
  111045. * Default value : true. The SPS is faster when it's set to false.
  111046. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111047. */
  111048. set computeParticleRotation(val: boolean);
  111049. /**
  111050. * Tells to `setParticles()` to compute the particle colors or not.
  111051. * Default value : true. The SPS is faster when it's set to false.
  111052. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111053. */
  111054. set computeParticleColor(val: boolean);
  111055. set computeParticleTexture(val: boolean);
  111056. /**
  111057. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  111058. * Default value : false. The SPS is faster when it's set to false.
  111059. * Note : the particle custom vertex positions aren't stored values.
  111060. */
  111061. set computeParticleVertex(val: boolean);
  111062. /**
  111063. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  111064. */
  111065. set computeBoundingBox(val: boolean);
  111066. /**
  111067. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  111068. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111069. * Default : `true`
  111070. */
  111071. set depthSortParticles(val: boolean);
  111072. /**
  111073. * Gets if `setParticles()` computes the particle rotations or not.
  111074. * Default value : true. The SPS is faster when it's set to false.
  111075. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111076. */
  111077. get computeParticleRotation(): boolean;
  111078. /**
  111079. * Gets if `setParticles()` computes the particle colors or not.
  111080. * Default value : true. The SPS is faster when it's set to false.
  111081. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111082. */
  111083. get computeParticleColor(): boolean;
  111084. /**
  111085. * Gets if `setParticles()` computes the particle textures or not.
  111086. * Default value : true. The SPS is faster when it's set to false.
  111087. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  111088. */
  111089. get computeParticleTexture(): boolean;
  111090. /**
  111091. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  111092. * Default value : false. The SPS is faster when it's set to false.
  111093. * Note : the particle custom vertex positions aren't stored values.
  111094. */
  111095. get computeParticleVertex(): boolean;
  111096. /**
  111097. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  111098. */
  111099. get computeBoundingBox(): boolean;
  111100. /**
  111101. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  111102. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111103. * Default : `true`
  111104. */
  111105. get depthSortParticles(): boolean;
  111106. /**
  111107. * Gets if the SPS is created as expandable at construction time.
  111108. * Default : `false`
  111109. */
  111110. get expandable(): boolean;
  111111. /**
  111112. * Gets if the SPS supports the Multi Materials
  111113. */
  111114. get multimaterialEnabled(): boolean;
  111115. /**
  111116. * Gets if the SPS uses the model materials for its own multimaterial.
  111117. */
  111118. get useModelMaterial(): boolean;
  111119. /**
  111120. * The SPS used material array.
  111121. */
  111122. get materials(): Material[];
  111123. /**
  111124. * Sets the SPS MultiMaterial from the passed materials.
  111125. * Note : the passed array is internally copied and not used then by reference.
  111126. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  111127. */
  111128. setMultiMaterial(materials: Material[]): void;
  111129. /**
  111130. * The SPS computed multimaterial object
  111131. */
  111132. get multimaterial(): MultiMaterial;
  111133. set multimaterial(mm: MultiMaterial);
  111134. /**
  111135. * If the subMeshes must be updated on the next call to setParticles()
  111136. */
  111137. get autoUpdateSubMeshes(): boolean;
  111138. set autoUpdateSubMeshes(val: boolean);
  111139. /**
  111140. * This function does nothing. It may be overwritten to set all the particle first values.
  111141. * The SPS doesn't call this function, you may have to call it by your own.
  111142. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111143. */
  111144. initParticles(): void;
  111145. /**
  111146. * This function does nothing. It may be overwritten to recycle a particle.
  111147. * The SPS doesn't call this function, you may have to call it by your own.
  111148. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111149. * @param particle The particle to recycle
  111150. * @returns the recycled particle
  111151. */
  111152. recycleParticle(particle: SolidParticle): SolidParticle;
  111153. /**
  111154. * Updates a particle : this function should be overwritten by the user.
  111155. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  111156. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111157. * @example : just set a particle position or velocity and recycle conditions
  111158. * @param particle The particle to update
  111159. * @returns the updated particle
  111160. */
  111161. updateParticle(particle: SolidParticle): SolidParticle;
  111162. /**
  111163. * Updates a vertex of a particle : it can be overwritten by the user.
  111164. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  111165. * @param particle the current particle
  111166. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  111167. * @param pt the index of the current vertex in the particle shape
  111168. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  111169. * @example : just set a vertex particle position or color
  111170. * @returns the sps
  111171. */
  111172. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  111173. /**
  111174. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  111175. * This does nothing and may be overwritten by the user.
  111176. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111177. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111178. * @param update the boolean update value actually passed to setParticles()
  111179. */
  111180. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111181. /**
  111182. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  111183. * This will be passed three parameters.
  111184. * This does nothing and may be overwritten by the user.
  111185. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111186. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111187. * @param update the boolean update value actually passed to setParticles()
  111188. */
  111189. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111190. }
  111191. }
  111192. declare module BABYLON {
  111193. /**
  111194. * Represents one particle of a solid particle system.
  111195. */
  111196. export class SolidParticle {
  111197. /**
  111198. * particle global index
  111199. */
  111200. idx: number;
  111201. /**
  111202. * particle identifier
  111203. */
  111204. id: number;
  111205. /**
  111206. * The color of the particle
  111207. */
  111208. color: Nullable<Color4>;
  111209. /**
  111210. * The world space position of the particle.
  111211. */
  111212. position: Vector3;
  111213. /**
  111214. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  111215. */
  111216. rotation: Vector3;
  111217. /**
  111218. * The world space rotation quaternion of the particle.
  111219. */
  111220. rotationQuaternion: Nullable<Quaternion>;
  111221. /**
  111222. * The scaling of the particle.
  111223. */
  111224. scaling: Vector3;
  111225. /**
  111226. * The uvs of the particle.
  111227. */
  111228. uvs: Vector4;
  111229. /**
  111230. * The current speed of the particle.
  111231. */
  111232. velocity: Vector3;
  111233. /**
  111234. * The pivot point in the particle local space.
  111235. */
  111236. pivot: Vector3;
  111237. /**
  111238. * Must the particle be translated from its pivot point in its local space ?
  111239. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  111240. * Default : false
  111241. */
  111242. translateFromPivot: boolean;
  111243. /**
  111244. * Is the particle active or not ?
  111245. */
  111246. alive: boolean;
  111247. /**
  111248. * Is the particle visible or not ?
  111249. */
  111250. isVisible: boolean;
  111251. /**
  111252. * Index of this particle in the global "positions" array (Internal use)
  111253. * @hidden
  111254. */
  111255. _pos: number;
  111256. /**
  111257. * @hidden Index of this particle in the global "indices" array (Internal use)
  111258. */
  111259. _ind: number;
  111260. /**
  111261. * @hidden ModelShape of this particle (Internal use)
  111262. */
  111263. _model: ModelShape;
  111264. /**
  111265. * ModelShape id of this particle
  111266. */
  111267. shapeId: number;
  111268. /**
  111269. * Index of the particle in its shape id
  111270. */
  111271. idxInShape: number;
  111272. /**
  111273. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  111274. */
  111275. _modelBoundingInfo: BoundingInfo;
  111276. /**
  111277. * @hidden Particle BoundingInfo object (Internal use)
  111278. */
  111279. _boundingInfo: BoundingInfo;
  111280. /**
  111281. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  111282. */
  111283. _sps: SolidParticleSystem;
  111284. /**
  111285. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  111286. */
  111287. _stillInvisible: boolean;
  111288. /**
  111289. * @hidden Last computed particle rotation matrix
  111290. */
  111291. _rotationMatrix: number[];
  111292. /**
  111293. * Parent particle Id, if any.
  111294. * Default null.
  111295. */
  111296. parentId: Nullable<number>;
  111297. /**
  111298. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  111299. */
  111300. materialIndex: Nullable<number>;
  111301. /**
  111302. * Custom object or properties.
  111303. */
  111304. props: Nullable<any>;
  111305. /**
  111306. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  111307. * The possible values are :
  111308. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  111309. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111310. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  111311. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  111312. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111313. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  111314. * */
  111315. cullingStrategy: number;
  111316. /**
  111317. * @hidden Internal global position in the SPS.
  111318. */
  111319. _globalPosition: Vector3;
  111320. /**
  111321. * Creates a Solid Particle object.
  111322. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  111323. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  111324. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  111325. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  111326. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  111327. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  111328. * @param shapeId (integer) is the model shape identifier in the SPS.
  111329. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  111330. * @param sps defines the sps it is associated to
  111331. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  111332. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  111333. */
  111334. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  111335. /**
  111336. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  111337. * @param target the particle target
  111338. * @returns the current particle
  111339. */
  111340. copyToRef(target: SolidParticle): SolidParticle;
  111341. /**
  111342. * Legacy support, changed scale to scaling
  111343. */
  111344. get scale(): Vector3;
  111345. /**
  111346. * Legacy support, changed scale to scaling
  111347. */
  111348. set scale(scale: Vector3);
  111349. /**
  111350. * Legacy support, changed quaternion to rotationQuaternion
  111351. */
  111352. get quaternion(): Nullable<Quaternion>;
  111353. /**
  111354. * Legacy support, changed quaternion to rotationQuaternion
  111355. */
  111356. set quaternion(q: Nullable<Quaternion>);
  111357. /**
  111358. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  111359. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  111360. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  111361. * @returns true if it intersects
  111362. */
  111363. intersectsMesh(target: Mesh | SolidParticle): boolean;
  111364. /**
  111365. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  111366. * A particle is in the frustum if its bounding box intersects the frustum
  111367. * @param frustumPlanes defines the frustum to test
  111368. * @returns true if the particle is in the frustum planes
  111369. */
  111370. isInFrustum(frustumPlanes: Plane[]): boolean;
  111371. /**
  111372. * get the rotation matrix of the particle
  111373. * @hidden
  111374. */
  111375. getRotationMatrix(m: Matrix): void;
  111376. }
  111377. /**
  111378. * Represents the shape of the model used by one particle of a solid particle system.
  111379. * SPS internal tool, don't use it manually.
  111380. */
  111381. export class ModelShape {
  111382. /**
  111383. * The shape id
  111384. * @hidden
  111385. */
  111386. shapeID: number;
  111387. /**
  111388. * flat array of model positions (internal use)
  111389. * @hidden
  111390. */
  111391. _shape: Vector3[];
  111392. /**
  111393. * flat array of model UVs (internal use)
  111394. * @hidden
  111395. */
  111396. _shapeUV: number[];
  111397. /**
  111398. * color array of the model
  111399. * @hidden
  111400. */
  111401. _shapeColors: number[];
  111402. /**
  111403. * indices array of the model
  111404. * @hidden
  111405. */
  111406. _indices: number[];
  111407. /**
  111408. * normals array of the model
  111409. * @hidden
  111410. */
  111411. _normals: number[];
  111412. /**
  111413. * length of the shape in the model indices array (internal use)
  111414. * @hidden
  111415. */
  111416. _indicesLength: number;
  111417. /**
  111418. * Custom position function (internal use)
  111419. * @hidden
  111420. */
  111421. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  111422. /**
  111423. * Custom vertex function (internal use)
  111424. * @hidden
  111425. */
  111426. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  111427. /**
  111428. * Model material (internal use)
  111429. * @hidden
  111430. */
  111431. _material: Nullable<Material>;
  111432. /**
  111433. * 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.
  111434. * SPS internal tool, don't use it manually.
  111435. * @hidden
  111436. */
  111437. 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>);
  111438. }
  111439. /**
  111440. * Represents a Depth Sorted Particle in the solid particle system.
  111441. * @hidden
  111442. */
  111443. export class DepthSortedParticle {
  111444. /**
  111445. * Particle index
  111446. */
  111447. idx: number;
  111448. /**
  111449. * Index of the particle in the "indices" array
  111450. */
  111451. ind: number;
  111452. /**
  111453. * Length of the particle shape in the "indices" array
  111454. */
  111455. indicesLength: number;
  111456. /**
  111457. * Squared distance from the particle to the camera
  111458. */
  111459. sqDistance: number;
  111460. /**
  111461. * Material index when used with MultiMaterials
  111462. */
  111463. materialIndex: number;
  111464. /**
  111465. * Creates a new sorted particle
  111466. * @param materialIndex
  111467. */
  111468. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  111469. }
  111470. /**
  111471. * Represents a solid particle vertex
  111472. */
  111473. export class SolidParticleVertex {
  111474. /**
  111475. * Vertex position
  111476. */
  111477. position: Vector3;
  111478. /**
  111479. * Vertex color
  111480. */
  111481. color: Color4;
  111482. /**
  111483. * Vertex UV
  111484. */
  111485. uv: Vector2;
  111486. /**
  111487. * Creates a new solid particle vertex
  111488. */
  111489. constructor();
  111490. /** Vertex x coordinate */
  111491. get x(): number;
  111492. set x(val: number);
  111493. /** Vertex y coordinate */
  111494. get y(): number;
  111495. set y(val: number);
  111496. /** Vertex z coordinate */
  111497. get z(): number;
  111498. set z(val: number);
  111499. }
  111500. }
  111501. declare module BABYLON {
  111502. /**
  111503. * @hidden
  111504. */
  111505. export class _MeshCollisionData {
  111506. _checkCollisions: boolean;
  111507. _collisionMask: number;
  111508. _collisionGroup: number;
  111509. _surroundingMeshes: Nullable<AbstractMesh[]>;
  111510. _collider: Nullable<Collider>;
  111511. _oldPositionForCollisions: Vector3;
  111512. _diffPositionForCollisions: Vector3;
  111513. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  111514. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  111515. }
  111516. }
  111517. declare module BABYLON {
  111518. /** @hidden */
  111519. class _FacetDataStorage {
  111520. facetPositions: Vector3[];
  111521. facetNormals: Vector3[];
  111522. facetPartitioning: number[][];
  111523. facetNb: number;
  111524. partitioningSubdivisions: number;
  111525. partitioningBBoxRatio: number;
  111526. facetDataEnabled: boolean;
  111527. facetParameters: any;
  111528. bbSize: Vector3;
  111529. subDiv: {
  111530. max: number;
  111531. X: number;
  111532. Y: number;
  111533. Z: number;
  111534. };
  111535. facetDepthSort: boolean;
  111536. facetDepthSortEnabled: boolean;
  111537. depthSortedIndices: IndicesArray;
  111538. depthSortedFacets: {
  111539. ind: number;
  111540. sqDistance: number;
  111541. }[];
  111542. facetDepthSortFunction: (f1: {
  111543. ind: number;
  111544. sqDistance: number;
  111545. }, f2: {
  111546. ind: number;
  111547. sqDistance: number;
  111548. }) => number;
  111549. facetDepthSortFrom: Vector3;
  111550. facetDepthSortOrigin: Vector3;
  111551. invertedMatrix: Matrix;
  111552. }
  111553. /**
  111554. * @hidden
  111555. **/
  111556. class _InternalAbstractMeshDataInfo {
  111557. _hasVertexAlpha: boolean;
  111558. _useVertexColors: boolean;
  111559. _numBoneInfluencers: number;
  111560. _applyFog: boolean;
  111561. _receiveShadows: boolean;
  111562. _facetData: _FacetDataStorage;
  111563. _visibility: number;
  111564. _skeleton: Nullable<Skeleton>;
  111565. _layerMask: number;
  111566. _computeBonesUsingShaders: boolean;
  111567. _isActive: boolean;
  111568. _onlyForInstances: boolean;
  111569. _isActiveIntermediate: boolean;
  111570. _onlyForInstancesIntermediate: boolean;
  111571. _actAsRegularMesh: boolean;
  111572. }
  111573. /**
  111574. * Class used to store all common mesh properties
  111575. */
  111576. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  111577. /** No occlusion */
  111578. static OCCLUSION_TYPE_NONE: number;
  111579. /** Occlusion set to optimisitic */
  111580. static OCCLUSION_TYPE_OPTIMISTIC: number;
  111581. /** Occlusion set to strict */
  111582. static OCCLUSION_TYPE_STRICT: number;
  111583. /** Use an accurante occlusion algorithm */
  111584. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  111585. /** Use a conservative occlusion algorithm */
  111586. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  111587. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  111588. * Test order :
  111589. * Is the bounding sphere outside the frustum ?
  111590. * If not, are the bounding box vertices outside the frustum ?
  111591. * It not, then the cullable object is in the frustum.
  111592. */
  111593. static readonly CULLINGSTRATEGY_STANDARD: number;
  111594. /** Culling strategy : Bounding Sphere Only.
  111595. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  111596. * It's also less accurate than the standard because some not visible objects can still be selected.
  111597. * Test : is the bounding sphere outside the frustum ?
  111598. * If not, then the cullable object is in the frustum.
  111599. */
  111600. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  111601. /** Culling strategy : Optimistic Inclusion.
  111602. * This in an inclusion test first, then the standard exclusion test.
  111603. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  111604. * 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.
  111605. * Anyway, it's as accurate as the standard strategy.
  111606. * Test :
  111607. * Is the cullable object bounding sphere center in the frustum ?
  111608. * If not, apply the default culling strategy.
  111609. */
  111610. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  111611. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  111612. * This in an inclusion test first, then the bounding sphere only exclusion test.
  111613. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  111614. * 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.
  111615. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  111616. * Test :
  111617. * Is the cullable object bounding sphere center in the frustum ?
  111618. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  111619. */
  111620. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  111621. /**
  111622. * No billboard
  111623. */
  111624. static get BILLBOARDMODE_NONE(): number;
  111625. /** Billboard on X axis */
  111626. static get BILLBOARDMODE_X(): number;
  111627. /** Billboard on Y axis */
  111628. static get BILLBOARDMODE_Y(): number;
  111629. /** Billboard on Z axis */
  111630. static get BILLBOARDMODE_Z(): number;
  111631. /** Billboard on all axes */
  111632. static get BILLBOARDMODE_ALL(): number;
  111633. /** Billboard on using position instead of orientation */
  111634. static get BILLBOARDMODE_USE_POSITION(): number;
  111635. /** @hidden */
  111636. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  111637. /**
  111638. * The culling strategy to use to check whether the mesh must be rendered or not.
  111639. * This value can be changed at any time and will be used on the next render mesh selection.
  111640. * The possible values are :
  111641. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  111642. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111643. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  111644. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  111645. * Please read each static variable documentation to get details about the culling process.
  111646. * */
  111647. cullingStrategy: number;
  111648. /**
  111649. * Gets the number of facets in the mesh
  111650. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  111651. */
  111652. get facetNb(): number;
  111653. /**
  111654. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  111655. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  111656. */
  111657. get partitioningSubdivisions(): number;
  111658. set partitioningSubdivisions(nb: number);
  111659. /**
  111660. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  111661. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  111662. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  111663. */
  111664. get partitioningBBoxRatio(): number;
  111665. set partitioningBBoxRatio(ratio: number);
  111666. /**
  111667. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  111668. * Works only for updatable meshes.
  111669. * Doesn't work with multi-materials
  111670. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  111671. */
  111672. get mustDepthSortFacets(): boolean;
  111673. set mustDepthSortFacets(sort: boolean);
  111674. /**
  111675. * The location (Vector3) where the facet depth sort must be computed from.
  111676. * By default, the active camera position.
  111677. * Used only when facet depth sort is enabled
  111678. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  111679. */
  111680. get facetDepthSortFrom(): Vector3;
  111681. set facetDepthSortFrom(location: Vector3);
  111682. /**
  111683. * gets a boolean indicating if facetData is enabled
  111684. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  111685. */
  111686. get isFacetDataEnabled(): boolean;
  111687. /** @hidden */
  111688. _updateNonUniformScalingState(value: boolean): boolean;
  111689. /**
  111690. * An event triggered when this mesh collides with another one
  111691. */
  111692. onCollideObservable: Observable<AbstractMesh>;
  111693. /** Set a function to call when this mesh collides with another one */
  111694. set onCollide(callback: () => void);
  111695. /**
  111696. * An event triggered when the collision's position changes
  111697. */
  111698. onCollisionPositionChangeObservable: Observable<Vector3>;
  111699. /** Set a function to call when the collision's position changes */
  111700. set onCollisionPositionChange(callback: () => void);
  111701. /**
  111702. * An event triggered when material is changed
  111703. */
  111704. onMaterialChangedObservable: Observable<AbstractMesh>;
  111705. /**
  111706. * Gets or sets the orientation for POV movement & rotation
  111707. */
  111708. definedFacingForward: boolean;
  111709. /** @hidden */
  111710. _occlusionQuery: Nullable<WebGLQuery>;
  111711. /** @hidden */
  111712. _renderingGroup: Nullable<RenderingGroup>;
  111713. /**
  111714. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  111715. */
  111716. get visibility(): number;
  111717. /**
  111718. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  111719. */
  111720. set visibility(value: number);
  111721. /** Gets or sets the alpha index used to sort transparent meshes
  111722. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  111723. */
  111724. alphaIndex: number;
  111725. /**
  111726. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  111727. */
  111728. isVisible: boolean;
  111729. /**
  111730. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  111731. */
  111732. isPickable: boolean;
  111733. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  111734. showSubMeshesBoundingBox: boolean;
  111735. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  111736. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111737. */
  111738. isBlocker: boolean;
  111739. /**
  111740. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  111741. */
  111742. enablePointerMoveEvents: boolean;
  111743. /**
  111744. * Specifies the rendering group id for this mesh (0 by default)
  111745. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  111746. */
  111747. renderingGroupId: number;
  111748. private _material;
  111749. /** Gets or sets current material */
  111750. get material(): Nullable<Material>;
  111751. set material(value: Nullable<Material>);
  111752. /**
  111753. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  111754. * @see https://doc.babylonjs.com/babylon101/shadows
  111755. */
  111756. get receiveShadows(): boolean;
  111757. set receiveShadows(value: boolean);
  111758. /** Defines color to use when rendering outline */
  111759. outlineColor: Color3;
  111760. /** Define width to use when rendering outline */
  111761. outlineWidth: number;
  111762. /** Defines color to use when rendering overlay */
  111763. overlayColor: Color3;
  111764. /** Defines alpha to use when rendering overlay */
  111765. overlayAlpha: number;
  111766. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  111767. get hasVertexAlpha(): boolean;
  111768. set hasVertexAlpha(value: boolean);
  111769. /** 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) */
  111770. get useVertexColors(): boolean;
  111771. set useVertexColors(value: boolean);
  111772. /**
  111773. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  111774. */
  111775. get computeBonesUsingShaders(): boolean;
  111776. set computeBonesUsingShaders(value: boolean);
  111777. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  111778. get numBoneInfluencers(): number;
  111779. set numBoneInfluencers(value: number);
  111780. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  111781. get applyFog(): boolean;
  111782. set applyFog(value: boolean);
  111783. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  111784. useOctreeForRenderingSelection: boolean;
  111785. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  111786. useOctreeForPicking: boolean;
  111787. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  111788. useOctreeForCollisions: boolean;
  111789. /**
  111790. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  111791. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  111792. */
  111793. get layerMask(): number;
  111794. set layerMask(value: number);
  111795. /**
  111796. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  111797. */
  111798. alwaysSelectAsActiveMesh: boolean;
  111799. /**
  111800. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  111801. */
  111802. doNotSyncBoundingInfo: boolean;
  111803. /**
  111804. * Gets or sets the current action manager
  111805. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  111806. */
  111807. actionManager: Nullable<AbstractActionManager>;
  111808. private _meshCollisionData;
  111809. /**
  111810. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  111811. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111812. */
  111813. ellipsoid: Vector3;
  111814. /**
  111815. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  111816. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111817. */
  111818. ellipsoidOffset: Vector3;
  111819. /**
  111820. * Gets or sets a collision mask used to mask collisions (default is -1).
  111821. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  111822. */
  111823. get collisionMask(): number;
  111824. set collisionMask(mask: number);
  111825. /**
  111826. * Gets or sets the current collision group mask (-1 by default).
  111827. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  111828. */
  111829. get collisionGroup(): number;
  111830. set collisionGroup(mask: number);
  111831. /**
  111832. * Gets or sets current surrounding meshes (null by default).
  111833. *
  111834. * By default collision detection is tested against every mesh in the scene.
  111835. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  111836. * meshes will be tested for the collision.
  111837. *
  111838. * Note: if set to an empty array no collision will happen when this mesh is moved.
  111839. */
  111840. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  111841. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  111842. /**
  111843. * Defines edge width used when edgesRenderer is enabled
  111844. * @see https://www.babylonjs-playground.com/#10OJSG#13
  111845. */
  111846. edgesWidth: number;
  111847. /**
  111848. * Defines edge color used when edgesRenderer is enabled
  111849. * @see https://www.babylonjs-playground.com/#10OJSG#13
  111850. */
  111851. edgesColor: Color4;
  111852. /** @hidden */
  111853. _edgesRenderer: Nullable<IEdgesRenderer>;
  111854. /** @hidden */
  111855. _masterMesh: Nullable<AbstractMesh>;
  111856. /** @hidden */
  111857. _boundingInfo: Nullable<BoundingInfo>;
  111858. /** @hidden */
  111859. _renderId: number;
  111860. /**
  111861. * Gets or sets the list of subMeshes
  111862. * @see https://doc.babylonjs.com/how_to/multi_materials
  111863. */
  111864. subMeshes: SubMesh[];
  111865. /** @hidden */
  111866. _intersectionsInProgress: AbstractMesh[];
  111867. /** @hidden */
  111868. _unIndexed: boolean;
  111869. /** @hidden */
  111870. _lightSources: Light[];
  111871. /** Gets the list of lights affecting that mesh */
  111872. get lightSources(): Light[];
  111873. /** @hidden */
  111874. get _positions(): Nullable<Vector3[]>;
  111875. /** @hidden */
  111876. _waitingData: {
  111877. lods: Nullable<any>;
  111878. actions: Nullable<any>;
  111879. freezeWorldMatrix: Nullable<boolean>;
  111880. };
  111881. /** @hidden */
  111882. _bonesTransformMatrices: Nullable<Float32Array>;
  111883. /** @hidden */
  111884. _transformMatrixTexture: Nullable<RawTexture>;
  111885. /**
  111886. * Gets or sets a skeleton to apply skining transformations
  111887. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  111888. */
  111889. set skeleton(value: Nullable<Skeleton>);
  111890. get skeleton(): Nullable<Skeleton>;
  111891. /**
  111892. * An event triggered when the mesh is rebuilt.
  111893. */
  111894. onRebuildObservable: Observable<AbstractMesh>;
  111895. /**
  111896. * Creates a new AbstractMesh
  111897. * @param name defines the name of the mesh
  111898. * @param scene defines the hosting scene
  111899. */
  111900. constructor(name: string, scene?: Nullable<Scene>);
  111901. /**
  111902. * Returns the string "AbstractMesh"
  111903. * @returns "AbstractMesh"
  111904. */
  111905. getClassName(): string;
  111906. /**
  111907. * Gets a string representation of the current mesh
  111908. * @param fullDetails defines a boolean indicating if full details must be included
  111909. * @returns a string representation of the current mesh
  111910. */
  111911. toString(fullDetails?: boolean): string;
  111912. /**
  111913. * @hidden
  111914. */
  111915. protected _getEffectiveParent(): Nullable<Node>;
  111916. /** @hidden */
  111917. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  111918. /** @hidden */
  111919. _rebuild(): void;
  111920. /** @hidden */
  111921. _resyncLightSources(): void;
  111922. /** @hidden */
  111923. _resyncLightSource(light: Light): void;
  111924. /** @hidden */
  111925. _unBindEffect(): void;
  111926. /** @hidden */
  111927. _removeLightSource(light: Light, dispose: boolean): void;
  111928. private _markSubMeshesAsDirty;
  111929. /** @hidden */
  111930. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  111931. /** @hidden */
  111932. _markSubMeshesAsAttributesDirty(): void;
  111933. /** @hidden */
  111934. _markSubMeshesAsMiscDirty(): void;
  111935. /**
  111936. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  111937. */
  111938. get scaling(): Vector3;
  111939. set scaling(newScaling: Vector3);
  111940. /**
  111941. * Returns true if the mesh is blocked. Implemented by child classes
  111942. */
  111943. get isBlocked(): boolean;
  111944. /**
  111945. * Returns the mesh itself by default. Implemented by child classes
  111946. * @param camera defines the camera to use to pick the right LOD level
  111947. * @returns the currentAbstractMesh
  111948. */
  111949. getLOD(camera: Camera): Nullable<AbstractMesh>;
  111950. /**
  111951. * Returns 0 by default. Implemented by child classes
  111952. * @returns an integer
  111953. */
  111954. getTotalVertices(): number;
  111955. /**
  111956. * Returns a positive integer : the total number of indices in this mesh geometry.
  111957. * @returns the numner of indices or zero if the mesh has no geometry.
  111958. */
  111959. getTotalIndices(): number;
  111960. /**
  111961. * Returns null by default. Implemented by child classes
  111962. * @returns null
  111963. */
  111964. getIndices(): Nullable<IndicesArray>;
  111965. /**
  111966. * Returns the array of the requested vertex data kind. Implemented by child classes
  111967. * @param kind defines the vertex data kind to use
  111968. * @returns null
  111969. */
  111970. getVerticesData(kind: string): Nullable<FloatArray>;
  111971. /**
  111972. * Sets the vertex data of the mesh geometry for the requested `kind`.
  111973. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  111974. * Note that a new underlying VertexBuffer object is created each call.
  111975. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  111976. * @param kind defines vertex data kind:
  111977. * * VertexBuffer.PositionKind
  111978. * * VertexBuffer.UVKind
  111979. * * VertexBuffer.UV2Kind
  111980. * * VertexBuffer.UV3Kind
  111981. * * VertexBuffer.UV4Kind
  111982. * * VertexBuffer.UV5Kind
  111983. * * VertexBuffer.UV6Kind
  111984. * * VertexBuffer.ColorKind
  111985. * * VertexBuffer.MatricesIndicesKind
  111986. * * VertexBuffer.MatricesIndicesExtraKind
  111987. * * VertexBuffer.MatricesWeightsKind
  111988. * * VertexBuffer.MatricesWeightsExtraKind
  111989. * @param data defines the data source
  111990. * @param updatable defines if the data must be flagged as updatable (or static)
  111991. * @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
  111992. * @returns the current mesh
  111993. */
  111994. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  111995. /**
  111996. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  111997. * If the mesh has no geometry, it is simply returned as it is.
  111998. * @param kind defines vertex data kind:
  111999. * * VertexBuffer.PositionKind
  112000. * * VertexBuffer.UVKind
  112001. * * VertexBuffer.UV2Kind
  112002. * * VertexBuffer.UV3Kind
  112003. * * VertexBuffer.UV4Kind
  112004. * * VertexBuffer.UV5Kind
  112005. * * VertexBuffer.UV6Kind
  112006. * * VertexBuffer.ColorKind
  112007. * * VertexBuffer.MatricesIndicesKind
  112008. * * VertexBuffer.MatricesIndicesExtraKind
  112009. * * VertexBuffer.MatricesWeightsKind
  112010. * * VertexBuffer.MatricesWeightsExtraKind
  112011. * @param data defines the data source
  112012. * @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
  112013. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  112014. * @returns the current mesh
  112015. */
  112016. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  112017. /**
  112018. * Sets the mesh indices,
  112019. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  112020. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  112021. * @param totalVertices Defines the total number of vertices
  112022. * @returns the current mesh
  112023. */
  112024. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  112025. /**
  112026. * Gets a boolean indicating if specific vertex data is present
  112027. * @param kind defines the vertex data kind to use
  112028. * @returns true is data kind is present
  112029. */
  112030. isVerticesDataPresent(kind: string): boolean;
  112031. /**
  112032. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  112033. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  112034. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  112035. * @returns a BoundingInfo
  112036. */
  112037. getBoundingInfo(): BoundingInfo;
  112038. /**
  112039. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  112040. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  112041. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  112042. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  112043. * @returns the current mesh
  112044. */
  112045. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  112046. /**
  112047. * Overwrite the current bounding info
  112048. * @param boundingInfo defines the new bounding info
  112049. * @returns the current mesh
  112050. */
  112051. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  112052. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  112053. get useBones(): boolean;
  112054. /** @hidden */
  112055. _preActivate(): void;
  112056. /** @hidden */
  112057. _preActivateForIntermediateRendering(renderId: number): void;
  112058. /** @hidden */
  112059. _activate(renderId: number, intermediateRendering: boolean): boolean;
  112060. /** @hidden */
  112061. _postActivate(): void;
  112062. /** @hidden */
  112063. _freeze(): void;
  112064. /** @hidden */
  112065. _unFreeze(): void;
  112066. /**
  112067. * Gets the current world matrix
  112068. * @returns a Matrix
  112069. */
  112070. getWorldMatrix(): Matrix;
  112071. /** @hidden */
  112072. _getWorldMatrixDeterminant(): number;
  112073. /**
  112074. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  112075. */
  112076. get isAnInstance(): boolean;
  112077. /**
  112078. * Gets a boolean indicating if this mesh has instances
  112079. */
  112080. get hasInstances(): boolean;
  112081. /**
  112082. * Gets a boolean indicating if this mesh has thin instances
  112083. */
  112084. get hasThinInstances(): boolean;
  112085. /**
  112086. * Perform relative position change from the point of view of behind the front of the mesh.
  112087. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112088. * Supports definition of mesh facing forward or backward
  112089. * @param amountRight defines the distance on the right axis
  112090. * @param amountUp defines the distance on the up axis
  112091. * @param amountForward defines the distance on the forward axis
  112092. * @returns the current mesh
  112093. */
  112094. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  112095. /**
  112096. * Calculate relative position change from the point of view of behind the front of the mesh.
  112097. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112098. * Supports definition of mesh facing forward or backward
  112099. * @param amountRight defines the distance on the right axis
  112100. * @param amountUp defines the distance on the up axis
  112101. * @param amountForward defines the distance on the forward axis
  112102. * @returns the new displacement vector
  112103. */
  112104. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  112105. /**
  112106. * Perform relative rotation change from the point of view of behind the front of the mesh.
  112107. * Supports definition of mesh facing forward or backward
  112108. * @param flipBack defines the flip
  112109. * @param twirlClockwise defines the twirl
  112110. * @param tiltRight defines the tilt
  112111. * @returns the current mesh
  112112. */
  112113. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  112114. /**
  112115. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  112116. * Supports definition of mesh facing forward or backward.
  112117. * @param flipBack defines the flip
  112118. * @param twirlClockwise defines the twirl
  112119. * @param tiltRight defines the tilt
  112120. * @returns the new rotation vector
  112121. */
  112122. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  112123. /**
  112124. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  112125. * This means the mesh underlying bounding box and sphere are recomputed.
  112126. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  112127. * @returns the current mesh
  112128. */
  112129. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  112130. /** @hidden */
  112131. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  112132. /** @hidden */
  112133. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  112134. /** @hidden */
  112135. _updateBoundingInfo(): AbstractMesh;
  112136. /** @hidden */
  112137. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  112138. /** @hidden */
  112139. protected _afterComputeWorldMatrix(): void;
  112140. /** @hidden */
  112141. get _effectiveMesh(): AbstractMesh;
  112142. /**
  112143. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  112144. * A mesh is in the frustum if its bounding box intersects the frustum
  112145. * @param frustumPlanes defines the frustum to test
  112146. * @returns true if the mesh is in the frustum planes
  112147. */
  112148. isInFrustum(frustumPlanes: Plane[]): boolean;
  112149. /**
  112150. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  112151. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  112152. * @param frustumPlanes defines the frustum to test
  112153. * @returns true if the mesh is completely in the frustum planes
  112154. */
  112155. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  112156. /**
  112157. * True if the mesh intersects another mesh or a SolidParticle object
  112158. * @param mesh defines a target mesh or SolidParticle to test
  112159. * @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)
  112160. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  112161. * @returns true if there is an intersection
  112162. */
  112163. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  112164. /**
  112165. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  112166. * @param point defines the point to test
  112167. * @returns true if there is an intersection
  112168. */
  112169. intersectsPoint(point: Vector3): boolean;
  112170. /**
  112171. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  112172. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112173. */
  112174. get checkCollisions(): boolean;
  112175. set checkCollisions(collisionEnabled: boolean);
  112176. /**
  112177. * Gets Collider object used to compute collisions (not physics)
  112178. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112179. */
  112180. get collider(): Nullable<Collider>;
  112181. /**
  112182. * Move the mesh using collision engine
  112183. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112184. * @param displacement defines the requested displacement vector
  112185. * @returns the current mesh
  112186. */
  112187. moveWithCollisions(displacement: Vector3): AbstractMesh;
  112188. private _onCollisionPositionChange;
  112189. /** @hidden */
  112190. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  112191. /** @hidden */
  112192. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  112193. /** @hidden */
  112194. _checkCollision(collider: Collider): AbstractMesh;
  112195. /** @hidden */
  112196. _generatePointsArray(): boolean;
  112197. /**
  112198. * Checks if the passed Ray intersects with the mesh
  112199. * @param ray defines the ray to use
  112200. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  112201. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  112202. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  112203. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  112204. * @returns the picking info
  112205. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  112206. */
  112207. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  112208. /**
  112209. * Clones the current mesh
  112210. * @param name defines the mesh name
  112211. * @param newParent defines the new mesh parent
  112212. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  112213. * @returns the new mesh
  112214. */
  112215. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  112216. /**
  112217. * Disposes all the submeshes of the current meshnp
  112218. * @returns the current mesh
  112219. */
  112220. releaseSubMeshes(): AbstractMesh;
  112221. /**
  112222. * Releases resources associated with this abstract mesh.
  112223. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112224. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112225. */
  112226. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112227. /**
  112228. * Adds the passed mesh as a child to the current mesh
  112229. * @param mesh defines the child mesh
  112230. * @returns the current mesh
  112231. */
  112232. addChild(mesh: AbstractMesh): AbstractMesh;
  112233. /**
  112234. * Removes the passed mesh from the current mesh children list
  112235. * @param mesh defines the child mesh
  112236. * @returns the current mesh
  112237. */
  112238. removeChild(mesh: AbstractMesh): AbstractMesh;
  112239. /** @hidden */
  112240. private _initFacetData;
  112241. /**
  112242. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  112243. * This method can be called within the render loop.
  112244. * 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
  112245. * @returns the current mesh
  112246. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112247. */
  112248. updateFacetData(): AbstractMesh;
  112249. /**
  112250. * Returns the facetLocalNormals array.
  112251. * The normals are expressed in the mesh local spac
  112252. * @returns an array of Vector3
  112253. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112254. */
  112255. getFacetLocalNormals(): Vector3[];
  112256. /**
  112257. * Returns the facetLocalPositions array.
  112258. * The facet positions are expressed in the mesh local space
  112259. * @returns an array of Vector3
  112260. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112261. */
  112262. getFacetLocalPositions(): Vector3[];
  112263. /**
  112264. * Returns the facetLocalPartioning array
  112265. * @returns an array of array of numbers
  112266. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112267. */
  112268. getFacetLocalPartitioning(): number[][];
  112269. /**
  112270. * Returns the i-th facet position in the world system.
  112271. * This method allocates a new Vector3 per call
  112272. * @param i defines the facet index
  112273. * @returns a new Vector3
  112274. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112275. */
  112276. getFacetPosition(i: number): Vector3;
  112277. /**
  112278. * Sets the reference Vector3 with the i-th facet position in the world system
  112279. * @param i defines the facet index
  112280. * @param ref defines the target vector
  112281. * @returns the current mesh
  112282. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112283. */
  112284. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  112285. /**
  112286. * Returns the i-th facet normal in the world system.
  112287. * This method allocates a new Vector3 per call
  112288. * @param i defines the facet index
  112289. * @returns a new Vector3
  112290. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112291. */
  112292. getFacetNormal(i: number): Vector3;
  112293. /**
  112294. * Sets the reference Vector3 with the i-th facet normal in the world system
  112295. * @param i defines the facet index
  112296. * @param ref defines the target vector
  112297. * @returns the current mesh
  112298. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112299. */
  112300. getFacetNormalToRef(i: number, ref: Vector3): this;
  112301. /**
  112302. * 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)
  112303. * @param x defines x coordinate
  112304. * @param y defines y coordinate
  112305. * @param z defines z coordinate
  112306. * @returns the array of facet indexes
  112307. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112308. */
  112309. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  112310. /**
  112311. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  112312. * @param projected sets as the (x,y,z) world projection on the facet
  112313. * @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
  112314. * @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
  112315. * @param x defines x coordinate
  112316. * @param y defines y coordinate
  112317. * @param z defines z coordinate
  112318. * @returns the face index if found (or null instead)
  112319. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112320. */
  112321. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  112322. /**
  112323. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  112324. * @param projected sets as the (x,y,z) local projection on the facet
  112325. * @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
  112326. * @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
  112327. * @param x defines x coordinate
  112328. * @param y defines y coordinate
  112329. * @param z defines z coordinate
  112330. * @returns the face index if found (or null instead)
  112331. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112332. */
  112333. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  112334. /**
  112335. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  112336. * @returns the parameters
  112337. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112338. */
  112339. getFacetDataParameters(): any;
  112340. /**
  112341. * Disables the feature FacetData and frees the related memory
  112342. * @returns the current mesh
  112343. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112344. */
  112345. disableFacetData(): AbstractMesh;
  112346. /**
  112347. * Updates the AbstractMesh indices array
  112348. * @param indices defines the data source
  112349. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  112350. * @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)
  112351. * @returns the current mesh
  112352. */
  112353. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  112354. /**
  112355. * Creates new normals data for the mesh
  112356. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  112357. * @returns the current mesh
  112358. */
  112359. createNormals(updatable: boolean): AbstractMesh;
  112360. /**
  112361. * Align the mesh with a normal
  112362. * @param normal defines the normal to use
  112363. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  112364. * @returns the current mesh
  112365. */
  112366. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  112367. /** @hidden */
  112368. _checkOcclusionQuery(): boolean;
  112369. /**
  112370. * Disables the mesh edge rendering mode
  112371. * @returns the currentAbstractMesh
  112372. */
  112373. disableEdgesRendering(): AbstractMesh;
  112374. /**
  112375. * Enables the edge rendering mode on the mesh.
  112376. * This mode makes the mesh edges visible
  112377. * @param epsilon defines the maximal distance between two angles to detect a face
  112378. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  112379. * @returns the currentAbstractMesh
  112380. * @see https://www.babylonjs-playground.com/#19O9TU#0
  112381. */
  112382. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  112383. /**
  112384. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  112385. * @returns an array of particle systems in the scene that use the mesh as an emitter
  112386. */
  112387. getConnectedParticleSystems(): IParticleSystem[];
  112388. }
  112389. }
  112390. declare module BABYLON {
  112391. /**
  112392. * Interface used to define ActionEvent
  112393. */
  112394. export interface IActionEvent {
  112395. /** The mesh or sprite that triggered the action */
  112396. source: any;
  112397. /** The X mouse cursor position at the time of the event */
  112398. pointerX: number;
  112399. /** The Y mouse cursor position at the time of the event */
  112400. pointerY: number;
  112401. /** The mesh that is currently pointed at (can be null) */
  112402. meshUnderPointer: Nullable<AbstractMesh>;
  112403. /** the original (browser) event that triggered the ActionEvent */
  112404. sourceEvent?: any;
  112405. /** additional data for the event */
  112406. additionalData?: any;
  112407. }
  112408. /**
  112409. * ActionEvent is the event being sent when an action is triggered.
  112410. */
  112411. export class ActionEvent implements IActionEvent {
  112412. /** The mesh or sprite that triggered the action */
  112413. source: any;
  112414. /** The X mouse cursor position at the time of the event */
  112415. pointerX: number;
  112416. /** The Y mouse cursor position at the time of the event */
  112417. pointerY: number;
  112418. /** The mesh that is currently pointed at (can be null) */
  112419. meshUnderPointer: Nullable<AbstractMesh>;
  112420. /** the original (browser) event that triggered the ActionEvent */
  112421. sourceEvent?: any;
  112422. /** additional data for the event */
  112423. additionalData?: any;
  112424. /**
  112425. * Creates a new ActionEvent
  112426. * @param source The mesh or sprite that triggered the action
  112427. * @param pointerX The X mouse cursor position at the time of the event
  112428. * @param pointerY The Y mouse cursor position at the time of the event
  112429. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  112430. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  112431. * @param additionalData additional data for the event
  112432. */
  112433. constructor(
  112434. /** The mesh or sprite that triggered the action */
  112435. source: any,
  112436. /** The X mouse cursor position at the time of the event */
  112437. pointerX: number,
  112438. /** The Y mouse cursor position at the time of the event */
  112439. pointerY: number,
  112440. /** The mesh that is currently pointed at (can be null) */
  112441. meshUnderPointer: Nullable<AbstractMesh>,
  112442. /** the original (browser) event that triggered the ActionEvent */
  112443. sourceEvent?: any,
  112444. /** additional data for the event */
  112445. additionalData?: any);
  112446. /**
  112447. * Helper function to auto-create an ActionEvent from a source mesh.
  112448. * @param source The source mesh that triggered the event
  112449. * @param evt The original (browser) event
  112450. * @param additionalData additional data for the event
  112451. * @returns the new ActionEvent
  112452. */
  112453. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  112454. /**
  112455. * Helper function to auto-create an ActionEvent from a source sprite
  112456. * @param source The source sprite that triggered the event
  112457. * @param scene Scene associated with the sprite
  112458. * @param evt The original (browser) event
  112459. * @param additionalData additional data for the event
  112460. * @returns the new ActionEvent
  112461. */
  112462. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  112463. /**
  112464. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  112465. * @param scene the scene where the event occurred
  112466. * @param evt The original (browser) event
  112467. * @returns the new ActionEvent
  112468. */
  112469. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  112470. /**
  112471. * Helper function to auto-create an ActionEvent from a primitive
  112472. * @param prim defines the target primitive
  112473. * @param pointerPos defines the pointer position
  112474. * @param evt The original (browser) event
  112475. * @param additionalData additional data for the event
  112476. * @returns the new ActionEvent
  112477. */
  112478. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  112479. }
  112480. }
  112481. declare module BABYLON {
  112482. /**
  112483. * Abstract class used to decouple action Manager from scene and meshes.
  112484. * Do not instantiate.
  112485. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112486. */
  112487. export abstract class AbstractActionManager implements IDisposable {
  112488. /** Gets the list of active triggers */
  112489. static Triggers: {
  112490. [key: string]: number;
  112491. };
  112492. /** Gets the cursor to use when hovering items */
  112493. hoverCursor: string;
  112494. /** Gets the list of actions */
  112495. actions: IAction[];
  112496. /**
  112497. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  112498. */
  112499. isRecursive: boolean;
  112500. /**
  112501. * Releases all associated resources
  112502. */
  112503. abstract dispose(): void;
  112504. /**
  112505. * Does this action manager has pointer triggers
  112506. */
  112507. abstract get hasPointerTriggers(): boolean;
  112508. /**
  112509. * Does this action manager has pick triggers
  112510. */
  112511. abstract get hasPickTriggers(): boolean;
  112512. /**
  112513. * Process a specific trigger
  112514. * @param trigger defines the trigger to process
  112515. * @param evt defines the event details to be processed
  112516. */
  112517. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  112518. /**
  112519. * Does this action manager handles actions of any of the given triggers
  112520. * @param triggers defines the triggers to be tested
  112521. * @return a boolean indicating whether one (or more) of the triggers is handled
  112522. */
  112523. abstract hasSpecificTriggers(triggers: number[]): boolean;
  112524. /**
  112525. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  112526. * speed.
  112527. * @param triggerA defines the trigger to be tested
  112528. * @param triggerB defines the trigger to be tested
  112529. * @return a boolean indicating whether one (or more) of the triggers is handled
  112530. */
  112531. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  112532. /**
  112533. * Does this action manager handles actions of a given trigger
  112534. * @param trigger defines the trigger to be tested
  112535. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  112536. * @return whether the trigger is handled
  112537. */
  112538. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  112539. /**
  112540. * Serialize this manager to a JSON object
  112541. * @param name defines the property name to store this manager
  112542. * @returns a JSON representation of this manager
  112543. */
  112544. abstract serialize(name: string): any;
  112545. /**
  112546. * Registers an action to this action manager
  112547. * @param action defines the action to be registered
  112548. * @return the action amended (prepared) after registration
  112549. */
  112550. abstract registerAction(action: IAction): Nullable<IAction>;
  112551. /**
  112552. * Unregisters an action to this action manager
  112553. * @param action defines the action to be unregistered
  112554. * @return a boolean indicating whether the action has been unregistered
  112555. */
  112556. abstract unregisterAction(action: IAction): Boolean;
  112557. /**
  112558. * Does exist one action manager with at least one trigger
  112559. **/
  112560. static get HasTriggers(): boolean;
  112561. /**
  112562. * Does exist one action manager with at least one pick trigger
  112563. **/
  112564. static get HasPickTriggers(): boolean;
  112565. /**
  112566. * Does exist one action manager that handles actions of a given trigger
  112567. * @param trigger defines the trigger to be tested
  112568. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  112569. **/
  112570. static HasSpecificTrigger(trigger: number): boolean;
  112571. }
  112572. }
  112573. declare module BABYLON {
  112574. /**
  112575. * Defines how a node can be built from a string name.
  112576. */
  112577. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  112578. /**
  112579. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  112580. */
  112581. export class Node implements IBehaviorAware<Node> {
  112582. /** @hidden */
  112583. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  112584. private static _NodeConstructors;
  112585. /**
  112586. * Add a new node constructor
  112587. * @param type defines the type name of the node to construct
  112588. * @param constructorFunc defines the constructor function
  112589. */
  112590. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  112591. /**
  112592. * Returns a node constructor based on type name
  112593. * @param type defines the type name
  112594. * @param name defines the new node name
  112595. * @param scene defines the hosting scene
  112596. * @param options defines optional options to transmit to constructors
  112597. * @returns the new constructor or null
  112598. */
  112599. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  112600. /**
  112601. * Gets or sets the name of the node
  112602. */
  112603. name: string;
  112604. /**
  112605. * Gets or sets the id of the node
  112606. */
  112607. id: string;
  112608. /**
  112609. * Gets or sets the unique id of the node
  112610. */
  112611. uniqueId: number;
  112612. /**
  112613. * Gets or sets a string used to store user defined state for the node
  112614. */
  112615. state: string;
  112616. /**
  112617. * Gets or sets an object used to store user defined information for the node
  112618. */
  112619. metadata: any;
  112620. /**
  112621. * For internal use only. Please do not use.
  112622. */
  112623. reservedDataStore: any;
  112624. /**
  112625. * List of inspectable custom properties (used by the Inspector)
  112626. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  112627. */
  112628. inspectableCustomProperties: IInspectable[];
  112629. private _doNotSerialize;
  112630. /**
  112631. * Gets or sets a boolean used to define if the node must be serialized
  112632. */
  112633. get doNotSerialize(): boolean;
  112634. set doNotSerialize(value: boolean);
  112635. /** @hidden */
  112636. _isDisposed: boolean;
  112637. /**
  112638. * Gets a list of Animations associated with the node
  112639. */
  112640. animations: Animation[];
  112641. protected _ranges: {
  112642. [name: string]: Nullable<AnimationRange>;
  112643. };
  112644. /**
  112645. * Callback raised when the node is ready to be used
  112646. */
  112647. onReady: Nullable<(node: Node) => void>;
  112648. private _isEnabled;
  112649. private _isParentEnabled;
  112650. private _isReady;
  112651. /** @hidden */
  112652. _currentRenderId: number;
  112653. private _parentUpdateId;
  112654. /** @hidden */
  112655. _childUpdateId: number;
  112656. /** @hidden */
  112657. _waitingParentId: Nullable<string>;
  112658. /** @hidden */
  112659. _scene: Scene;
  112660. /** @hidden */
  112661. _cache: any;
  112662. private _parentNode;
  112663. private _children;
  112664. /** @hidden */
  112665. _worldMatrix: Matrix;
  112666. /** @hidden */
  112667. _worldMatrixDeterminant: number;
  112668. /** @hidden */
  112669. _worldMatrixDeterminantIsDirty: boolean;
  112670. /** @hidden */
  112671. private _sceneRootNodesIndex;
  112672. /**
  112673. * Gets a boolean indicating if the node has been disposed
  112674. * @returns true if the node was disposed
  112675. */
  112676. isDisposed(): boolean;
  112677. /**
  112678. * Gets or sets the parent of the node (without keeping the current position in the scene)
  112679. * @see https://doc.babylonjs.com/how_to/parenting
  112680. */
  112681. set parent(parent: Nullable<Node>);
  112682. get parent(): Nullable<Node>;
  112683. /** @hidden */
  112684. _addToSceneRootNodes(): void;
  112685. /** @hidden */
  112686. _removeFromSceneRootNodes(): void;
  112687. private _animationPropertiesOverride;
  112688. /**
  112689. * Gets or sets the animation properties override
  112690. */
  112691. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  112692. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  112693. /**
  112694. * Gets a string identifying the name of the class
  112695. * @returns "Node" string
  112696. */
  112697. getClassName(): string;
  112698. /** @hidden */
  112699. readonly _isNode: boolean;
  112700. /**
  112701. * An event triggered when the mesh is disposed
  112702. */
  112703. onDisposeObservable: Observable<Node>;
  112704. private _onDisposeObserver;
  112705. /**
  112706. * Sets a callback that will be raised when the node will be disposed
  112707. */
  112708. set onDispose(callback: () => void);
  112709. /**
  112710. * Creates a new Node
  112711. * @param name the name and id to be given to this node
  112712. * @param scene the scene this node will be added to
  112713. */
  112714. constructor(name: string, scene?: Nullable<Scene>);
  112715. /**
  112716. * Gets the scene of the node
  112717. * @returns a scene
  112718. */
  112719. getScene(): Scene;
  112720. /**
  112721. * Gets the engine of the node
  112722. * @returns a Engine
  112723. */
  112724. getEngine(): Engine;
  112725. private _behaviors;
  112726. /**
  112727. * Attach a behavior to the node
  112728. * @see https://doc.babylonjs.com/features/behaviour
  112729. * @param behavior defines the behavior to attach
  112730. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  112731. * @returns the current Node
  112732. */
  112733. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  112734. /**
  112735. * Remove an attached behavior
  112736. * @see https://doc.babylonjs.com/features/behaviour
  112737. * @param behavior defines the behavior to attach
  112738. * @returns the current Node
  112739. */
  112740. removeBehavior(behavior: Behavior<Node>): Node;
  112741. /**
  112742. * Gets the list of attached behaviors
  112743. * @see https://doc.babylonjs.com/features/behaviour
  112744. */
  112745. get behaviors(): Behavior<Node>[];
  112746. /**
  112747. * Gets an attached behavior by name
  112748. * @param name defines the name of the behavior to look for
  112749. * @see https://doc.babylonjs.com/features/behaviour
  112750. * @returns null if behavior was not found else the requested behavior
  112751. */
  112752. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  112753. /**
  112754. * Returns the latest update of the World matrix
  112755. * @returns a Matrix
  112756. */
  112757. getWorldMatrix(): Matrix;
  112758. /** @hidden */
  112759. _getWorldMatrixDeterminant(): number;
  112760. /**
  112761. * Returns directly the latest state of the mesh World matrix.
  112762. * A Matrix is returned.
  112763. */
  112764. get worldMatrixFromCache(): Matrix;
  112765. /** @hidden */
  112766. _initCache(): void;
  112767. /** @hidden */
  112768. updateCache(force?: boolean): void;
  112769. /** @hidden */
  112770. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112771. /** @hidden */
  112772. _updateCache(ignoreParentClass?: boolean): void;
  112773. /** @hidden */
  112774. _isSynchronized(): boolean;
  112775. /** @hidden */
  112776. _markSyncedWithParent(): void;
  112777. /** @hidden */
  112778. isSynchronizedWithParent(): boolean;
  112779. /** @hidden */
  112780. isSynchronized(): boolean;
  112781. /**
  112782. * Is this node ready to be used/rendered
  112783. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  112784. * @return true if the node is ready
  112785. */
  112786. isReady(completeCheck?: boolean): boolean;
  112787. /**
  112788. * Is this node enabled?
  112789. * 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
  112790. * @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
  112791. * @return whether this node (and its parent) is enabled
  112792. */
  112793. isEnabled(checkAncestors?: boolean): boolean;
  112794. /** @hidden */
  112795. protected _syncParentEnabledState(): void;
  112796. /**
  112797. * Set the enabled state of this node
  112798. * @param value defines the new enabled state
  112799. */
  112800. setEnabled(value: boolean): void;
  112801. /**
  112802. * Is this node a descendant of the given node?
  112803. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  112804. * @param ancestor defines the parent node to inspect
  112805. * @returns a boolean indicating if this node is a descendant of the given node
  112806. */
  112807. isDescendantOf(ancestor: Node): boolean;
  112808. /** @hidden */
  112809. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  112810. /**
  112811. * Will return all nodes that have this node as ascendant
  112812. * @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
  112813. * @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
  112814. * @return all children nodes of all types
  112815. */
  112816. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  112817. /**
  112818. * Get all child-meshes of this node
  112819. * @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)
  112820. * @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
  112821. * @returns an array of AbstractMesh
  112822. */
  112823. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  112824. /**
  112825. * Get all direct children of this node
  112826. * @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
  112827. * @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)
  112828. * @returns an array of Node
  112829. */
  112830. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  112831. /** @hidden */
  112832. _setReady(state: boolean): void;
  112833. /**
  112834. * Get an animation by name
  112835. * @param name defines the name of the animation to look for
  112836. * @returns null if not found else the requested animation
  112837. */
  112838. getAnimationByName(name: string): Nullable<Animation>;
  112839. /**
  112840. * Creates an animation range for this node
  112841. * @param name defines the name of the range
  112842. * @param from defines the starting key
  112843. * @param to defines the end key
  112844. */
  112845. createAnimationRange(name: string, from: number, to: number): void;
  112846. /**
  112847. * Delete a specific animation range
  112848. * @param name defines the name of the range to delete
  112849. * @param deleteFrames defines if animation frames from the range must be deleted as well
  112850. */
  112851. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  112852. /**
  112853. * Get an animation range by name
  112854. * @param name defines the name of the animation range to look for
  112855. * @returns null if not found else the requested animation range
  112856. */
  112857. getAnimationRange(name: string): Nullable<AnimationRange>;
  112858. /**
  112859. * Gets the list of all animation ranges defined on this node
  112860. * @returns an array
  112861. */
  112862. getAnimationRanges(): Nullable<AnimationRange>[];
  112863. /**
  112864. * Will start the animation sequence
  112865. * @param name defines the range frames for animation sequence
  112866. * @param loop defines if the animation should loop (false by default)
  112867. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  112868. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  112869. * @returns the object created for this animation. If range does not exist, it will return null
  112870. */
  112871. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  112872. /**
  112873. * Serialize animation ranges into a JSON compatible object
  112874. * @returns serialization object
  112875. */
  112876. serializeAnimationRanges(): any;
  112877. /**
  112878. * Computes the world matrix of the node
  112879. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  112880. * @returns the world matrix
  112881. */
  112882. computeWorldMatrix(force?: boolean): Matrix;
  112883. /**
  112884. * Releases resources associated with this node.
  112885. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112886. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112887. */
  112888. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112889. /**
  112890. * Parse animation range data from a serialization object and store them into a given node
  112891. * @param node defines where to store the animation ranges
  112892. * @param parsedNode defines the serialization object to read data from
  112893. * @param scene defines the hosting scene
  112894. */
  112895. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  112896. /**
  112897. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  112898. * @param includeDescendants Include bounding info from descendants as well (true by default)
  112899. * @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
  112900. * @returns the new bounding vectors
  112901. */
  112902. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  112903. min: Vector3;
  112904. max: Vector3;
  112905. };
  112906. }
  112907. }
  112908. declare module BABYLON {
  112909. /**
  112910. * @hidden
  112911. */
  112912. export class _IAnimationState {
  112913. key: number;
  112914. repeatCount: number;
  112915. workValue?: any;
  112916. loopMode?: number;
  112917. offsetValue?: any;
  112918. highLimitValue?: any;
  112919. }
  112920. /**
  112921. * Class used to store any kind of animation
  112922. */
  112923. export class Animation {
  112924. /**Name of the animation */
  112925. name: string;
  112926. /**Property to animate */
  112927. targetProperty: string;
  112928. /**The frames per second of the animation */
  112929. framePerSecond: number;
  112930. /**The data type of the animation */
  112931. dataType: number;
  112932. /**The loop mode of the animation */
  112933. loopMode?: number | undefined;
  112934. /**Specifies if blending should be enabled */
  112935. enableBlending?: boolean | undefined;
  112936. /**
  112937. * Use matrix interpolation instead of using direct key value when animating matrices
  112938. */
  112939. static AllowMatricesInterpolation: boolean;
  112940. /**
  112941. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  112942. */
  112943. static AllowMatrixDecomposeForInterpolation: boolean;
  112944. /** Define the Url to load snippets */
  112945. static SnippetUrl: string;
  112946. /** Snippet ID if the animation was created from the snippet server */
  112947. snippetId: string;
  112948. /**
  112949. * Stores the key frames of the animation
  112950. */
  112951. private _keys;
  112952. /**
  112953. * Stores the easing function of the animation
  112954. */
  112955. private _easingFunction;
  112956. /**
  112957. * @hidden Internal use only
  112958. */
  112959. _runtimeAnimations: RuntimeAnimation[];
  112960. /**
  112961. * The set of event that will be linked to this animation
  112962. */
  112963. private _events;
  112964. /**
  112965. * Stores an array of target property paths
  112966. */
  112967. targetPropertyPath: string[];
  112968. /**
  112969. * Stores the blending speed of the animation
  112970. */
  112971. blendingSpeed: number;
  112972. /**
  112973. * Stores the animation ranges for the animation
  112974. */
  112975. private _ranges;
  112976. /**
  112977. * @hidden Internal use
  112978. */
  112979. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  112980. /**
  112981. * Sets up an animation
  112982. * @param property The property to animate
  112983. * @param animationType The animation type to apply
  112984. * @param framePerSecond The frames per second of the animation
  112985. * @param easingFunction The easing function used in the animation
  112986. * @returns The created animation
  112987. */
  112988. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  112989. /**
  112990. * Create and start an animation on a node
  112991. * @param name defines the name of the global animation that will be run on all nodes
  112992. * @param node defines the root node where the animation will take place
  112993. * @param targetProperty defines property to animate
  112994. * @param framePerSecond defines the number of frame per second yo use
  112995. * @param totalFrame defines the number of frames in total
  112996. * @param from defines the initial value
  112997. * @param to defines the final value
  112998. * @param loopMode defines which loop mode you want to use (off by default)
  112999. * @param easingFunction defines the easing function to use (linear by default)
  113000. * @param onAnimationEnd defines the callback to call when animation end
  113001. * @returns the animatable created for this animation
  113002. */
  113003. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113004. /**
  113005. * Create and start an animation on a node and its descendants
  113006. * @param name defines the name of the global animation that will be run on all nodes
  113007. * @param node defines the root node where the animation will take place
  113008. * @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
  113009. * @param targetProperty defines property to animate
  113010. * @param framePerSecond defines the number of frame per second to use
  113011. * @param totalFrame defines the number of frames in total
  113012. * @param from defines the initial value
  113013. * @param to defines the final value
  113014. * @param loopMode defines which loop mode you want to use (off by default)
  113015. * @param easingFunction defines the easing function to use (linear by default)
  113016. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  113017. * @returns the list of animatables created for all nodes
  113018. * @example https://www.babylonjs-playground.com/#MH0VLI
  113019. */
  113020. 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[]>;
  113021. /**
  113022. * Creates a new animation, merges it with the existing animations and starts it
  113023. * @param name Name of the animation
  113024. * @param node Node which contains the scene that begins the animations
  113025. * @param targetProperty Specifies which property to animate
  113026. * @param framePerSecond The frames per second of the animation
  113027. * @param totalFrame The total number of frames
  113028. * @param from The frame at the beginning of the animation
  113029. * @param to The frame at the end of the animation
  113030. * @param loopMode Specifies the loop mode of the animation
  113031. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  113032. * @param onAnimationEnd Callback to run once the animation is complete
  113033. * @returns Nullable animation
  113034. */
  113035. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113036. /**
  113037. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  113038. * @param sourceAnimation defines the Animation containing keyframes to convert
  113039. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  113040. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  113041. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  113042. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  113043. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  113044. */
  113045. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  113046. /**
  113047. * Transition property of an host to the target Value
  113048. * @param property The property to transition
  113049. * @param targetValue The target Value of the property
  113050. * @param host The object where the property to animate belongs
  113051. * @param scene Scene used to run the animation
  113052. * @param frameRate Framerate (in frame/s) to use
  113053. * @param transition The transition type we want to use
  113054. * @param duration The duration of the animation, in milliseconds
  113055. * @param onAnimationEnd Callback trigger at the end of the animation
  113056. * @returns Nullable animation
  113057. */
  113058. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  113059. /**
  113060. * Return the array of runtime animations currently using this animation
  113061. */
  113062. get runtimeAnimations(): RuntimeAnimation[];
  113063. /**
  113064. * Specifies if any of the runtime animations are currently running
  113065. */
  113066. get hasRunningRuntimeAnimations(): boolean;
  113067. /**
  113068. * Initializes the animation
  113069. * @param name Name of the animation
  113070. * @param targetProperty Property to animate
  113071. * @param framePerSecond The frames per second of the animation
  113072. * @param dataType The data type of the animation
  113073. * @param loopMode The loop mode of the animation
  113074. * @param enableBlending Specifies if blending should be enabled
  113075. */
  113076. constructor(
  113077. /**Name of the animation */
  113078. name: string,
  113079. /**Property to animate */
  113080. targetProperty: string,
  113081. /**The frames per second of the animation */
  113082. framePerSecond: number,
  113083. /**The data type of the animation */
  113084. dataType: number,
  113085. /**The loop mode of the animation */
  113086. loopMode?: number | undefined,
  113087. /**Specifies if blending should be enabled */
  113088. enableBlending?: boolean | undefined);
  113089. /**
  113090. * Converts the animation to a string
  113091. * @param fullDetails support for multiple levels of logging within scene loading
  113092. * @returns String form of the animation
  113093. */
  113094. toString(fullDetails?: boolean): string;
  113095. /**
  113096. * Add an event to this animation
  113097. * @param event Event to add
  113098. */
  113099. addEvent(event: AnimationEvent): void;
  113100. /**
  113101. * Remove all events found at the given frame
  113102. * @param frame The frame to remove events from
  113103. */
  113104. removeEvents(frame: number): void;
  113105. /**
  113106. * Retrieves all the events from the animation
  113107. * @returns Events from the animation
  113108. */
  113109. getEvents(): AnimationEvent[];
  113110. /**
  113111. * Creates an animation range
  113112. * @param name Name of the animation range
  113113. * @param from Starting frame of the animation range
  113114. * @param to Ending frame of the animation
  113115. */
  113116. createRange(name: string, from: number, to: number): void;
  113117. /**
  113118. * Deletes an animation range by name
  113119. * @param name Name of the animation range to delete
  113120. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  113121. */
  113122. deleteRange(name: string, deleteFrames?: boolean): void;
  113123. /**
  113124. * Gets the animation range by name, or null if not defined
  113125. * @param name Name of the animation range
  113126. * @returns Nullable animation range
  113127. */
  113128. getRange(name: string): Nullable<AnimationRange>;
  113129. /**
  113130. * Gets the key frames from the animation
  113131. * @returns The key frames of the animation
  113132. */
  113133. getKeys(): Array<IAnimationKey>;
  113134. /**
  113135. * Gets the highest frame rate of the animation
  113136. * @returns Highest frame rate of the animation
  113137. */
  113138. getHighestFrame(): number;
  113139. /**
  113140. * Gets the easing function of the animation
  113141. * @returns Easing function of the animation
  113142. */
  113143. getEasingFunction(): IEasingFunction;
  113144. /**
  113145. * Sets the easing function of the animation
  113146. * @param easingFunction A custom mathematical formula for animation
  113147. */
  113148. setEasingFunction(easingFunction: EasingFunction): void;
  113149. /**
  113150. * Interpolates a scalar linearly
  113151. * @param startValue Start value of the animation curve
  113152. * @param endValue End value of the animation curve
  113153. * @param gradient Scalar amount to interpolate
  113154. * @returns Interpolated scalar value
  113155. */
  113156. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  113157. /**
  113158. * Interpolates a scalar cubically
  113159. * @param startValue Start value of the animation curve
  113160. * @param outTangent End tangent of the animation
  113161. * @param endValue End value of the animation curve
  113162. * @param inTangent Start tangent of the animation curve
  113163. * @param gradient Scalar amount to interpolate
  113164. * @returns Interpolated scalar value
  113165. */
  113166. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  113167. /**
  113168. * Interpolates a quaternion using a spherical linear interpolation
  113169. * @param startValue Start value of the animation curve
  113170. * @param endValue End value of the animation curve
  113171. * @param gradient Scalar amount to interpolate
  113172. * @returns Interpolated quaternion value
  113173. */
  113174. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  113175. /**
  113176. * Interpolates a quaternion cubically
  113177. * @param startValue Start value of the animation curve
  113178. * @param outTangent End tangent of the animation curve
  113179. * @param endValue End value of the animation curve
  113180. * @param inTangent Start tangent of the animation curve
  113181. * @param gradient Scalar amount to interpolate
  113182. * @returns Interpolated quaternion value
  113183. */
  113184. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  113185. /**
  113186. * Interpolates a Vector3 linearl
  113187. * @param startValue Start value of the animation curve
  113188. * @param endValue End value of the animation curve
  113189. * @param gradient Scalar amount to interpolate
  113190. * @returns Interpolated scalar value
  113191. */
  113192. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  113193. /**
  113194. * Interpolates a Vector3 cubically
  113195. * @param startValue Start value of the animation curve
  113196. * @param outTangent End tangent of the animation
  113197. * @param endValue End value of the animation curve
  113198. * @param inTangent Start tangent of the animation curve
  113199. * @param gradient Scalar amount to interpolate
  113200. * @returns InterpolatedVector3 value
  113201. */
  113202. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  113203. /**
  113204. * Interpolates a Vector2 linearly
  113205. * @param startValue Start value of the animation curve
  113206. * @param endValue End value of the animation curve
  113207. * @param gradient Scalar amount to interpolate
  113208. * @returns Interpolated Vector2 value
  113209. */
  113210. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  113211. /**
  113212. * Interpolates a Vector2 cubically
  113213. * @param startValue Start value of the animation curve
  113214. * @param outTangent End tangent of the animation
  113215. * @param endValue End value of the animation curve
  113216. * @param inTangent Start tangent of the animation curve
  113217. * @param gradient Scalar amount to interpolate
  113218. * @returns Interpolated Vector2 value
  113219. */
  113220. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  113221. /**
  113222. * Interpolates a size linearly
  113223. * @param startValue Start value of the animation curve
  113224. * @param endValue End value of the animation curve
  113225. * @param gradient Scalar amount to interpolate
  113226. * @returns Interpolated Size value
  113227. */
  113228. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  113229. /**
  113230. * Interpolates a Color3 linearly
  113231. * @param startValue Start value of the animation curve
  113232. * @param endValue End value of the animation curve
  113233. * @param gradient Scalar amount to interpolate
  113234. * @returns Interpolated Color3 value
  113235. */
  113236. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  113237. /**
  113238. * Interpolates a Color4 linearly
  113239. * @param startValue Start value of the animation curve
  113240. * @param endValue End value of the animation curve
  113241. * @param gradient Scalar amount to interpolate
  113242. * @returns Interpolated Color3 value
  113243. */
  113244. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  113245. /**
  113246. * @hidden Internal use only
  113247. */
  113248. _getKeyValue(value: any): any;
  113249. /**
  113250. * @hidden Internal use only
  113251. */
  113252. _interpolate(currentFrame: number, state: _IAnimationState): any;
  113253. /**
  113254. * Defines the function to use to interpolate matrices
  113255. * @param startValue defines the start matrix
  113256. * @param endValue defines the end matrix
  113257. * @param gradient defines the gradient between both matrices
  113258. * @param result defines an optional target matrix where to store the interpolation
  113259. * @returns the interpolated matrix
  113260. */
  113261. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  113262. /**
  113263. * Makes a copy of the animation
  113264. * @returns Cloned animation
  113265. */
  113266. clone(): Animation;
  113267. /**
  113268. * Sets the key frames of the animation
  113269. * @param values The animation key frames to set
  113270. */
  113271. setKeys(values: Array<IAnimationKey>): void;
  113272. /**
  113273. * Serializes the animation to an object
  113274. * @returns Serialized object
  113275. */
  113276. serialize(): any;
  113277. /**
  113278. * Float animation type
  113279. */
  113280. static readonly ANIMATIONTYPE_FLOAT: number;
  113281. /**
  113282. * Vector3 animation type
  113283. */
  113284. static readonly ANIMATIONTYPE_VECTOR3: number;
  113285. /**
  113286. * Quaternion animation type
  113287. */
  113288. static readonly ANIMATIONTYPE_QUATERNION: number;
  113289. /**
  113290. * Matrix animation type
  113291. */
  113292. static readonly ANIMATIONTYPE_MATRIX: number;
  113293. /**
  113294. * Color3 animation type
  113295. */
  113296. static readonly ANIMATIONTYPE_COLOR3: number;
  113297. /**
  113298. * Color3 animation type
  113299. */
  113300. static readonly ANIMATIONTYPE_COLOR4: number;
  113301. /**
  113302. * Vector2 animation type
  113303. */
  113304. static readonly ANIMATIONTYPE_VECTOR2: number;
  113305. /**
  113306. * Size animation type
  113307. */
  113308. static readonly ANIMATIONTYPE_SIZE: number;
  113309. /**
  113310. * Relative Loop Mode
  113311. */
  113312. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  113313. /**
  113314. * Cycle Loop Mode
  113315. */
  113316. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  113317. /**
  113318. * Constant Loop Mode
  113319. */
  113320. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  113321. /** @hidden */
  113322. static _UniversalLerp(left: any, right: any, amount: number): any;
  113323. /**
  113324. * Parses an animation object and creates an animation
  113325. * @param parsedAnimation Parsed animation object
  113326. * @returns Animation object
  113327. */
  113328. static Parse(parsedAnimation: any): Animation;
  113329. /**
  113330. * Appends the serialized animations from the source animations
  113331. * @param source Source containing the animations
  113332. * @param destination Target to store the animations
  113333. */
  113334. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  113335. /**
  113336. * Creates a new animation or an array of animations from a snippet saved in a remote file
  113337. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  113338. * @param url defines the url to load from
  113339. * @returns a promise that will resolve to the new animation or an array of animations
  113340. */
  113341. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  113342. /**
  113343. * Creates an animation or an array of animations from a snippet saved by the Inspector
  113344. * @param snippetId defines the snippet to load
  113345. * @returns a promise that will resolve to the new animation or a new array of animations
  113346. */
  113347. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  113348. }
  113349. }
  113350. declare module BABYLON {
  113351. /**
  113352. * Interface containing an array of animations
  113353. */
  113354. export interface IAnimatable {
  113355. /**
  113356. * Array of animations
  113357. */
  113358. animations: Nullable<Array<Animation>>;
  113359. }
  113360. }
  113361. declare module BABYLON {
  113362. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  113363. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113364. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113365. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113366. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113367. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113368. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113369. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113370. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113371. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113372. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113373. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113374. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113375. /**
  113376. * Decorator used to define property that can be serialized as reference to a camera
  113377. * @param sourceName defines the name of the property to decorate
  113378. */
  113379. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113380. /**
  113381. * Class used to help serialization objects
  113382. */
  113383. export class SerializationHelper {
  113384. /** @hidden */
  113385. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  113386. /** @hidden */
  113387. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  113388. /** @hidden */
  113389. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  113390. /** @hidden */
  113391. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  113392. /**
  113393. * Appends the serialized animations from the source animations
  113394. * @param source Source containing the animations
  113395. * @param destination Target to store the animations
  113396. */
  113397. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  113398. /**
  113399. * Static function used to serialized a specific entity
  113400. * @param entity defines the entity to serialize
  113401. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  113402. * @returns a JSON compatible object representing the serialization of the entity
  113403. */
  113404. static Serialize<T>(entity: T, serializationObject?: any): any;
  113405. /**
  113406. * Creates a new entity from a serialization data object
  113407. * @param creationFunction defines a function used to instanciated the new entity
  113408. * @param source defines the source serialization data
  113409. * @param scene defines the hosting scene
  113410. * @param rootUrl defines the root url for resources
  113411. * @returns a new entity
  113412. */
  113413. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  113414. /**
  113415. * Clones an object
  113416. * @param creationFunction defines the function used to instanciate the new object
  113417. * @param source defines the source object
  113418. * @returns the cloned object
  113419. */
  113420. static Clone<T>(creationFunction: () => T, source: T): T;
  113421. /**
  113422. * Instanciates a new object based on a source one (some data will be shared between both object)
  113423. * @param creationFunction defines the function used to instanciate the new object
  113424. * @param source defines the source object
  113425. * @returns the new object
  113426. */
  113427. static Instanciate<T>(creationFunction: () => T, source: T): T;
  113428. }
  113429. }
  113430. declare module BABYLON {
  113431. /**
  113432. * Base class of all the textures in babylon.
  113433. * It groups all the common properties the materials, post process, lights... might need
  113434. * in order to make a correct use of the texture.
  113435. */
  113436. export class BaseTexture implements IAnimatable {
  113437. /**
  113438. * Default anisotropic filtering level for the application.
  113439. * It is set to 4 as a good tradeoff between perf and quality.
  113440. */
  113441. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  113442. /**
  113443. * Gets or sets the unique id of the texture
  113444. */
  113445. uniqueId: number;
  113446. /**
  113447. * Define the name of the texture.
  113448. */
  113449. name: string;
  113450. /**
  113451. * Gets or sets an object used to store user defined information.
  113452. */
  113453. metadata: any;
  113454. /**
  113455. * For internal use only. Please do not use.
  113456. */
  113457. reservedDataStore: any;
  113458. private _hasAlpha;
  113459. /**
  113460. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  113461. */
  113462. set hasAlpha(value: boolean);
  113463. get hasAlpha(): boolean;
  113464. /**
  113465. * Defines if the alpha value should be determined via the rgb values.
  113466. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  113467. */
  113468. getAlphaFromRGB: boolean;
  113469. /**
  113470. * Intensity or strength of the texture.
  113471. * It is commonly used by materials to fine tune the intensity of the texture
  113472. */
  113473. level: number;
  113474. /**
  113475. * Define the UV chanel to use starting from 0 and defaulting to 0.
  113476. * This is part of the texture as textures usually maps to one uv set.
  113477. */
  113478. coordinatesIndex: number;
  113479. private _coordinatesMode;
  113480. /**
  113481. * How a texture is mapped.
  113482. *
  113483. * | Value | Type | Description |
  113484. * | ----- | ----------------------------------- | ----------- |
  113485. * | 0 | EXPLICIT_MODE | |
  113486. * | 1 | SPHERICAL_MODE | |
  113487. * | 2 | PLANAR_MODE | |
  113488. * | 3 | CUBIC_MODE | |
  113489. * | 4 | PROJECTION_MODE | |
  113490. * | 5 | SKYBOX_MODE | |
  113491. * | 6 | INVCUBIC_MODE | |
  113492. * | 7 | EQUIRECTANGULAR_MODE | |
  113493. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  113494. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  113495. */
  113496. set coordinatesMode(value: number);
  113497. get coordinatesMode(): number;
  113498. /**
  113499. * | Value | Type | Description |
  113500. * | ----- | ------------------ | ----------- |
  113501. * | 0 | CLAMP_ADDRESSMODE | |
  113502. * | 1 | WRAP_ADDRESSMODE | |
  113503. * | 2 | MIRROR_ADDRESSMODE | |
  113504. */
  113505. wrapU: number;
  113506. /**
  113507. * | Value | Type | Description |
  113508. * | ----- | ------------------ | ----------- |
  113509. * | 0 | CLAMP_ADDRESSMODE | |
  113510. * | 1 | WRAP_ADDRESSMODE | |
  113511. * | 2 | MIRROR_ADDRESSMODE | |
  113512. */
  113513. wrapV: number;
  113514. /**
  113515. * | Value | Type | Description |
  113516. * | ----- | ------------------ | ----------- |
  113517. * | 0 | CLAMP_ADDRESSMODE | |
  113518. * | 1 | WRAP_ADDRESSMODE | |
  113519. * | 2 | MIRROR_ADDRESSMODE | |
  113520. */
  113521. wrapR: number;
  113522. /**
  113523. * With compliant hardware and browser (supporting anisotropic filtering)
  113524. * this defines the level of anisotropic filtering in the texture.
  113525. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  113526. */
  113527. anisotropicFilteringLevel: number;
  113528. /**
  113529. * Define if the texture is a cube texture or if false a 2d texture.
  113530. */
  113531. get isCube(): boolean;
  113532. set isCube(value: boolean);
  113533. /**
  113534. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  113535. */
  113536. get is3D(): boolean;
  113537. set is3D(value: boolean);
  113538. /**
  113539. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  113540. */
  113541. get is2DArray(): boolean;
  113542. set is2DArray(value: boolean);
  113543. /**
  113544. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  113545. * HDR texture are usually stored in linear space.
  113546. * This only impacts the PBR and Background materials
  113547. */
  113548. gammaSpace: boolean;
  113549. /**
  113550. * Gets or sets whether or not the texture contains RGBD data.
  113551. */
  113552. get isRGBD(): boolean;
  113553. set isRGBD(value: boolean);
  113554. /**
  113555. * Is Z inverted in the texture (useful in a cube texture).
  113556. */
  113557. invertZ: boolean;
  113558. /**
  113559. * Are mip maps generated for this texture or not.
  113560. */
  113561. get noMipmap(): boolean;
  113562. /**
  113563. * @hidden
  113564. */
  113565. lodLevelInAlpha: boolean;
  113566. /**
  113567. * With prefiltered texture, defined the offset used during the prefiltering steps.
  113568. */
  113569. get lodGenerationOffset(): number;
  113570. set lodGenerationOffset(value: number);
  113571. /**
  113572. * With prefiltered texture, defined the scale used during the prefiltering steps.
  113573. */
  113574. get lodGenerationScale(): number;
  113575. set lodGenerationScale(value: number);
  113576. /**
  113577. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  113578. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  113579. * average roughness values.
  113580. */
  113581. get linearSpecularLOD(): boolean;
  113582. set linearSpecularLOD(value: boolean);
  113583. /**
  113584. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  113585. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  113586. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  113587. */
  113588. get irradianceTexture(): Nullable<BaseTexture>;
  113589. set irradianceTexture(value: Nullable<BaseTexture>);
  113590. /**
  113591. * Define if the texture is a render target.
  113592. */
  113593. isRenderTarget: boolean;
  113594. /**
  113595. * Define the unique id of the texture in the scene.
  113596. */
  113597. get uid(): string;
  113598. /** @hidden */
  113599. _prefiltered: boolean;
  113600. /**
  113601. * Return a string representation of the texture.
  113602. * @returns the texture as a string
  113603. */
  113604. toString(): string;
  113605. /**
  113606. * Get the class name of the texture.
  113607. * @returns "BaseTexture"
  113608. */
  113609. getClassName(): string;
  113610. /**
  113611. * Define the list of animation attached to the texture.
  113612. */
  113613. animations: Animation[];
  113614. /**
  113615. * An event triggered when the texture is disposed.
  113616. */
  113617. onDisposeObservable: Observable<BaseTexture>;
  113618. private _onDisposeObserver;
  113619. /**
  113620. * Callback triggered when the texture has been disposed.
  113621. * Kept for back compatibility, you can use the onDisposeObservable instead.
  113622. */
  113623. set onDispose(callback: () => void);
  113624. /**
  113625. * Define the current state of the loading sequence when in delayed load mode.
  113626. */
  113627. delayLoadState: number;
  113628. protected _scene: Nullable<Scene>;
  113629. protected _engine: Nullable<ThinEngine>;
  113630. /** @hidden */
  113631. _texture: Nullable<InternalTexture>;
  113632. private _uid;
  113633. /**
  113634. * Define if the texture is preventinga material to render or not.
  113635. * If not and the texture is not ready, the engine will use a default black texture instead.
  113636. */
  113637. get isBlocking(): boolean;
  113638. /**
  113639. * Instantiates a new BaseTexture.
  113640. * Base class of all the textures in babylon.
  113641. * It groups all the common properties the materials, post process, lights... might need
  113642. * in order to make a correct use of the texture.
  113643. * @param sceneOrEngine Define the scene or engine the texture blongs to
  113644. */
  113645. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  113646. /**
  113647. * Get the scene the texture belongs to.
  113648. * @returns the scene or null if undefined
  113649. */
  113650. getScene(): Nullable<Scene>;
  113651. /** @hidden */
  113652. protected _getEngine(): Nullable<ThinEngine>;
  113653. /**
  113654. * Get the texture transform matrix used to offset tile the texture for istance.
  113655. * @returns the transformation matrix
  113656. */
  113657. getTextureMatrix(): Matrix;
  113658. /**
  113659. * Get the texture reflection matrix used to rotate/transform the reflection.
  113660. * @returns the reflection matrix
  113661. */
  113662. getReflectionTextureMatrix(): Matrix;
  113663. /**
  113664. * Get the underlying lower level texture from Babylon.
  113665. * @returns the insternal texture
  113666. */
  113667. getInternalTexture(): Nullable<InternalTexture>;
  113668. /**
  113669. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  113670. * @returns true if ready or not blocking
  113671. */
  113672. isReadyOrNotBlocking(): boolean;
  113673. /**
  113674. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  113675. * @returns true if fully ready
  113676. */
  113677. isReady(): boolean;
  113678. private _cachedSize;
  113679. /**
  113680. * Get the size of the texture.
  113681. * @returns the texture size.
  113682. */
  113683. getSize(): ISize;
  113684. /**
  113685. * Get the base size of the texture.
  113686. * It can be different from the size if the texture has been resized for POT for instance
  113687. * @returns the base size
  113688. */
  113689. getBaseSize(): ISize;
  113690. /**
  113691. * Update the sampling mode of the texture.
  113692. * Default is Trilinear mode.
  113693. *
  113694. * | Value | Type | Description |
  113695. * | ----- | ------------------ | ----------- |
  113696. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  113697. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  113698. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  113699. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  113700. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  113701. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  113702. * | 7 | NEAREST_LINEAR | |
  113703. * | 8 | NEAREST_NEAREST | |
  113704. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  113705. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  113706. * | 11 | LINEAR_LINEAR | |
  113707. * | 12 | LINEAR_NEAREST | |
  113708. *
  113709. * > _mag_: magnification filter (close to the viewer)
  113710. * > _min_: minification filter (far from the viewer)
  113711. * > _mip_: filter used between mip map levels
  113712. *@param samplingMode Define the new sampling mode of the texture
  113713. */
  113714. updateSamplingMode(samplingMode: number): void;
  113715. /**
  113716. * Scales the texture if is `canRescale()`
  113717. * @param ratio the resize factor we want to use to rescale
  113718. */
  113719. scale(ratio: number): void;
  113720. /**
  113721. * Get if the texture can rescale.
  113722. */
  113723. get canRescale(): boolean;
  113724. /** @hidden */
  113725. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  113726. /** @hidden */
  113727. _rebuild(): void;
  113728. /**
  113729. * Triggers the load sequence in delayed load mode.
  113730. */
  113731. delayLoad(): void;
  113732. /**
  113733. * Clones the texture.
  113734. * @returns the cloned texture
  113735. */
  113736. clone(): Nullable<BaseTexture>;
  113737. /**
  113738. * Get the texture underlying type (INT, FLOAT...)
  113739. */
  113740. get textureType(): number;
  113741. /**
  113742. * Get the texture underlying format (RGB, RGBA...)
  113743. */
  113744. get textureFormat(): number;
  113745. /**
  113746. * Indicates that textures need to be re-calculated for all materials
  113747. */
  113748. protected _markAllSubMeshesAsTexturesDirty(): void;
  113749. /**
  113750. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  113751. * This will returns an RGBA array buffer containing either in values (0-255) or
  113752. * float values (0-1) depending of the underlying buffer type.
  113753. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  113754. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  113755. * @param buffer defines a user defined buffer to fill with data (can be null)
  113756. * @returns The Array buffer containing the pixels data.
  113757. */
  113758. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  113759. /**
  113760. * Release and destroy the underlying lower level texture aka internalTexture.
  113761. */
  113762. releaseInternalTexture(): void;
  113763. /** @hidden */
  113764. get _lodTextureHigh(): Nullable<BaseTexture>;
  113765. /** @hidden */
  113766. get _lodTextureMid(): Nullable<BaseTexture>;
  113767. /** @hidden */
  113768. get _lodTextureLow(): Nullable<BaseTexture>;
  113769. /**
  113770. * Dispose the texture and release its associated resources.
  113771. */
  113772. dispose(): void;
  113773. /**
  113774. * Serialize the texture into a JSON representation that can be parsed later on.
  113775. * @returns the JSON representation of the texture
  113776. */
  113777. serialize(): any;
  113778. /**
  113779. * Helper function to be called back once a list of texture contains only ready textures.
  113780. * @param textures Define the list of textures to wait for
  113781. * @param callback Define the callback triggered once the entire list will be ready
  113782. */
  113783. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  113784. private static _isScene;
  113785. }
  113786. }
  113787. declare module BABYLON {
  113788. /**
  113789. * Options to be used when creating an effect.
  113790. */
  113791. export interface IEffectCreationOptions {
  113792. /**
  113793. * Atrributes that will be used in the shader.
  113794. */
  113795. attributes: string[];
  113796. /**
  113797. * Uniform varible names that will be set in the shader.
  113798. */
  113799. uniformsNames: string[];
  113800. /**
  113801. * Uniform buffer variable names that will be set in the shader.
  113802. */
  113803. uniformBuffersNames: string[];
  113804. /**
  113805. * Sampler texture variable names that will be set in the shader.
  113806. */
  113807. samplers: string[];
  113808. /**
  113809. * Define statements that will be set in the shader.
  113810. */
  113811. defines: any;
  113812. /**
  113813. * Possible fallbacks for this effect to improve performance when needed.
  113814. */
  113815. fallbacks: Nullable<IEffectFallbacks>;
  113816. /**
  113817. * Callback that will be called when the shader is compiled.
  113818. */
  113819. onCompiled: Nullable<(effect: Effect) => void>;
  113820. /**
  113821. * Callback that will be called if an error occurs during shader compilation.
  113822. */
  113823. onError: Nullable<(effect: Effect, errors: string) => void>;
  113824. /**
  113825. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  113826. */
  113827. indexParameters?: any;
  113828. /**
  113829. * Max number of lights that can be used in the shader.
  113830. */
  113831. maxSimultaneousLights?: number;
  113832. /**
  113833. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  113834. */
  113835. transformFeedbackVaryings?: Nullable<string[]>;
  113836. /**
  113837. * 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
  113838. */
  113839. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  113840. /**
  113841. * Is this effect rendering to several color attachments ?
  113842. */
  113843. multiTarget?: boolean;
  113844. }
  113845. /**
  113846. * Effect containing vertex and fragment shader that can be executed on an object.
  113847. */
  113848. export class Effect implements IDisposable {
  113849. /**
  113850. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  113851. */
  113852. static ShadersRepository: string;
  113853. /**
  113854. * Enable logging of the shader code when a compilation error occurs
  113855. */
  113856. static LogShaderCodeOnCompilationError: boolean;
  113857. /**
  113858. * Name of the effect.
  113859. */
  113860. name: any;
  113861. /**
  113862. * String container all the define statements that should be set on the shader.
  113863. */
  113864. defines: string;
  113865. /**
  113866. * Callback that will be called when the shader is compiled.
  113867. */
  113868. onCompiled: Nullable<(effect: Effect) => void>;
  113869. /**
  113870. * Callback that will be called if an error occurs during shader compilation.
  113871. */
  113872. onError: Nullable<(effect: Effect, errors: string) => void>;
  113873. /**
  113874. * Callback that will be called when effect is bound.
  113875. */
  113876. onBind: Nullable<(effect: Effect) => void>;
  113877. /**
  113878. * Unique ID of the effect.
  113879. */
  113880. uniqueId: number;
  113881. /**
  113882. * Observable that will be called when the shader is compiled.
  113883. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  113884. */
  113885. onCompileObservable: Observable<Effect>;
  113886. /**
  113887. * Observable that will be called if an error occurs during shader compilation.
  113888. */
  113889. onErrorObservable: Observable<Effect>;
  113890. /** @hidden */
  113891. _onBindObservable: Nullable<Observable<Effect>>;
  113892. /**
  113893. * @hidden
  113894. * Specifies if the effect was previously ready
  113895. */
  113896. _wasPreviouslyReady: boolean;
  113897. /**
  113898. * Observable that will be called when effect is bound.
  113899. */
  113900. get onBindObservable(): Observable<Effect>;
  113901. /** @hidden */
  113902. _bonesComputationForcedToCPU: boolean;
  113903. /** @hidden */
  113904. _multiTarget: boolean;
  113905. private static _uniqueIdSeed;
  113906. private _engine;
  113907. private _uniformBuffersNames;
  113908. private _uniformBuffersNamesList;
  113909. private _uniformsNames;
  113910. private _samplerList;
  113911. private _samplers;
  113912. private _isReady;
  113913. private _compilationError;
  113914. private _allFallbacksProcessed;
  113915. private _attributesNames;
  113916. private _attributes;
  113917. private _attributeLocationByName;
  113918. private _uniforms;
  113919. /**
  113920. * Key for the effect.
  113921. * @hidden
  113922. */
  113923. _key: string;
  113924. private _indexParameters;
  113925. private _fallbacks;
  113926. private _vertexSourceCode;
  113927. private _fragmentSourceCode;
  113928. private _vertexSourceCodeOverride;
  113929. private _fragmentSourceCodeOverride;
  113930. private _transformFeedbackVaryings;
  113931. /**
  113932. * Compiled shader to webGL program.
  113933. * @hidden
  113934. */
  113935. _pipelineContext: Nullable<IPipelineContext>;
  113936. private _valueCache;
  113937. private static _baseCache;
  113938. /**
  113939. * Instantiates an effect.
  113940. * An effect can be used to create/manage/execute vertex and fragment shaders.
  113941. * @param baseName Name of the effect.
  113942. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  113943. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  113944. * @param samplers List of sampler variables that will be passed to the shader.
  113945. * @param engine Engine to be used to render the effect
  113946. * @param defines Define statements to be added to the shader.
  113947. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  113948. * @param onCompiled Callback that will be called when the shader is compiled.
  113949. * @param onError Callback that will be called if an error occurs during shader compilation.
  113950. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  113951. */
  113952. 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);
  113953. private _useFinalCode;
  113954. /**
  113955. * Unique key for this effect
  113956. */
  113957. get key(): string;
  113958. /**
  113959. * If the effect has been compiled and prepared.
  113960. * @returns if the effect is compiled and prepared.
  113961. */
  113962. isReady(): boolean;
  113963. private _isReadyInternal;
  113964. /**
  113965. * The engine the effect was initialized with.
  113966. * @returns the engine.
  113967. */
  113968. getEngine(): Engine;
  113969. /**
  113970. * The pipeline context for this effect
  113971. * @returns the associated pipeline context
  113972. */
  113973. getPipelineContext(): Nullable<IPipelineContext>;
  113974. /**
  113975. * The set of names of attribute variables for the shader.
  113976. * @returns An array of attribute names.
  113977. */
  113978. getAttributesNames(): string[];
  113979. /**
  113980. * Returns the attribute at the given index.
  113981. * @param index The index of the attribute.
  113982. * @returns The location of the attribute.
  113983. */
  113984. getAttributeLocation(index: number): number;
  113985. /**
  113986. * Returns the attribute based on the name of the variable.
  113987. * @param name of the attribute to look up.
  113988. * @returns the attribute location.
  113989. */
  113990. getAttributeLocationByName(name: string): number;
  113991. /**
  113992. * The number of attributes.
  113993. * @returns the numnber of attributes.
  113994. */
  113995. getAttributesCount(): number;
  113996. /**
  113997. * Gets the index of a uniform variable.
  113998. * @param uniformName of the uniform to look up.
  113999. * @returns the index.
  114000. */
  114001. getUniformIndex(uniformName: string): number;
  114002. /**
  114003. * Returns the attribute based on the name of the variable.
  114004. * @param uniformName of the uniform to look up.
  114005. * @returns the location of the uniform.
  114006. */
  114007. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  114008. /**
  114009. * Returns an array of sampler variable names
  114010. * @returns The array of sampler variable names.
  114011. */
  114012. getSamplers(): string[];
  114013. /**
  114014. * Returns an array of uniform variable names
  114015. * @returns The array of uniform variable names.
  114016. */
  114017. getUniformNames(): string[];
  114018. /**
  114019. * Returns an array of uniform buffer variable names
  114020. * @returns The array of uniform buffer variable names.
  114021. */
  114022. getUniformBuffersNames(): string[];
  114023. /**
  114024. * Returns the index parameters used to create the effect
  114025. * @returns The index parameters object
  114026. */
  114027. getIndexParameters(): any;
  114028. /**
  114029. * The error from the last compilation.
  114030. * @returns the error string.
  114031. */
  114032. getCompilationError(): string;
  114033. /**
  114034. * Gets a boolean indicating that all fallbacks were used during compilation
  114035. * @returns true if all fallbacks were used
  114036. */
  114037. allFallbacksProcessed(): boolean;
  114038. /**
  114039. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  114040. * @param func The callback to be used.
  114041. */
  114042. executeWhenCompiled(func: (effect: Effect) => void): void;
  114043. private _checkIsReady;
  114044. private _loadShader;
  114045. /**
  114046. * Gets the vertex shader source code of this effect
  114047. */
  114048. get vertexSourceCode(): string;
  114049. /**
  114050. * Gets the fragment shader source code of this effect
  114051. */
  114052. get fragmentSourceCode(): string;
  114053. /**
  114054. * Recompiles the webGL program
  114055. * @param vertexSourceCode The source code for the vertex shader.
  114056. * @param fragmentSourceCode The source code for the fragment shader.
  114057. * @param onCompiled Callback called when completed.
  114058. * @param onError Callback called on error.
  114059. * @hidden
  114060. */
  114061. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  114062. /**
  114063. * Prepares the effect
  114064. * @hidden
  114065. */
  114066. _prepareEffect(): void;
  114067. private _getShaderCodeAndErrorLine;
  114068. private _processCompilationErrors;
  114069. /**
  114070. * Checks if the effect is supported. (Must be called after compilation)
  114071. */
  114072. get isSupported(): boolean;
  114073. /**
  114074. * Binds a texture to the engine to be used as output of the shader.
  114075. * @param channel Name of the output variable.
  114076. * @param texture Texture to bind.
  114077. * @hidden
  114078. */
  114079. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  114080. /**
  114081. * Sets a texture on the engine to be used in the shader.
  114082. * @param channel Name of the sampler variable.
  114083. * @param texture Texture to set.
  114084. */
  114085. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  114086. /**
  114087. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  114088. * @param channel Name of the sampler variable.
  114089. * @param texture Texture to set.
  114090. */
  114091. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  114092. /**
  114093. * Sets an array of textures on the engine to be used in the shader.
  114094. * @param channel Name of the variable.
  114095. * @param textures Textures to set.
  114096. */
  114097. setTextureArray(channel: string, textures: BaseTexture[]): void;
  114098. /**
  114099. * 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)
  114100. * @param channel Name of the sampler variable.
  114101. * @param postProcess Post process to get the input texture from.
  114102. */
  114103. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  114104. /**
  114105. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  114106. * 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)
  114107. * @param channel Name of the sampler variable.
  114108. * @param postProcess Post process to get the output texture from.
  114109. */
  114110. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  114111. /** @hidden */
  114112. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  114113. /** @hidden */
  114114. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  114115. /** @hidden */
  114116. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  114117. /** @hidden */
  114118. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  114119. /**
  114120. * Binds a buffer to a uniform.
  114121. * @param buffer Buffer to bind.
  114122. * @param name Name of the uniform variable to bind to.
  114123. */
  114124. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  114125. /**
  114126. * Binds block to a uniform.
  114127. * @param blockName Name of the block to bind.
  114128. * @param index Index to bind.
  114129. */
  114130. bindUniformBlock(blockName: string, index: number): void;
  114131. /**
  114132. * Sets an interger value on a uniform variable.
  114133. * @param uniformName Name of the variable.
  114134. * @param value Value to be set.
  114135. * @returns this effect.
  114136. */
  114137. setInt(uniformName: string, value: number): Effect;
  114138. /**
  114139. * Sets an int array on a uniform variable.
  114140. * @param uniformName Name of the variable.
  114141. * @param array array to be set.
  114142. * @returns this effect.
  114143. */
  114144. setIntArray(uniformName: string, array: Int32Array): Effect;
  114145. /**
  114146. * 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)
  114147. * @param uniformName Name of the variable.
  114148. * @param array array to be set.
  114149. * @returns this effect.
  114150. */
  114151. setIntArray2(uniformName: string, array: Int32Array): Effect;
  114152. /**
  114153. * 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)
  114154. * @param uniformName Name of the variable.
  114155. * @param array array to be set.
  114156. * @returns this effect.
  114157. */
  114158. setIntArray3(uniformName: string, array: Int32Array): Effect;
  114159. /**
  114160. * 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)
  114161. * @param uniformName Name of the variable.
  114162. * @param array array to be set.
  114163. * @returns this effect.
  114164. */
  114165. setIntArray4(uniformName: string, array: Int32Array): Effect;
  114166. /**
  114167. * Sets an float array on a uniform variable.
  114168. * @param uniformName Name of the variable.
  114169. * @param array array to be set.
  114170. * @returns this effect.
  114171. */
  114172. setFloatArray(uniformName: string, array: Float32Array): Effect;
  114173. /**
  114174. * 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)
  114175. * @param uniformName Name of the variable.
  114176. * @param array array to be set.
  114177. * @returns this effect.
  114178. */
  114179. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  114180. /**
  114181. * 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)
  114182. * @param uniformName Name of the variable.
  114183. * @param array array to be set.
  114184. * @returns this effect.
  114185. */
  114186. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  114187. /**
  114188. * 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)
  114189. * @param uniformName Name of the variable.
  114190. * @param array array to be set.
  114191. * @returns this effect.
  114192. */
  114193. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  114194. /**
  114195. * Sets an array on a uniform variable.
  114196. * @param uniformName Name of the variable.
  114197. * @param array array to be set.
  114198. * @returns this effect.
  114199. */
  114200. setArray(uniformName: string, array: number[]): Effect;
  114201. /**
  114202. * 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)
  114203. * @param uniformName Name of the variable.
  114204. * @param array array to be set.
  114205. * @returns this effect.
  114206. */
  114207. setArray2(uniformName: string, array: number[]): Effect;
  114208. /**
  114209. * 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)
  114210. * @param uniformName Name of the variable.
  114211. * @param array array to be set.
  114212. * @returns this effect.
  114213. */
  114214. setArray3(uniformName: string, array: number[]): Effect;
  114215. /**
  114216. * 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)
  114217. * @param uniformName Name of the variable.
  114218. * @param array array to be set.
  114219. * @returns this effect.
  114220. */
  114221. setArray4(uniformName: string, array: number[]): Effect;
  114222. /**
  114223. * Sets matrices on a uniform variable.
  114224. * @param uniformName Name of the variable.
  114225. * @param matrices matrices to be set.
  114226. * @returns this effect.
  114227. */
  114228. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  114229. /**
  114230. * Sets matrix on a uniform variable.
  114231. * @param uniformName Name of the variable.
  114232. * @param matrix matrix to be set.
  114233. * @returns this effect.
  114234. */
  114235. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  114236. /**
  114237. * 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)
  114238. * @param uniformName Name of the variable.
  114239. * @param matrix matrix to be set.
  114240. * @returns this effect.
  114241. */
  114242. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  114243. /**
  114244. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  114245. * @param uniformName Name of the variable.
  114246. * @param matrix matrix to be set.
  114247. * @returns this effect.
  114248. */
  114249. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  114250. /**
  114251. * Sets a float on a uniform variable.
  114252. * @param uniformName Name of the variable.
  114253. * @param value value to be set.
  114254. * @returns this effect.
  114255. */
  114256. setFloat(uniformName: string, value: number): Effect;
  114257. /**
  114258. * Sets a boolean on a uniform variable.
  114259. * @param uniformName Name of the variable.
  114260. * @param bool value to be set.
  114261. * @returns this effect.
  114262. */
  114263. setBool(uniformName: string, bool: boolean): Effect;
  114264. /**
  114265. * Sets a Vector2 on a uniform variable.
  114266. * @param uniformName Name of the variable.
  114267. * @param vector2 vector2 to be set.
  114268. * @returns this effect.
  114269. */
  114270. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  114271. /**
  114272. * Sets a float2 on a uniform variable.
  114273. * @param uniformName Name of the variable.
  114274. * @param x First float in float2.
  114275. * @param y Second float in float2.
  114276. * @returns this effect.
  114277. */
  114278. setFloat2(uniformName: string, x: number, y: number): Effect;
  114279. /**
  114280. * Sets a Vector3 on a uniform variable.
  114281. * @param uniformName Name of the variable.
  114282. * @param vector3 Value to be set.
  114283. * @returns this effect.
  114284. */
  114285. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  114286. /**
  114287. * Sets a float3 on a uniform variable.
  114288. * @param uniformName Name of the variable.
  114289. * @param x First float in float3.
  114290. * @param y Second float in float3.
  114291. * @param z Third float in float3.
  114292. * @returns this effect.
  114293. */
  114294. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  114295. /**
  114296. * Sets a Vector4 on a uniform variable.
  114297. * @param uniformName Name of the variable.
  114298. * @param vector4 Value to be set.
  114299. * @returns this effect.
  114300. */
  114301. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  114302. /**
  114303. * Sets a float4 on a uniform variable.
  114304. * @param uniformName Name of the variable.
  114305. * @param x First float in float4.
  114306. * @param y Second float in float4.
  114307. * @param z Third float in float4.
  114308. * @param w Fourth float in float4.
  114309. * @returns this effect.
  114310. */
  114311. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  114312. /**
  114313. * Sets a Color3 on a uniform variable.
  114314. * @param uniformName Name of the variable.
  114315. * @param color3 Value to be set.
  114316. * @returns this effect.
  114317. */
  114318. setColor3(uniformName: string, color3: IColor3Like): Effect;
  114319. /**
  114320. * Sets a Color4 on a uniform variable.
  114321. * @param uniformName Name of the variable.
  114322. * @param color3 Value to be set.
  114323. * @param alpha Alpha value to be set.
  114324. * @returns this effect.
  114325. */
  114326. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  114327. /**
  114328. * Sets a Color4 on a uniform variable
  114329. * @param uniformName defines the name of the variable
  114330. * @param color4 defines the value to be set
  114331. * @returns this effect.
  114332. */
  114333. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  114334. /** Release all associated resources */
  114335. dispose(): void;
  114336. /**
  114337. * This function will add a new shader to the shader store
  114338. * @param name the name of the shader
  114339. * @param pixelShader optional pixel shader content
  114340. * @param vertexShader optional vertex shader content
  114341. */
  114342. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  114343. /**
  114344. * Store of each shader (The can be looked up using effect.key)
  114345. */
  114346. static ShadersStore: {
  114347. [key: string]: string;
  114348. };
  114349. /**
  114350. * Store of each included file for a shader (The can be looked up using effect.key)
  114351. */
  114352. static IncludesShadersStore: {
  114353. [key: string]: string;
  114354. };
  114355. /**
  114356. * Resets the cache of effects.
  114357. */
  114358. static ResetCache(): void;
  114359. }
  114360. }
  114361. declare module BABYLON {
  114362. /**
  114363. * Interface used to describe the capabilities of the engine relatively to the current browser
  114364. */
  114365. export interface EngineCapabilities {
  114366. /** Maximum textures units per fragment shader */
  114367. maxTexturesImageUnits: number;
  114368. /** Maximum texture units per vertex shader */
  114369. maxVertexTextureImageUnits: number;
  114370. /** Maximum textures units in the entire pipeline */
  114371. maxCombinedTexturesImageUnits: number;
  114372. /** Maximum texture size */
  114373. maxTextureSize: number;
  114374. /** Maximum texture samples */
  114375. maxSamples?: number;
  114376. /** Maximum cube texture size */
  114377. maxCubemapTextureSize: number;
  114378. /** Maximum render texture size */
  114379. maxRenderTextureSize: number;
  114380. /** Maximum number of vertex attributes */
  114381. maxVertexAttribs: number;
  114382. /** Maximum number of varyings */
  114383. maxVaryingVectors: number;
  114384. /** Maximum number of uniforms per vertex shader */
  114385. maxVertexUniformVectors: number;
  114386. /** Maximum number of uniforms per fragment shader */
  114387. maxFragmentUniformVectors: number;
  114388. /** Defines if standard derivates (dx/dy) are supported */
  114389. standardDerivatives: boolean;
  114390. /** Defines if s3tc texture compression is supported */
  114391. s3tc?: WEBGL_compressed_texture_s3tc;
  114392. /** Defines if pvrtc texture compression is supported */
  114393. pvrtc: any;
  114394. /** Defines if etc1 texture compression is supported */
  114395. etc1: any;
  114396. /** Defines if etc2 texture compression is supported */
  114397. etc2: any;
  114398. /** Defines if astc texture compression is supported */
  114399. astc: any;
  114400. /** Defines if float textures are supported */
  114401. textureFloat: boolean;
  114402. /** Defines if vertex array objects are supported */
  114403. vertexArrayObject: boolean;
  114404. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  114405. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  114406. /** Gets the maximum level of anisotropy supported */
  114407. maxAnisotropy: number;
  114408. /** Defines if instancing is supported */
  114409. instancedArrays: boolean;
  114410. /** Defines if 32 bits indices are supported */
  114411. uintIndices: boolean;
  114412. /** Defines if high precision shaders are supported */
  114413. highPrecisionShaderSupported: boolean;
  114414. /** Defines if depth reading in the fragment shader is supported */
  114415. fragmentDepthSupported: boolean;
  114416. /** Defines if float texture linear filtering is supported*/
  114417. textureFloatLinearFiltering: boolean;
  114418. /** Defines if rendering to float textures is supported */
  114419. textureFloatRender: boolean;
  114420. /** Defines if half float textures are supported*/
  114421. textureHalfFloat: boolean;
  114422. /** Defines if half float texture linear filtering is supported*/
  114423. textureHalfFloatLinearFiltering: boolean;
  114424. /** Defines if rendering to half float textures is supported */
  114425. textureHalfFloatRender: boolean;
  114426. /** Defines if textureLOD shader command is supported */
  114427. textureLOD: boolean;
  114428. /** Defines if draw buffers extension is supported */
  114429. drawBuffersExtension: boolean;
  114430. /** Defines if depth textures are supported */
  114431. depthTextureExtension: boolean;
  114432. /** Defines if float color buffer are supported */
  114433. colorBufferFloat: boolean;
  114434. /** Gets disjoint timer query extension (null if not supported) */
  114435. timerQuery?: EXT_disjoint_timer_query;
  114436. /** Defines if timestamp can be used with timer query */
  114437. canUseTimestampForTimerQuery: boolean;
  114438. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  114439. multiview?: any;
  114440. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  114441. oculusMultiview?: any;
  114442. /** Function used to let the system compiles shaders in background */
  114443. parallelShaderCompile?: {
  114444. COMPLETION_STATUS_KHR: number;
  114445. };
  114446. /** Max number of texture samples for MSAA */
  114447. maxMSAASamples: number;
  114448. /** Defines if the blend min max extension is supported */
  114449. blendMinMax: boolean;
  114450. }
  114451. }
  114452. declare module BABYLON {
  114453. /**
  114454. * @hidden
  114455. **/
  114456. export class DepthCullingState {
  114457. private _isDepthTestDirty;
  114458. private _isDepthMaskDirty;
  114459. private _isDepthFuncDirty;
  114460. private _isCullFaceDirty;
  114461. private _isCullDirty;
  114462. private _isZOffsetDirty;
  114463. private _isFrontFaceDirty;
  114464. private _depthTest;
  114465. private _depthMask;
  114466. private _depthFunc;
  114467. private _cull;
  114468. private _cullFace;
  114469. private _zOffset;
  114470. private _frontFace;
  114471. /**
  114472. * Initializes the state.
  114473. */
  114474. constructor();
  114475. get isDirty(): boolean;
  114476. get zOffset(): number;
  114477. set zOffset(value: number);
  114478. get cullFace(): Nullable<number>;
  114479. set cullFace(value: Nullable<number>);
  114480. get cull(): Nullable<boolean>;
  114481. set cull(value: Nullable<boolean>);
  114482. get depthFunc(): Nullable<number>;
  114483. set depthFunc(value: Nullable<number>);
  114484. get depthMask(): boolean;
  114485. set depthMask(value: boolean);
  114486. get depthTest(): boolean;
  114487. set depthTest(value: boolean);
  114488. get frontFace(): Nullable<number>;
  114489. set frontFace(value: Nullable<number>);
  114490. reset(): void;
  114491. apply(gl: WebGLRenderingContext): void;
  114492. }
  114493. }
  114494. declare module BABYLON {
  114495. /**
  114496. * @hidden
  114497. **/
  114498. export class StencilState {
  114499. /** 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 */
  114500. static readonly ALWAYS: number;
  114501. /** Passed to stencilOperation to specify that stencil value must be kept */
  114502. static readonly KEEP: number;
  114503. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114504. static readonly REPLACE: number;
  114505. private _isStencilTestDirty;
  114506. private _isStencilMaskDirty;
  114507. private _isStencilFuncDirty;
  114508. private _isStencilOpDirty;
  114509. private _stencilTest;
  114510. private _stencilMask;
  114511. private _stencilFunc;
  114512. private _stencilFuncRef;
  114513. private _stencilFuncMask;
  114514. private _stencilOpStencilFail;
  114515. private _stencilOpDepthFail;
  114516. private _stencilOpStencilDepthPass;
  114517. get isDirty(): boolean;
  114518. get stencilFunc(): number;
  114519. set stencilFunc(value: number);
  114520. get stencilFuncRef(): number;
  114521. set stencilFuncRef(value: number);
  114522. get stencilFuncMask(): number;
  114523. set stencilFuncMask(value: number);
  114524. get stencilOpStencilFail(): number;
  114525. set stencilOpStencilFail(value: number);
  114526. get stencilOpDepthFail(): number;
  114527. set stencilOpDepthFail(value: number);
  114528. get stencilOpStencilDepthPass(): number;
  114529. set stencilOpStencilDepthPass(value: number);
  114530. get stencilMask(): number;
  114531. set stencilMask(value: number);
  114532. get stencilTest(): boolean;
  114533. set stencilTest(value: boolean);
  114534. constructor();
  114535. reset(): void;
  114536. apply(gl: WebGLRenderingContext): void;
  114537. }
  114538. }
  114539. declare module BABYLON {
  114540. /**
  114541. * @hidden
  114542. **/
  114543. export class AlphaState {
  114544. private _isAlphaBlendDirty;
  114545. private _isBlendFunctionParametersDirty;
  114546. private _isBlendEquationParametersDirty;
  114547. private _isBlendConstantsDirty;
  114548. private _alphaBlend;
  114549. private _blendFunctionParameters;
  114550. private _blendEquationParameters;
  114551. private _blendConstants;
  114552. /**
  114553. * Initializes the state.
  114554. */
  114555. constructor();
  114556. get isDirty(): boolean;
  114557. get alphaBlend(): boolean;
  114558. set alphaBlend(value: boolean);
  114559. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  114560. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  114561. setAlphaEquationParameters(rgb: number, alpha: number): void;
  114562. reset(): void;
  114563. apply(gl: WebGLRenderingContext): void;
  114564. }
  114565. }
  114566. declare module BABYLON {
  114567. /** @hidden */
  114568. export class WebGL2ShaderProcessor implements IShaderProcessor {
  114569. attributeProcessor(attribute: string): string;
  114570. varyingProcessor(varying: string, isFragment: boolean): string;
  114571. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  114572. }
  114573. }
  114574. declare module BABYLON {
  114575. /**
  114576. * Interface for attribute information associated with buffer instanciation
  114577. */
  114578. export interface InstancingAttributeInfo {
  114579. /**
  114580. * Name of the GLSL attribute
  114581. * if attribute index is not specified, this is used to retrieve the index from the effect
  114582. */
  114583. attributeName: string;
  114584. /**
  114585. * Index/offset of the attribute in the vertex shader
  114586. * if not specified, this will be computes from the name.
  114587. */
  114588. index?: number;
  114589. /**
  114590. * size of the attribute, 1, 2, 3 or 4
  114591. */
  114592. attributeSize: number;
  114593. /**
  114594. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  114595. */
  114596. offset: number;
  114597. /**
  114598. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  114599. * default to 1
  114600. */
  114601. divisor?: number;
  114602. /**
  114603. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  114604. * default is FLOAT
  114605. */
  114606. attributeType?: number;
  114607. /**
  114608. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  114609. */
  114610. normalized?: boolean;
  114611. }
  114612. }
  114613. declare module BABYLON {
  114614. interface ThinEngine {
  114615. /**
  114616. * Update a video texture
  114617. * @param texture defines the texture to update
  114618. * @param video defines the video element to use
  114619. * @param invertY defines if data must be stored with Y axis inverted
  114620. */
  114621. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  114622. }
  114623. }
  114624. declare module BABYLON {
  114625. interface ThinEngine {
  114626. /**
  114627. * Creates a dynamic texture
  114628. * @param width defines the width of the texture
  114629. * @param height defines the height of the texture
  114630. * @param generateMipMaps defines if the engine should generate the mip levels
  114631. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  114632. * @returns the dynamic texture inside an InternalTexture
  114633. */
  114634. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  114635. /**
  114636. * Update the content of a dynamic texture
  114637. * @param texture defines the texture to update
  114638. * @param canvas defines the canvas containing the source
  114639. * @param invertY defines if data must be stored with Y axis inverted
  114640. * @param premulAlpha defines if alpha is stored as premultiplied
  114641. * @param format defines the format of the data
  114642. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  114643. */
  114644. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  114645. }
  114646. }
  114647. declare module BABYLON {
  114648. /**
  114649. * Settings for finer control over video usage
  114650. */
  114651. export interface VideoTextureSettings {
  114652. /**
  114653. * Applies `autoplay` to video, if specified
  114654. */
  114655. autoPlay?: boolean;
  114656. /**
  114657. * Applies `loop` to video, if specified
  114658. */
  114659. loop?: boolean;
  114660. /**
  114661. * Automatically updates internal texture from video at every frame in the render loop
  114662. */
  114663. autoUpdateTexture: boolean;
  114664. /**
  114665. * Image src displayed during the video loading or until the user interacts with the video.
  114666. */
  114667. poster?: string;
  114668. }
  114669. /**
  114670. * If you want to display a video in your scene, this is the special texture for that.
  114671. * This special texture works similar to other textures, with the exception of a few parameters.
  114672. * @see https://doc.babylonjs.com/how_to/video_texture
  114673. */
  114674. export class VideoTexture extends Texture {
  114675. /**
  114676. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  114677. */
  114678. readonly autoUpdateTexture: boolean;
  114679. /**
  114680. * The video instance used by the texture internally
  114681. */
  114682. readonly video: HTMLVideoElement;
  114683. private _onUserActionRequestedObservable;
  114684. /**
  114685. * Event triggerd when a dom action is required by the user to play the video.
  114686. * This happens due to recent changes in browser policies preventing video to auto start.
  114687. */
  114688. get onUserActionRequestedObservable(): Observable<Texture>;
  114689. private _generateMipMaps;
  114690. private _stillImageCaptured;
  114691. private _displayingPosterTexture;
  114692. private _settings;
  114693. private _createInternalTextureOnEvent;
  114694. private _frameId;
  114695. private _currentSrc;
  114696. /**
  114697. * Creates a video texture.
  114698. * If you want to display a video in your scene, this is the special texture for that.
  114699. * This special texture works similar to other textures, with the exception of a few parameters.
  114700. * @see https://doc.babylonjs.com/how_to/video_texture
  114701. * @param name optional name, will detect from video source, if not defined
  114702. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  114703. * @param scene is obviously the current scene.
  114704. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  114705. * @param invertY is false by default but can be used to invert video on Y axis
  114706. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  114707. * @param settings allows finer control over video usage
  114708. */
  114709. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  114710. private _getName;
  114711. private _getVideo;
  114712. private _createInternalTexture;
  114713. private reset;
  114714. /**
  114715. * @hidden Internal method to initiate `update`.
  114716. */
  114717. _rebuild(): void;
  114718. /**
  114719. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  114720. */
  114721. update(): void;
  114722. /**
  114723. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  114724. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  114725. */
  114726. updateTexture(isVisible: boolean): void;
  114727. protected _updateInternalTexture: () => void;
  114728. /**
  114729. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  114730. * @param url New url.
  114731. */
  114732. updateURL(url: string): void;
  114733. /**
  114734. * Clones the texture.
  114735. * @returns the cloned texture
  114736. */
  114737. clone(): VideoTexture;
  114738. /**
  114739. * Dispose the texture and release its associated resources.
  114740. */
  114741. dispose(): void;
  114742. /**
  114743. * Creates a video texture straight from a stream.
  114744. * @param scene Define the scene the texture should be created in
  114745. * @param stream Define the stream the texture should be created from
  114746. * @returns The created video texture as a promise
  114747. */
  114748. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  114749. /**
  114750. * Creates a video texture straight from your WebCam video feed.
  114751. * @param scene Define the scene the texture should be created in
  114752. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  114753. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  114754. * @returns The created video texture as a promise
  114755. */
  114756. static CreateFromWebCamAsync(scene: Scene, constraints: {
  114757. minWidth: number;
  114758. maxWidth: number;
  114759. minHeight: number;
  114760. maxHeight: number;
  114761. deviceId: string;
  114762. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  114763. /**
  114764. * Creates a video texture straight from your WebCam video feed.
  114765. * @param scene Define the scene the texture should be created in
  114766. * @param onReady Define a callback to triggered once the texture will be ready
  114767. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  114768. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  114769. */
  114770. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  114771. minWidth: number;
  114772. maxWidth: number;
  114773. minHeight: number;
  114774. maxHeight: number;
  114775. deviceId: string;
  114776. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  114777. }
  114778. }
  114779. declare module BABYLON {
  114780. /**
  114781. * Defines the interface used by objects working like Scene
  114782. * @hidden
  114783. */
  114784. export interface ISceneLike {
  114785. _addPendingData(data: any): void;
  114786. _removePendingData(data: any): void;
  114787. offlineProvider: IOfflineProvider;
  114788. }
  114789. /**
  114790. * Information about the current host
  114791. */
  114792. export interface HostInformation {
  114793. /**
  114794. * Defines if the current host is a mobile
  114795. */
  114796. isMobile: boolean;
  114797. }
  114798. /** Interface defining initialization parameters for Engine class */
  114799. export interface EngineOptions extends WebGLContextAttributes {
  114800. /**
  114801. * Defines if the engine should no exceed a specified device ratio
  114802. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  114803. */
  114804. limitDeviceRatio?: number;
  114805. /**
  114806. * Defines if webvr should be enabled automatically
  114807. * @see https://doc.babylonjs.com/how_to/webvr_camera
  114808. */
  114809. autoEnableWebVR?: boolean;
  114810. /**
  114811. * Defines if webgl2 should be turned off even if supported
  114812. * @see https://doc.babylonjs.com/features/webgl2
  114813. */
  114814. disableWebGL2Support?: boolean;
  114815. /**
  114816. * Defines if webaudio should be initialized as well
  114817. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114818. */
  114819. audioEngine?: boolean;
  114820. /**
  114821. * Defines if animations should run using a deterministic lock step
  114822. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114823. */
  114824. deterministicLockstep?: boolean;
  114825. /** Defines the maximum steps to use with deterministic lock step mode */
  114826. lockstepMaxSteps?: number;
  114827. /** Defines the seconds between each deterministic lock step */
  114828. timeStep?: number;
  114829. /**
  114830. * Defines that engine should ignore context lost events
  114831. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  114832. */
  114833. doNotHandleContextLost?: boolean;
  114834. /**
  114835. * Defines that engine should ignore modifying touch action attribute and style
  114836. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  114837. */
  114838. doNotHandleTouchAction?: boolean;
  114839. /**
  114840. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  114841. */
  114842. useHighPrecisionFloats?: boolean;
  114843. /**
  114844. * Make the canvas XR Compatible for XR sessions
  114845. */
  114846. xrCompatible?: boolean;
  114847. /**
  114848. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  114849. */
  114850. useHighPrecisionMatrix?: boolean;
  114851. }
  114852. /**
  114853. * The base engine class (root of all engines)
  114854. */
  114855. export class ThinEngine {
  114856. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  114857. static ExceptionList: ({
  114858. key: string;
  114859. capture: string;
  114860. captureConstraint: number;
  114861. targets: string[];
  114862. } | {
  114863. key: string;
  114864. capture: null;
  114865. captureConstraint: null;
  114866. targets: string[];
  114867. })[];
  114868. /** @hidden */
  114869. static _TextureLoaders: IInternalTextureLoader[];
  114870. /**
  114871. * Returns the current npm package of the sdk
  114872. */
  114873. static get NpmPackage(): string;
  114874. /**
  114875. * Returns the current version of the framework
  114876. */
  114877. static get Version(): string;
  114878. /**
  114879. * Returns a string describing the current engine
  114880. */
  114881. get description(): string;
  114882. /**
  114883. * Gets or sets the epsilon value used by collision engine
  114884. */
  114885. static CollisionsEpsilon: number;
  114886. /**
  114887. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114888. */
  114889. static get ShadersRepository(): string;
  114890. static set ShadersRepository(value: string);
  114891. /** @hidden */
  114892. _shaderProcessor: IShaderProcessor;
  114893. /**
  114894. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  114895. */
  114896. forcePOTTextures: boolean;
  114897. /**
  114898. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  114899. */
  114900. isFullscreen: boolean;
  114901. /**
  114902. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  114903. */
  114904. cullBackFaces: boolean;
  114905. /**
  114906. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  114907. */
  114908. renderEvenInBackground: boolean;
  114909. /**
  114910. * Gets or sets a boolean indicating that cache can be kept between frames
  114911. */
  114912. preventCacheWipeBetweenFrames: boolean;
  114913. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  114914. validateShaderPrograms: boolean;
  114915. /**
  114916. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  114917. * This can provide greater z depth for distant objects.
  114918. */
  114919. useReverseDepthBuffer: boolean;
  114920. /**
  114921. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  114922. */
  114923. disableUniformBuffers: boolean;
  114924. /** @hidden */
  114925. _uniformBuffers: UniformBuffer[];
  114926. /**
  114927. * Gets a boolean indicating that the engine supports uniform buffers
  114928. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  114929. */
  114930. get supportsUniformBuffers(): boolean;
  114931. /** @hidden */
  114932. _gl: WebGLRenderingContext;
  114933. /** @hidden */
  114934. _webGLVersion: number;
  114935. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  114936. protected _windowIsBackground: boolean;
  114937. protected _creationOptions: EngineOptions;
  114938. protected _highPrecisionShadersAllowed: boolean;
  114939. /** @hidden */
  114940. get _shouldUseHighPrecisionShader(): boolean;
  114941. /**
  114942. * Gets a boolean indicating that only power of 2 textures are supported
  114943. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  114944. */
  114945. get needPOTTextures(): boolean;
  114946. /** @hidden */
  114947. _badOS: boolean;
  114948. /** @hidden */
  114949. _badDesktopOS: boolean;
  114950. private _hardwareScalingLevel;
  114951. /** @hidden */
  114952. _caps: EngineCapabilities;
  114953. private _isStencilEnable;
  114954. private _glVersion;
  114955. private _glRenderer;
  114956. private _glVendor;
  114957. /** @hidden */
  114958. _videoTextureSupported: boolean;
  114959. protected _renderingQueueLaunched: boolean;
  114960. protected _activeRenderLoops: (() => void)[];
  114961. /**
  114962. * Observable signaled when a context lost event is raised
  114963. */
  114964. onContextLostObservable: Observable<ThinEngine>;
  114965. /**
  114966. * Observable signaled when a context restored event is raised
  114967. */
  114968. onContextRestoredObservable: Observable<ThinEngine>;
  114969. private _onContextLost;
  114970. private _onContextRestored;
  114971. protected _contextWasLost: boolean;
  114972. /** @hidden */
  114973. _doNotHandleContextLost: boolean;
  114974. /**
  114975. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  114976. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  114977. */
  114978. get doNotHandleContextLost(): boolean;
  114979. set doNotHandleContextLost(value: boolean);
  114980. /**
  114981. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  114982. */
  114983. disableVertexArrayObjects: boolean;
  114984. /** @hidden */
  114985. protected _colorWrite: boolean;
  114986. /** @hidden */
  114987. protected _colorWriteChanged: boolean;
  114988. /** @hidden */
  114989. protected _depthCullingState: DepthCullingState;
  114990. /** @hidden */
  114991. protected _stencilState: StencilState;
  114992. /** @hidden */
  114993. _alphaState: AlphaState;
  114994. /** @hidden */
  114995. _alphaMode: number;
  114996. /** @hidden */
  114997. _alphaEquation: number;
  114998. /** @hidden */
  114999. _internalTexturesCache: InternalTexture[];
  115000. /** @hidden */
  115001. protected _activeChannel: number;
  115002. private _currentTextureChannel;
  115003. /** @hidden */
  115004. protected _boundTexturesCache: {
  115005. [key: string]: Nullable<InternalTexture>;
  115006. };
  115007. /** @hidden */
  115008. protected _currentEffect: Nullable<Effect>;
  115009. /** @hidden */
  115010. protected _currentProgram: Nullable<WebGLProgram>;
  115011. private _compiledEffects;
  115012. private _vertexAttribArraysEnabled;
  115013. /** @hidden */
  115014. protected _cachedViewport: Nullable<IViewportLike>;
  115015. private _cachedVertexArrayObject;
  115016. /** @hidden */
  115017. protected _cachedVertexBuffers: any;
  115018. /** @hidden */
  115019. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  115020. /** @hidden */
  115021. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  115022. /** @hidden */
  115023. _currentRenderTarget: Nullable<InternalTexture>;
  115024. private _uintIndicesCurrentlySet;
  115025. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  115026. /** @hidden */
  115027. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  115028. /** @hidden */
  115029. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  115030. private _currentBufferPointers;
  115031. private _currentInstanceLocations;
  115032. private _currentInstanceBuffers;
  115033. private _textureUnits;
  115034. /** @hidden */
  115035. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115036. /** @hidden */
  115037. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115038. /** @hidden */
  115039. _boundRenderFunction: any;
  115040. private _vaoRecordInProgress;
  115041. private _mustWipeVertexAttributes;
  115042. private _emptyTexture;
  115043. private _emptyCubeTexture;
  115044. private _emptyTexture3D;
  115045. private _emptyTexture2DArray;
  115046. /** @hidden */
  115047. _frameHandler: number;
  115048. private _nextFreeTextureSlots;
  115049. private _maxSimultaneousTextures;
  115050. private _activeRequests;
  115051. /** @hidden */
  115052. _transformTextureUrl: Nullable<(url: string) => string>;
  115053. /**
  115054. * Gets information about the current host
  115055. */
  115056. hostInformation: HostInformation;
  115057. protected get _supportsHardwareTextureRescaling(): boolean;
  115058. private _framebufferDimensionsObject;
  115059. /**
  115060. * sets the object from which width and height will be taken from when getting render width and height
  115061. * Will fallback to the gl object
  115062. * @param dimensions the framebuffer width and height that will be used.
  115063. */
  115064. set framebufferDimensionsObject(dimensions: Nullable<{
  115065. framebufferWidth: number;
  115066. framebufferHeight: number;
  115067. }>);
  115068. /**
  115069. * Gets the current viewport
  115070. */
  115071. get currentViewport(): Nullable<IViewportLike>;
  115072. /**
  115073. * Gets the default empty texture
  115074. */
  115075. get emptyTexture(): InternalTexture;
  115076. /**
  115077. * Gets the default empty 3D texture
  115078. */
  115079. get emptyTexture3D(): InternalTexture;
  115080. /**
  115081. * Gets the default empty 2D array texture
  115082. */
  115083. get emptyTexture2DArray(): InternalTexture;
  115084. /**
  115085. * Gets the default empty cube texture
  115086. */
  115087. get emptyCubeTexture(): InternalTexture;
  115088. /**
  115089. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  115090. */
  115091. readonly premultipliedAlpha: boolean;
  115092. /**
  115093. * Observable event triggered before each texture is initialized
  115094. */
  115095. onBeforeTextureInitObservable: Observable<Texture>;
  115096. /**
  115097. * Creates a new engine
  115098. * @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
  115099. * @param antialias defines enable antialiasing (default: false)
  115100. * @param options defines further options to be sent to the getContext() function
  115101. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  115102. */
  115103. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  115104. private _rebuildInternalTextures;
  115105. private _rebuildEffects;
  115106. /**
  115107. * Gets a boolean indicating if all created effects are ready
  115108. * @returns true if all effects are ready
  115109. */
  115110. areAllEffectsReady(): boolean;
  115111. protected _rebuildBuffers(): void;
  115112. protected _initGLContext(): void;
  115113. /**
  115114. * Gets version of the current webGL context
  115115. */
  115116. get webGLVersion(): number;
  115117. /**
  115118. * Gets a string identifying the name of the class
  115119. * @returns "Engine" string
  115120. */
  115121. getClassName(): string;
  115122. /**
  115123. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  115124. */
  115125. get isStencilEnable(): boolean;
  115126. /** @hidden */
  115127. _prepareWorkingCanvas(): void;
  115128. /**
  115129. * Reset the texture cache to empty state
  115130. */
  115131. resetTextureCache(): void;
  115132. /**
  115133. * Gets an object containing information about the current webGL context
  115134. * @returns an object containing the vender, the renderer and the version of the current webGL context
  115135. */
  115136. getGlInfo(): {
  115137. vendor: string;
  115138. renderer: string;
  115139. version: string;
  115140. };
  115141. /**
  115142. * Defines the hardware scaling level.
  115143. * By default the hardware scaling level is computed from the window device ratio.
  115144. * 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.
  115145. * @param level defines the level to use
  115146. */
  115147. setHardwareScalingLevel(level: number): void;
  115148. /**
  115149. * Gets the current hardware scaling level.
  115150. * By default the hardware scaling level is computed from the window device ratio.
  115151. * 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.
  115152. * @returns a number indicating the current hardware scaling level
  115153. */
  115154. getHardwareScalingLevel(): number;
  115155. /**
  115156. * Gets the list of loaded textures
  115157. * @returns an array containing all loaded textures
  115158. */
  115159. getLoadedTexturesCache(): InternalTexture[];
  115160. /**
  115161. * Gets the object containing all engine capabilities
  115162. * @returns the EngineCapabilities object
  115163. */
  115164. getCaps(): EngineCapabilities;
  115165. /**
  115166. * stop executing a render loop function and remove it from the execution array
  115167. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  115168. */
  115169. stopRenderLoop(renderFunction?: () => void): void;
  115170. /** @hidden */
  115171. _renderLoop(): void;
  115172. /**
  115173. * Gets the HTML canvas attached with the current webGL context
  115174. * @returns a HTML canvas
  115175. */
  115176. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  115177. /**
  115178. * Gets host window
  115179. * @returns the host window object
  115180. */
  115181. getHostWindow(): Nullable<Window>;
  115182. /**
  115183. * Gets the current render width
  115184. * @param useScreen defines if screen size must be used (or the current render target if any)
  115185. * @returns a number defining the current render width
  115186. */
  115187. getRenderWidth(useScreen?: boolean): number;
  115188. /**
  115189. * Gets the current render height
  115190. * @param useScreen defines if screen size must be used (or the current render target if any)
  115191. * @returns a number defining the current render height
  115192. */
  115193. getRenderHeight(useScreen?: boolean): number;
  115194. /**
  115195. * Can be used to override the current requestAnimationFrame requester.
  115196. * @hidden
  115197. */
  115198. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  115199. /**
  115200. * Register and execute a render loop. The engine can have more than one render function
  115201. * @param renderFunction defines the function to continuously execute
  115202. */
  115203. runRenderLoop(renderFunction: () => void): void;
  115204. /**
  115205. * Clear the current render buffer or the current render target (if any is set up)
  115206. * @param color defines the color to use
  115207. * @param backBuffer defines if the back buffer must be cleared
  115208. * @param depth defines if the depth buffer must be cleared
  115209. * @param stencil defines if the stencil buffer must be cleared
  115210. */
  115211. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  115212. private _viewportCached;
  115213. /** @hidden */
  115214. _viewport(x: number, y: number, width: number, height: number): void;
  115215. /**
  115216. * Set the WebGL's viewport
  115217. * @param viewport defines the viewport element to be used
  115218. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  115219. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  115220. */
  115221. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  115222. /**
  115223. * Begin a new frame
  115224. */
  115225. beginFrame(): void;
  115226. /**
  115227. * Enf the current frame
  115228. */
  115229. endFrame(): void;
  115230. /**
  115231. * Resize the view according to the canvas' size
  115232. */
  115233. resize(): void;
  115234. /**
  115235. * Force a specific size of the canvas
  115236. * @param width defines the new canvas' width
  115237. * @param height defines the new canvas' height
  115238. * @returns true if the size was changed
  115239. */
  115240. setSize(width: number, height: number): boolean;
  115241. /**
  115242. * Binds the frame buffer to the specified texture.
  115243. * @param texture The texture to render to or null for the default canvas
  115244. * @param faceIndex The face of the texture to render to in case of cube texture
  115245. * @param requiredWidth The width of the target to render to
  115246. * @param requiredHeight The height of the target to render to
  115247. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  115248. * @param lodLevel defines the lod level to bind to the frame buffer
  115249. * @param layer defines the 2d array index to bind to frame buffer to
  115250. */
  115251. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  115252. /** @hidden */
  115253. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  115254. /**
  115255. * Unbind the current render target texture from the webGL context
  115256. * @param texture defines the render target texture to unbind
  115257. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  115258. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  115259. */
  115260. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  115261. /**
  115262. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  115263. */
  115264. flushFramebuffer(): void;
  115265. /**
  115266. * Unbind the current render target and bind the default framebuffer
  115267. */
  115268. restoreDefaultFramebuffer(): void;
  115269. /** @hidden */
  115270. protected _resetVertexBufferBinding(): void;
  115271. /**
  115272. * Creates a vertex buffer
  115273. * @param data the data for the vertex buffer
  115274. * @returns the new WebGL static buffer
  115275. */
  115276. createVertexBuffer(data: DataArray): DataBuffer;
  115277. private _createVertexBuffer;
  115278. /**
  115279. * Creates a dynamic vertex buffer
  115280. * @param data the data for the dynamic vertex buffer
  115281. * @returns the new WebGL dynamic buffer
  115282. */
  115283. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  115284. protected _resetIndexBufferBinding(): void;
  115285. /**
  115286. * Creates a new index buffer
  115287. * @param indices defines the content of the index buffer
  115288. * @param updatable defines if the index buffer must be updatable
  115289. * @returns a new webGL buffer
  115290. */
  115291. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  115292. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  115293. /**
  115294. * Bind a webGL buffer to the webGL context
  115295. * @param buffer defines the buffer to bind
  115296. */
  115297. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  115298. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  115299. private bindBuffer;
  115300. /**
  115301. * update the bound buffer with the given data
  115302. * @param data defines the data to update
  115303. */
  115304. updateArrayBuffer(data: Float32Array): void;
  115305. private _vertexAttribPointer;
  115306. /** @hidden */
  115307. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  115308. private _bindVertexBuffersAttributes;
  115309. /**
  115310. * Records a vertex array object
  115311. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  115312. * @param vertexBuffers defines the list of vertex buffers to store
  115313. * @param indexBuffer defines the index buffer to store
  115314. * @param effect defines the effect to store
  115315. * @returns the new vertex array object
  115316. */
  115317. recordVertexArrayObject(vertexBuffers: {
  115318. [key: string]: VertexBuffer;
  115319. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  115320. /**
  115321. * Bind a specific vertex array object
  115322. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  115323. * @param vertexArrayObject defines the vertex array object to bind
  115324. * @param indexBuffer defines the index buffer to bind
  115325. */
  115326. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  115327. /**
  115328. * Bind webGl buffers directly to the webGL context
  115329. * @param vertexBuffer defines the vertex buffer to bind
  115330. * @param indexBuffer defines the index buffer to bind
  115331. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  115332. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  115333. * @param effect defines the effect associated with the vertex buffer
  115334. */
  115335. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  115336. private _unbindVertexArrayObject;
  115337. /**
  115338. * Bind a list of vertex buffers to the webGL context
  115339. * @param vertexBuffers defines the list of vertex buffers to bind
  115340. * @param indexBuffer defines the index buffer to bind
  115341. * @param effect defines the effect associated with the vertex buffers
  115342. */
  115343. bindBuffers(vertexBuffers: {
  115344. [key: string]: Nullable<VertexBuffer>;
  115345. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  115346. /**
  115347. * Unbind all instance attributes
  115348. */
  115349. unbindInstanceAttributes(): void;
  115350. /**
  115351. * Release and free the memory of a vertex array object
  115352. * @param vao defines the vertex array object to delete
  115353. */
  115354. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  115355. /** @hidden */
  115356. _releaseBuffer(buffer: DataBuffer): boolean;
  115357. protected _deleteBuffer(buffer: DataBuffer): void;
  115358. /**
  115359. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  115360. * @param instancesBuffer defines the webGL buffer to update and bind
  115361. * @param data defines the data to store in the buffer
  115362. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  115363. */
  115364. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  115365. /**
  115366. * Bind the content of a webGL buffer used with instantiation
  115367. * @param instancesBuffer defines the webGL buffer to bind
  115368. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  115369. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  115370. */
  115371. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  115372. /**
  115373. * Disable the instance attribute corresponding to the name in parameter
  115374. * @param name defines the name of the attribute to disable
  115375. */
  115376. disableInstanceAttributeByName(name: string): void;
  115377. /**
  115378. * Disable the instance attribute corresponding to the location in parameter
  115379. * @param attributeLocation defines the attribute location of the attribute to disable
  115380. */
  115381. disableInstanceAttribute(attributeLocation: number): void;
  115382. /**
  115383. * Disable the attribute corresponding to the location in parameter
  115384. * @param attributeLocation defines the attribute location of the attribute to disable
  115385. */
  115386. disableAttributeByIndex(attributeLocation: number): void;
  115387. /**
  115388. * Send a draw order
  115389. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115390. * @param indexStart defines the starting index
  115391. * @param indexCount defines the number of index to draw
  115392. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115393. */
  115394. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  115395. /**
  115396. * Draw a list of points
  115397. * @param verticesStart defines the index of first vertex to draw
  115398. * @param verticesCount defines the count of vertices to draw
  115399. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115400. */
  115401. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115402. /**
  115403. * Draw a list of unindexed primitives
  115404. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115405. * @param verticesStart defines the index of first vertex to draw
  115406. * @param verticesCount defines the count of vertices to draw
  115407. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115408. */
  115409. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115410. /**
  115411. * Draw a list of indexed primitives
  115412. * @param fillMode defines the primitive to use
  115413. * @param indexStart defines the starting index
  115414. * @param indexCount defines the number of index to draw
  115415. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115416. */
  115417. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  115418. /**
  115419. * Draw a list of unindexed primitives
  115420. * @param fillMode defines the primitive to use
  115421. * @param verticesStart defines the index of first vertex to draw
  115422. * @param verticesCount defines the count of vertices to draw
  115423. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115424. */
  115425. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115426. private _drawMode;
  115427. /** @hidden */
  115428. protected _reportDrawCall(): void;
  115429. /** @hidden */
  115430. _releaseEffect(effect: Effect): void;
  115431. /** @hidden */
  115432. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115433. /**
  115434. * Create a new effect (used to store vertex/fragment shaders)
  115435. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  115436. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  115437. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  115438. * @param samplers defines an array of string used to represent textures
  115439. * @param defines defines the string containing the defines to use to compile the shaders
  115440. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  115441. * @param onCompiled defines a function to call when the effect creation is successful
  115442. * @param onError defines a function to call when the effect creation has failed
  115443. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  115444. * @returns the new Effect
  115445. */
  115446. 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;
  115447. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  115448. private _compileShader;
  115449. private _compileRawShader;
  115450. /** @hidden */
  115451. _getShaderSource(shader: WebGLShader): Nullable<string>;
  115452. /**
  115453. * Directly creates a webGL program
  115454. * @param pipelineContext defines the pipeline context to attach to
  115455. * @param vertexCode defines the vertex shader code to use
  115456. * @param fragmentCode defines the fragment shader code to use
  115457. * @param context defines the webGL context to use (if not set, the current one will be used)
  115458. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  115459. * @returns the new webGL program
  115460. */
  115461. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115462. /**
  115463. * Creates a webGL program
  115464. * @param pipelineContext defines the pipeline context to attach to
  115465. * @param vertexCode defines the vertex shader code to use
  115466. * @param fragmentCode defines the fragment shader code to use
  115467. * @param defines defines the string containing the defines to use to compile the shaders
  115468. * @param context defines the webGL context to use (if not set, the current one will be used)
  115469. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  115470. * @returns the new webGL program
  115471. */
  115472. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115473. /**
  115474. * Creates a new pipeline context
  115475. * @returns the new pipeline
  115476. */
  115477. createPipelineContext(): IPipelineContext;
  115478. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115479. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  115480. /** @hidden */
  115481. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  115482. /** @hidden */
  115483. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  115484. /** @hidden */
  115485. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  115486. /**
  115487. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  115488. * @param pipelineContext defines the pipeline context to use
  115489. * @param uniformsNames defines the list of uniform names
  115490. * @returns an array of webGL uniform locations
  115491. */
  115492. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  115493. /**
  115494. * Gets the lsit of active attributes for a given webGL program
  115495. * @param pipelineContext defines the pipeline context to use
  115496. * @param attributesNames defines the list of attribute names to get
  115497. * @returns an array of indices indicating the offset of each attribute
  115498. */
  115499. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  115500. /**
  115501. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  115502. * @param effect defines the effect to activate
  115503. */
  115504. enableEffect(effect: Nullable<Effect>): void;
  115505. /**
  115506. * Set the value of an uniform to a number (int)
  115507. * @param uniform defines the webGL uniform location where to store the value
  115508. * @param value defines the int number to store
  115509. */
  115510. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  115511. /**
  115512. * Set the value of an uniform to an array of int32
  115513. * @param uniform defines the webGL uniform location where to store the value
  115514. * @param array defines the array of int32 to store
  115515. */
  115516. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115517. /**
  115518. * Set the value of an uniform to an array of int32 (stored as vec2)
  115519. * @param uniform defines the webGL uniform location where to store the value
  115520. * @param array defines the array of int32 to store
  115521. */
  115522. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115523. /**
  115524. * Set the value of an uniform to an array of int32 (stored as vec3)
  115525. * @param uniform defines the webGL uniform location where to store the value
  115526. * @param array defines the array of int32 to store
  115527. */
  115528. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115529. /**
  115530. * Set the value of an uniform to an array of int32 (stored as vec4)
  115531. * @param uniform defines the webGL uniform location where to store the value
  115532. * @param array defines the array of int32 to store
  115533. */
  115534. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115535. /**
  115536. * Set the value of an uniform to an array of number
  115537. * @param uniform defines the webGL uniform location where to store the value
  115538. * @param array defines the array of number to store
  115539. */
  115540. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115541. /**
  115542. * Set the value of an uniform to an array of number (stored as vec2)
  115543. * @param uniform defines the webGL uniform location where to store the value
  115544. * @param array defines the array of number to store
  115545. */
  115546. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115547. /**
  115548. * Set the value of an uniform to an array of number (stored as vec3)
  115549. * @param uniform defines the webGL uniform location where to store the value
  115550. * @param array defines the array of number to store
  115551. */
  115552. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115553. /**
  115554. * Set the value of an uniform to an array of number (stored as vec4)
  115555. * @param uniform defines the webGL uniform location where to store the value
  115556. * @param array defines the array of number to store
  115557. */
  115558. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115559. /**
  115560. * Set the value of an uniform to an array of float32 (stored as matrices)
  115561. * @param uniform defines the webGL uniform location where to store the value
  115562. * @param matrices defines the array of float32 to store
  115563. */
  115564. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  115565. /**
  115566. * Set the value of an uniform to a matrix (3x3)
  115567. * @param uniform defines the webGL uniform location where to store the value
  115568. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  115569. */
  115570. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  115571. /**
  115572. * Set the value of an uniform to a matrix (2x2)
  115573. * @param uniform defines the webGL uniform location where to store the value
  115574. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  115575. */
  115576. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  115577. /**
  115578. * Set the value of an uniform to a number (float)
  115579. * @param uniform defines the webGL uniform location where to store the value
  115580. * @param value defines the float number to store
  115581. */
  115582. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  115583. /**
  115584. * Set the value of an uniform to a vec2
  115585. * @param uniform defines the webGL uniform location where to store the value
  115586. * @param x defines the 1st component of the value
  115587. * @param y defines the 2nd component of the value
  115588. */
  115589. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  115590. /**
  115591. * Set the value of an uniform to a vec3
  115592. * @param uniform defines the webGL uniform location where to store the value
  115593. * @param x defines the 1st component of the value
  115594. * @param y defines the 2nd component of the value
  115595. * @param z defines the 3rd component of the value
  115596. */
  115597. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  115598. /**
  115599. * Set the value of an uniform to a vec4
  115600. * @param uniform defines the webGL uniform location where to store the value
  115601. * @param x defines the 1st component of the value
  115602. * @param y defines the 2nd component of the value
  115603. * @param z defines the 3rd component of the value
  115604. * @param w defines the 4th component of the value
  115605. */
  115606. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  115607. /**
  115608. * Apply all cached states (depth, culling, stencil and alpha)
  115609. */
  115610. applyStates(): void;
  115611. /**
  115612. * Enable or disable color writing
  115613. * @param enable defines the state to set
  115614. */
  115615. setColorWrite(enable: boolean): void;
  115616. /**
  115617. * Gets a boolean indicating if color writing is enabled
  115618. * @returns the current color writing state
  115619. */
  115620. getColorWrite(): boolean;
  115621. /**
  115622. * Gets the depth culling state manager
  115623. */
  115624. get depthCullingState(): DepthCullingState;
  115625. /**
  115626. * Gets the alpha state manager
  115627. */
  115628. get alphaState(): AlphaState;
  115629. /**
  115630. * Gets the stencil state manager
  115631. */
  115632. get stencilState(): StencilState;
  115633. /**
  115634. * Clears the list of texture accessible through engine.
  115635. * This can help preventing texture load conflict due to name collision.
  115636. */
  115637. clearInternalTexturesCache(): void;
  115638. /**
  115639. * Force the entire cache to be cleared
  115640. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  115641. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  115642. */
  115643. wipeCaches(bruteForce?: boolean): void;
  115644. /** @hidden */
  115645. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  115646. min: number;
  115647. mag: number;
  115648. };
  115649. /** @hidden */
  115650. _createTexture(): WebGLTexture;
  115651. /**
  115652. * Usually called from Texture.ts.
  115653. * Passed information to create a WebGLTexture
  115654. * @param url defines a value which contains one of the following:
  115655. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  115656. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  115657. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  115658. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  115659. * @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)
  115660. * @param scene needed for loading to the correct scene
  115661. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  115662. * @param onLoad optional callback to be called upon successful completion
  115663. * @param onError optional callback to be called upon failure
  115664. * @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
  115665. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  115666. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  115667. * @param forcedExtension defines the extension to use to pick the right loader
  115668. * @param mimeType defines an optional mime type
  115669. * @returns a InternalTexture for assignment back into BABYLON.Texture
  115670. */
  115671. 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;
  115672. /**
  115673. * Loads an image as an HTMLImageElement.
  115674. * @param input url string, ArrayBuffer, or Blob to load
  115675. * @param onLoad callback called when the image successfully loads
  115676. * @param onError callback called when the image fails to load
  115677. * @param offlineProvider offline provider for caching
  115678. * @param mimeType optional mime type
  115679. * @returns the HTMLImageElement of the loaded image
  115680. * @hidden
  115681. */
  115682. 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>;
  115683. /**
  115684. * @hidden
  115685. */
  115686. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  115687. private _unpackFlipYCached;
  115688. /**
  115689. * In case you are sharing the context with other applications, it might
  115690. * be interested to not cache the unpack flip y state to ensure a consistent
  115691. * value would be set.
  115692. */
  115693. enableUnpackFlipYCached: boolean;
  115694. /** @hidden */
  115695. _unpackFlipY(value: boolean): void;
  115696. /** @hidden */
  115697. _getUnpackAlignement(): number;
  115698. private _getTextureTarget;
  115699. /**
  115700. * Update the sampling mode of a given texture
  115701. * @param samplingMode defines the required sampling mode
  115702. * @param texture defines the texture to update
  115703. * @param generateMipMaps defines whether to generate mipmaps for the texture
  115704. */
  115705. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  115706. /**
  115707. * Update the sampling mode of a given texture
  115708. * @param texture defines the texture to update
  115709. * @param wrapU defines the texture wrap mode of the u coordinates
  115710. * @param wrapV defines the texture wrap mode of the v coordinates
  115711. * @param wrapR defines the texture wrap mode of the r coordinates
  115712. */
  115713. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  115714. /** @hidden */
  115715. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  115716. width: number;
  115717. height: number;
  115718. layers?: number;
  115719. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  115720. /** @hidden */
  115721. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115722. /** @hidden */
  115723. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  115724. /**
  115725. * Update a portion of an internal texture
  115726. * @param texture defines the texture to update
  115727. * @param imageData defines the data to store into the texture
  115728. * @param xOffset defines the x coordinates of the update rectangle
  115729. * @param yOffset defines the y coordinates of the update rectangle
  115730. * @param width defines the width of the update rectangle
  115731. * @param height defines the height of the update rectangle
  115732. * @param faceIndex defines the face index if texture is a cube (0 by default)
  115733. * @param lod defines the lod level to update (0 by default)
  115734. */
  115735. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  115736. /** @hidden */
  115737. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115738. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  115739. private _prepareWebGLTexture;
  115740. /** @hidden */
  115741. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  115742. private _getDepthStencilBuffer;
  115743. /** @hidden */
  115744. _releaseFramebufferObjects(texture: InternalTexture): void;
  115745. /** @hidden */
  115746. _releaseTexture(texture: InternalTexture): void;
  115747. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  115748. protected _setProgram(program: WebGLProgram): void;
  115749. protected _boundUniforms: {
  115750. [key: number]: WebGLUniformLocation;
  115751. };
  115752. /**
  115753. * Binds an effect to the webGL context
  115754. * @param effect defines the effect to bind
  115755. */
  115756. bindSamplers(effect: Effect): void;
  115757. private _activateCurrentTexture;
  115758. /** @hidden */
  115759. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  115760. /** @hidden */
  115761. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  115762. /**
  115763. * Unbind all textures from the webGL context
  115764. */
  115765. unbindAllTextures(): void;
  115766. /**
  115767. * Sets a texture to the according uniform.
  115768. * @param channel The texture channel
  115769. * @param uniform The uniform to set
  115770. * @param texture The texture to apply
  115771. */
  115772. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  115773. private _bindSamplerUniformToChannel;
  115774. private _getTextureWrapMode;
  115775. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  115776. /**
  115777. * Sets an array of texture to the webGL context
  115778. * @param channel defines the channel where the texture array must be set
  115779. * @param uniform defines the associated uniform location
  115780. * @param textures defines the array of textures to bind
  115781. */
  115782. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  115783. /** @hidden */
  115784. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  115785. private _setTextureParameterFloat;
  115786. private _setTextureParameterInteger;
  115787. /**
  115788. * Unbind all vertex attributes from the webGL context
  115789. */
  115790. unbindAllAttributes(): void;
  115791. /**
  115792. * 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
  115793. */
  115794. releaseEffects(): void;
  115795. /**
  115796. * Dispose and release all associated resources
  115797. */
  115798. dispose(): void;
  115799. /**
  115800. * Attach a new callback raised when context lost event is fired
  115801. * @param callback defines the callback to call
  115802. */
  115803. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  115804. /**
  115805. * Attach a new callback raised when context restored event is fired
  115806. * @param callback defines the callback to call
  115807. */
  115808. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  115809. /**
  115810. * Get the current error code of the webGL context
  115811. * @returns the error code
  115812. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  115813. */
  115814. getError(): number;
  115815. private _canRenderToFloatFramebuffer;
  115816. private _canRenderToHalfFloatFramebuffer;
  115817. private _canRenderToFramebuffer;
  115818. /** @hidden */
  115819. _getWebGLTextureType(type: number): number;
  115820. /** @hidden */
  115821. _getInternalFormat(format: number): number;
  115822. /** @hidden */
  115823. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  115824. /** @hidden */
  115825. _getRGBAMultiSampleBufferFormat(type: number): number;
  115826. /** @hidden */
  115827. _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;
  115828. /**
  115829. * Loads a file from a url
  115830. * @param url url to load
  115831. * @param onSuccess callback called when the file successfully loads
  115832. * @param onProgress callback called while file is loading (if the server supports this mode)
  115833. * @param offlineProvider defines the offline provider for caching
  115834. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115835. * @param onError callback called when the file fails to load
  115836. * @returns a file request object
  115837. * @hidden
  115838. */
  115839. 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;
  115840. /**
  115841. * Reads pixels from the current frame buffer. Please note that this function can be slow
  115842. * @param x defines the x coordinate of the rectangle where pixels must be read
  115843. * @param y defines the y coordinate of the rectangle where pixels must be read
  115844. * @param width defines the width of the rectangle where pixels must be read
  115845. * @param height defines the height of the rectangle where pixels must be read
  115846. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  115847. * @returns a Uint8Array containing RGBA colors
  115848. */
  115849. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  115850. private static _isSupported;
  115851. /**
  115852. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  115853. * @returns true if the engine can be created
  115854. * @ignorenaming
  115855. */
  115856. static isSupported(): boolean;
  115857. /**
  115858. * Find the next highest power of two.
  115859. * @param x Number to start search from.
  115860. * @return Next highest power of two.
  115861. */
  115862. static CeilingPOT(x: number): number;
  115863. /**
  115864. * Find the next lowest power of two.
  115865. * @param x Number to start search from.
  115866. * @return Next lowest power of two.
  115867. */
  115868. static FloorPOT(x: number): number;
  115869. /**
  115870. * Find the nearest power of two.
  115871. * @param x Number to start search from.
  115872. * @return Next nearest power of two.
  115873. */
  115874. static NearestPOT(x: number): number;
  115875. /**
  115876. * Get the closest exponent of two
  115877. * @param value defines the value to approximate
  115878. * @param max defines the maximum value to return
  115879. * @param mode defines how to define the closest value
  115880. * @returns closest exponent of two of the given value
  115881. */
  115882. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  115883. /**
  115884. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  115885. * @param func - the function to be called
  115886. * @param requester - the object that will request the next frame. Falls back to window.
  115887. * @returns frame number
  115888. */
  115889. static QueueNewFrame(func: () => void, requester?: any): number;
  115890. /**
  115891. * Gets host document
  115892. * @returns the host document object
  115893. */
  115894. getHostDocument(): Nullable<Document>;
  115895. }
  115896. }
  115897. declare module BABYLON {
  115898. /**
  115899. * Class representing spherical harmonics coefficients to the 3rd degree
  115900. */
  115901. export class SphericalHarmonics {
  115902. /**
  115903. * Defines whether or not the harmonics have been prescaled for rendering.
  115904. */
  115905. preScaled: boolean;
  115906. /**
  115907. * The l0,0 coefficients of the spherical harmonics
  115908. */
  115909. l00: Vector3;
  115910. /**
  115911. * The l1,-1 coefficients of the spherical harmonics
  115912. */
  115913. l1_1: Vector3;
  115914. /**
  115915. * The l1,0 coefficients of the spherical harmonics
  115916. */
  115917. l10: Vector3;
  115918. /**
  115919. * The l1,1 coefficients of the spherical harmonics
  115920. */
  115921. l11: Vector3;
  115922. /**
  115923. * The l2,-2 coefficients of the spherical harmonics
  115924. */
  115925. l2_2: Vector3;
  115926. /**
  115927. * The l2,-1 coefficients of the spherical harmonics
  115928. */
  115929. l2_1: Vector3;
  115930. /**
  115931. * The l2,0 coefficients of the spherical harmonics
  115932. */
  115933. l20: Vector3;
  115934. /**
  115935. * The l2,1 coefficients of the spherical harmonics
  115936. */
  115937. l21: Vector3;
  115938. /**
  115939. * The l2,2 coefficients of the spherical harmonics
  115940. */
  115941. l22: Vector3;
  115942. /**
  115943. * Adds a light to the spherical harmonics
  115944. * @param direction the direction of the light
  115945. * @param color the color of the light
  115946. * @param deltaSolidAngle the delta solid angle of the light
  115947. */
  115948. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  115949. /**
  115950. * Scales the spherical harmonics by the given amount
  115951. * @param scale the amount to scale
  115952. */
  115953. scaleInPlace(scale: number): void;
  115954. /**
  115955. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  115956. *
  115957. * ```
  115958. * E_lm = A_l * L_lm
  115959. * ```
  115960. *
  115961. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  115962. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  115963. * the scaling factors are given in equation 9.
  115964. */
  115965. convertIncidentRadianceToIrradiance(): void;
  115966. /**
  115967. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  115968. *
  115969. * ```
  115970. * L = (1/pi) * E * rho
  115971. * ```
  115972. *
  115973. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  115974. */
  115975. convertIrradianceToLambertianRadiance(): void;
  115976. /**
  115977. * Integrates the reconstruction coefficients directly in to the SH preventing further
  115978. * required operations at run time.
  115979. *
  115980. * This is simply done by scaling back the SH with Ylm constants parameter.
  115981. * The trigonometric part being applied by the shader at run time.
  115982. */
  115983. preScaleForRendering(): void;
  115984. /**
  115985. * Constructs a spherical harmonics from an array.
  115986. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  115987. * @returns the spherical harmonics
  115988. */
  115989. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  115990. /**
  115991. * Gets the spherical harmonics from polynomial
  115992. * @param polynomial the spherical polynomial
  115993. * @returns the spherical harmonics
  115994. */
  115995. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  115996. }
  115997. /**
  115998. * Class representing spherical polynomial coefficients to the 3rd degree
  115999. */
  116000. export class SphericalPolynomial {
  116001. private _harmonics;
  116002. /**
  116003. * The spherical harmonics used to create the polynomials.
  116004. */
  116005. get preScaledHarmonics(): SphericalHarmonics;
  116006. /**
  116007. * The x coefficients of the spherical polynomial
  116008. */
  116009. x: Vector3;
  116010. /**
  116011. * The y coefficients of the spherical polynomial
  116012. */
  116013. y: Vector3;
  116014. /**
  116015. * The z coefficients of the spherical polynomial
  116016. */
  116017. z: Vector3;
  116018. /**
  116019. * The xx coefficients of the spherical polynomial
  116020. */
  116021. xx: Vector3;
  116022. /**
  116023. * The yy coefficients of the spherical polynomial
  116024. */
  116025. yy: Vector3;
  116026. /**
  116027. * The zz coefficients of the spherical polynomial
  116028. */
  116029. zz: Vector3;
  116030. /**
  116031. * The xy coefficients of the spherical polynomial
  116032. */
  116033. xy: Vector3;
  116034. /**
  116035. * The yz coefficients of the spherical polynomial
  116036. */
  116037. yz: Vector3;
  116038. /**
  116039. * The zx coefficients of the spherical polynomial
  116040. */
  116041. zx: Vector3;
  116042. /**
  116043. * Adds an ambient color to the spherical polynomial
  116044. * @param color the color to add
  116045. */
  116046. addAmbient(color: Color3): void;
  116047. /**
  116048. * Scales the spherical polynomial by the given amount
  116049. * @param scale the amount to scale
  116050. */
  116051. scaleInPlace(scale: number): void;
  116052. /**
  116053. * Gets the spherical polynomial from harmonics
  116054. * @param harmonics the spherical harmonics
  116055. * @returns the spherical polynomial
  116056. */
  116057. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  116058. /**
  116059. * Constructs a spherical polynomial from an array.
  116060. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  116061. * @returns the spherical polynomial
  116062. */
  116063. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  116064. }
  116065. }
  116066. declare module BABYLON {
  116067. /**
  116068. * Defines the source of the internal texture
  116069. */
  116070. export enum InternalTextureSource {
  116071. /**
  116072. * The source of the texture data is unknown
  116073. */
  116074. Unknown = 0,
  116075. /**
  116076. * Texture data comes from an URL
  116077. */
  116078. Url = 1,
  116079. /**
  116080. * Texture data is only used for temporary storage
  116081. */
  116082. Temp = 2,
  116083. /**
  116084. * Texture data comes from raw data (ArrayBuffer)
  116085. */
  116086. Raw = 3,
  116087. /**
  116088. * Texture content is dynamic (video or dynamic texture)
  116089. */
  116090. Dynamic = 4,
  116091. /**
  116092. * Texture content is generated by rendering to it
  116093. */
  116094. RenderTarget = 5,
  116095. /**
  116096. * Texture content is part of a multi render target process
  116097. */
  116098. MultiRenderTarget = 6,
  116099. /**
  116100. * Texture data comes from a cube data file
  116101. */
  116102. Cube = 7,
  116103. /**
  116104. * Texture data comes from a raw cube data
  116105. */
  116106. CubeRaw = 8,
  116107. /**
  116108. * Texture data come from a prefiltered cube data file
  116109. */
  116110. CubePrefiltered = 9,
  116111. /**
  116112. * Texture content is raw 3D data
  116113. */
  116114. Raw3D = 10,
  116115. /**
  116116. * Texture content is raw 2D array data
  116117. */
  116118. Raw2DArray = 11,
  116119. /**
  116120. * Texture content is a depth texture
  116121. */
  116122. Depth = 12,
  116123. /**
  116124. * Texture data comes from a raw cube data encoded with RGBD
  116125. */
  116126. CubeRawRGBD = 13
  116127. }
  116128. /**
  116129. * Class used to store data associated with WebGL texture data for the engine
  116130. * This class should not be used directly
  116131. */
  116132. export class InternalTexture {
  116133. /** @hidden */
  116134. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  116135. /**
  116136. * Defines if the texture is ready
  116137. */
  116138. isReady: boolean;
  116139. /**
  116140. * Defines if the texture is a cube texture
  116141. */
  116142. isCube: boolean;
  116143. /**
  116144. * Defines if the texture contains 3D data
  116145. */
  116146. is3D: boolean;
  116147. /**
  116148. * Defines if the texture contains 2D array data
  116149. */
  116150. is2DArray: boolean;
  116151. /**
  116152. * Defines if the texture contains multiview data
  116153. */
  116154. isMultiview: boolean;
  116155. /**
  116156. * Gets the URL used to load this texture
  116157. */
  116158. url: string;
  116159. /**
  116160. * Gets the sampling mode of the texture
  116161. */
  116162. samplingMode: number;
  116163. /**
  116164. * Gets a boolean indicating if the texture needs mipmaps generation
  116165. */
  116166. generateMipMaps: boolean;
  116167. /**
  116168. * Gets the number of samples used by the texture (WebGL2+ only)
  116169. */
  116170. samples: number;
  116171. /**
  116172. * Gets the type of the texture (int, float...)
  116173. */
  116174. type: number;
  116175. /**
  116176. * Gets the format of the texture (RGB, RGBA...)
  116177. */
  116178. format: number;
  116179. /**
  116180. * Observable called when the texture is loaded
  116181. */
  116182. onLoadedObservable: Observable<InternalTexture>;
  116183. /**
  116184. * Gets the width of the texture
  116185. */
  116186. width: number;
  116187. /**
  116188. * Gets the height of the texture
  116189. */
  116190. height: number;
  116191. /**
  116192. * Gets the depth of the texture
  116193. */
  116194. depth: number;
  116195. /**
  116196. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  116197. */
  116198. baseWidth: number;
  116199. /**
  116200. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  116201. */
  116202. baseHeight: number;
  116203. /**
  116204. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  116205. */
  116206. baseDepth: number;
  116207. /**
  116208. * Gets a boolean indicating if the texture is inverted on Y axis
  116209. */
  116210. invertY: boolean;
  116211. /** @hidden */
  116212. _invertVScale: boolean;
  116213. /** @hidden */
  116214. _associatedChannel: number;
  116215. /** @hidden */
  116216. _source: InternalTextureSource;
  116217. /** @hidden */
  116218. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  116219. /** @hidden */
  116220. _bufferView: Nullable<ArrayBufferView>;
  116221. /** @hidden */
  116222. _bufferViewArray: Nullable<ArrayBufferView[]>;
  116223. /** @hidden */
  116224. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  116225. /** @hidden */
  116226. _size: number;
  116227. /** @hidden */
  116228. _extension: string;
  116229. /** @hidden */
  116230. _files: Nullable<string[]>;
  116231. /** @hidden */
  116232. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  116233. /** @hidden */
  116234. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  116235. /** @hidden */
  116236. _framebuffer: Nullable<WebGLFramebuffer>;
  116237. /** @hidden */
  116238. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  116239. /** @hidden */
  116240. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  116241. /** @hidden */
  116242. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  116243. /** @hidden */
  116244. _attachments: Nullable<number[]>;
  116245. /** @hidden */
  116246. _textureArray: Nullable<InternalTexture[]>;
  116247. /** @hidden */
  116248. _cachedCoordinatesMode: Nullable<number>;
  116249. /** @hidden */
  116250. _cachedWrapU: Nullable<number>;
  116251. /** @hidden */
  116252. _cachedWrapV: Nullable<number>;
  116253. /** @hidden */
  116254. _cachedWrapR: Nullable<number>;
  116255. /** @hidden */
  116256. _cachedAnisotropicFilteringLevel: Nullable<number>;
  116257. /** @hidden */
  116258. _isDisabled: boolean;
  116259. /** @hidden */
  116260. _compression: Nullable<string>;
  116261. /** @hidden */
  116262. _generateStencilBuffer: boolean;
  116263. /** @hidden */
  116264. _generateDepthBuffer: boolean;
  116265. /** @hidden */
  116266. _comparisonFunction: number;
  116267. /** @hidden */
  116268. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  116269. /** @hidden */
  116270. _lodGenerationScale: number;
  116271. /** @hidden */
  116272. _lodGenerationOffset: number;
  116273. /** @hidden */
  116274. _depthStencilTexture: Nullable<InternalTexture>;
  116275. /** @hidden */
  116276. _colorTextureArray: Nullable<WebGLTexture>;
  116277. /** @hidden */
  116278. _depthStencilTextureArray: Nullable<WebGLTexture>;
  116279. /** @hidden */
  116280. _lodTextureHigh: Nullable<BaseTexture>;
  116281. /** @hidden */
  116282. _lodTextureMid: Nullable<BaseTexture>;
  116283. /** @hidden */
  116284. _lodTextureLow: Nullable<BaseTexture>;
  116285. /** @hidden */
  116286. _isRGBD: boolean;
  116287. /** @hidden */
  116288. _linearSpecularLOD: boolean;
  116289. /** @hidden */
  116290. _irradianceTexture: Nullable<BaseTexture>;
  116291. /** @hidden */
  116292. _webGLTexture: Nullable<WebGLTexture>;
  116293. /** @hidden */
  116294. _references: number;
  116295. private _engine;
  116296. /**
  116297. * Gets the Engine the texture belongs to.
  116298. * @returns The babylon engine
  116299. */
  116300. getEngine(): ThinEngine;
  116301. /**
  116302. * Gets the data source type of the texture
  116303. */
  116304. get source(): InternalTextureSource;
  116305. /**
  116306. * Creates a new InternalTexture
  116307. * @param engine defines the engine to use
  116308. * @param source defines the type of data that will be used
  116309. * @param delayAllocation if the texture allocation should be delayed (default: false)
  116310. */
  116311. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  116312. /**
  116313. * Increments the number of references (ie. the number of Texture that point to it)
  116314. */
  116315. incrementReferences(): void;
  116316. /**
  116317. * Change the size of the texture (not the size of the content)
  116318. * @param width defines the new width
  116319. * @param height defines the new height
  116320. * @param depth defines the new depth (1 by default)
  116321. */
  116322. updateSize(width: int, height: int, depth?: int): void;
  116323. /** @hidden */
  116324. _rebuild(): void;
  116325. /** @hidden */
  116326. _swapAndDie(target: InternalTexture): void;
  116327. /**
  116328. * Dispose the current allocated resources
  116329. */
  116330. dispose(): void;
  116331. }
  116332. }
  116333. declare module BABYLON {
  116334. /**
  116335. * Class used to work with sound analyzer using fast fourier transform (FFT)
  116336. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116337. */
  116338. export class Analyser {
  116339. /**
  116340. * Gets or sets the smoothing
  116341. * @ignorenaming
  116342. */
  116343. SMOOTHING: number;
  116344. /**
  116345. * Gets or sets the FFT table size
  116346. * @ignorenaming
  116347. */
  116348. FFT_SIZE: number;
  116349. /**
  116350. * Gets or sets the bar graph amplitude
  116351. * @ignorenaming
  116352. */
  116353. BARGRAPHAMPLITUDE: number;
  116354. /**
  116355. * Gets or sets the position of the debug canvas
  116356. * @ignorenaming
  116357. */
  116358. DEBUGCANVASPOS: {
  116359. x: number;
  116360. y: number;
  116361. };
  116362. /**
  116363. * Gets or sets the debug canvas size
  116364. * @ignorenaming
  116365. */
  116366. DEBUGCANVASSIZE: {
  116367. width: number;
  116368. height: number;
  116369. };
  116370. private _byteFreqs;
  116371. private _byteTime;
  116372. private _floatFreqs;
  116373. private _webAudioAnalyser;
  116374. private _debugCanvas;
  116375. private _debugCanvasContext;
  116376. private _scene;
  116377. private _registerFunc;
  116378. private _audioEngine;
  116379. /**
  116380. * Creates a new analyser
  116381. * @param scene defines hosting scene
  116382. */
  116383. constructor(scene: Scene);
  116384. /**
  116385. * Get the number of data values you will have to play with for the visualization
  116386. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  116387. * @returns a number
  116388. */
  116389. getFrequencyBinCount(): number;
  116390. /**
  116391. * Gets the current frequency data as a byte array
  116392. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  116393. * @returns a Uint8Array
  116394. */
  116395. getByteFrequencyData(): Uint8Array;
  116396. /**
  116397. * Gets the current waveform as a byte array
  116398. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  116399. * @returns a Uint8Array
  116400. */
  116401. getByteTimeDomainData(): Uint8Array;
  116402. /**
  116403. * Gets the current frequency data as a float array
  116404. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  116405. * @returns a Float32Array
  116406. */
  116407. getFloatFrequencyData(): Float32Array;
  116408. /**
  116409. * Renders the debug canvas
  116410. */
  116411. drawDebugCanvas(): void;
  116412. /**
  116413. * Stops rendering the debug canvas and removes it
  116414. */
  116415. stopDebugCanvas(): void;
  116416. /**
  116417. * Connects two audio nodes
  116418. * @param inputAudioNode defines first node to connect
  116419. * @param outputAudioNode defines second node to connect
  116420. */
  116421. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  116422. /**
  116423. * Releases all associated resources
  116424. */
  116425. dispose(): void;
  116426. }
  116427. }
  116428. declare module BABYLON {
  116429. /**
  116430. * This represents an audio engine and it is responsible
  116431. * to play, synchronize and analyse sounds throughout the application.
  116432. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116433. */
  116434. export interface IAudioEngine extends IDisposable {
  116435. /**
  116436. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  116437. */
  116438. readonly canUseWebAudio: boolean;
  116439. /**
  116440. * Gets the current AudioContext if available.
  116441. */
  116442. readonly audioContext: Nullable<AudioContext>;
  116443. /**
  116444. * The master gain node defines the global audio volume of your audio engine.
  116445. */
  116446. readonly masterGain: GainNode;
  116447. /**
  116448. * Gets whether or not mp3 are supported by your browser.
  116449. */
  116450. readonly isMP3supported: boolean;
  116451. /**
  116452. * Gets whether or not ogg are supported by your browser.
  116453. */
  116454. readonly isOGGsupported: boolean;
  116455. /**
  116456. * Defines if Babylon should emit a warning if WebAudio is not supported.
  116457. * @ignoreNaming
  116458. */
  116459. WarnedWebAudioUnsupported: boolean;
  116460. /**
  116461. * Defines if the audio engine relies on a custom unlocked button.
  116462. * In this case, the embedded button will not be displayed.
  116463. */
  116464. useCustomUnlockedButton: boolean;
  116465. /**
  116466. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  116467. */
  116468. readonly unlocked: boolean;
  116469. /**
  116470. * Event raised when audio has been unlocked on the browser.
  116471. */
  116472. onAudioUnlockedObservable: Observable<AudioEngine>;
  116473. /**
  116474. * Event raised when audio has been locked on the browser.
  116475. */
  116476. onAudioLockedObservable: Observable<AudioEngine>;
  116477. /**
  116478. * Flags the audio engine in Locked state.
  116479. * This happens due to new browser policies preventing audio to autoplay.
  116480. */
  116481. lock(): void;
  116482. /**
  116483. * Unlocks the audio engine once a user action has been done on the dom.
  116484. * This is helpful to resume play once browser policies have been satisfied.
  116485. */
  116486. unlock(): void;
  116487. /**
  116488. * Gets the global volume sets on the master gain.
  116489. * @returns the global volume if set or -1 otherwise
  116490. */
  116491. getGlobalVolume(): number;
  116492. /**
  116493. * Sets the global volume of your experience (sets on the master gain).
  116494. * @param newVolume Defines the new global volume of the application
  116495. */
  116496. setGlobalVolume(newVolume: number): void;
  116497. /**
  116498. * Connect the audio engine to an audio analyser allowing some amazing
  116499. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  116500. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  116501. * @param analyser The analyser to connect to the engine
  116502. */
  116503. connectToAnalyser(analyser: Analyser): void;
  116504. }
  116505. /**
  116506. * This represents the default audio engine used in babylon.
  116507. * It is responsible to play, synchronize and analyse sounds throughout the application.
  116508. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116509. */
  116510. export class AudioEngine implements IAudioEngine {
  116511. private _audioContext;
  116512. private _audioContextInitialized;
  116513. private _muteButton;
  116514. private _hostElement;
  116515. /**
  116516. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  116517. */
  116518. canUseWebAudio: boolean;
  116519. /**
  116520. * The master gain node defines the global audio volume of your audio engine.
  116521. */
  116522. masterGain: GainNode;
  116523. /**
  116524. * Defines if Babylon should emit a warning if WebAudio is not supported.
  116525. * @ignoreNaming
  116526. */
  116527. WarnedWebAudioUnsupported: boolean;
  116528. /**
  116529. * Gets whether or not mp3 are supported by your browser.
  116530. */
  116531. isMP3supported: boolean;
  116532. /**
  116533. * Gets whether or not ogg are supported by your browser.
  116534. */
  116535. isOGGsupported: boolean;
  116536. /**
  116537. * Gets whether audio has been unlocked on the device.
  116538. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  116539. * a user interaction has happened.
  116540. */
  116541. unlocked: boolean;
  116542. /**
  116543. * Defines if the audio engine relies on a custom unlocked button.
  116544. * In this case, the embedded button will not be displayed.
  116545. */
  116546. useCustomUnlockedButton: boolean;
  116547. /**
  116548. * Event raised when audio has been unlocked on the browser.
  116549. */
  116550. onAudioUnlockedObservable: Observable<AudioEngine>;
  116551. /**
  116552. * Event raised when audio has been locked on the browser.
  116553. */
  116554. onAudioLockedObservable: Observable<AudioEngine>;
  116555. /**
  116556. * Gets the current AudioContext if available.
  116557. */
  116558. get audioContext(): Nullable<AudioContext>;
  116559. private _connectedAnalyser;
  116560. /**
  116561. * Instantiates a new audio engine.
  116562. *
  116563. * There should be only one per page as some browsers restrict the number
  116564. * of audio contexts you can create.
  116565. * @param hostElement defines the host element where to display the mute icon if necessary
  116566. */
  116567. constructor(hostElement?: Nullable<HTMLElement>);
  116568. /**
  116569. * Flags the audio engine in Locked state.
  116570. * This happens due to new browser policies preventing audio to autoplay.
  116571. */
  116572. lock(): void;
  116573. /**
  116574. * Unlocks the audio engine once a user action has been done on the dom.
  116575. * This is helpful to resume play once browser policies have been satisfied.
  116576. */
  116577. unlock(): void;
  116578. private _resumeAudioContext;
  116579. private _initializeAudioContext;
  116580. private _tryToRun;
  116581. private _triggerRunningState;
  116582. private _triggerSuspendedState;
  116583. private _displayMuteButton;
  116584. private _moveButtonToTopLeft;
  116585. private _onResize;
  116586. private _hideMuteButton;
  116587. /**
  116588. * Destroy and release the resources associated with the audio ccontext.
  116589. */
  116590. dispose(): void;
  116591. /**
  116592. * Gets the global volume sets on the master gain.
  116593. * @returns the global volume if set or -1 otherwise
  116594. */
  116595. getGlobalVolume(): number;
  116596. /**
  116597. * Sets the global volume of your experience (sets on the master gain).
  116598. * @param newVolume Defines the new global volume of the application
  116599. */
  116600. setGlobalVolume(newVolume: number): void;
  116601. /**
  116602. * Connect the audio engine to an audio analyser allowing some amazing
  116603. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  116604. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  116605. * @param analyser The analyser to connect to the engine
  116606. */
  116607. connectToAnalyser(analyser: Analyser): void;
  116608. }
  116609. }
  116610. declare module BABYLON {
  116611. /**
  116612. * Interface used to present a loading screen while loading a scene
  116613. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116614. */
  116615. export interface ILoadingScreen {
  116616. /**
  116617. * Function called to display the loading screen
  116618. */
  116619. displayLoadingUI: () => void;
  116620. /**
  116621. * Function called to hide the loading screen
  116622. */
  116623. hideLoadingUI: () => void;
  116624. /**
  116625. * Gets or sets the color to use for the background
  116626. */
  116627. loadingUIBackgroundColor: string;
  116628. /**
  116629. * Gets or sets the text to display while loading
  116630. */
  116631. loadingUIText: string;
  116632. }
  116633. /**
  116634. * Class used for the default loading screen
  116635. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116636. */
  116637. export class DefaultLoadingScreen implements ILoadingScreen {
  116638. private _renderingCanvas;
  116639. private _loadingText;
  116640. private _loadingDivBackgroundColor;
  116641. private _loadingDiv;
  116642. private _loadingTextDiv;
  116643. /** Gets or sets the logo url to use for the default loading screen */
  116644. static DefaultLogoUrl: string;
  116645. /** Gets or sets the spinner url to use for the default loading screen */
  116646. static DefaultSpinnerUrl: string;
  116647. /**
  116648. * Creates a new default loading screen
  116649. * @param _renderingCanvas defines the canvas used to render the scene
  116650. * @param _loadingText defines the default text to display
  116651. * @param _loadingDivBackgroundColor defines the default background color
  116652. */
  116653. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  116654. /**
  116655. * Function called to display the loading screen
  116656. */
  116657. displayLoadingUI(): void;
  116658. /**
  116659. * Function called to hide the loading screen
  116660. */
  116661. hideLoadingUI(): void;
  116662. /**
  116663. * Gets or sets the text to display while loading
  116664. */
  116665. set loadingUIText(text: string);
  116666. get loadingUIText(): string;
  116667. /**
  116668. * Gets or sets the color to use for the background
  116669. */
  116670. get loadingUIBackgroundColor(): string;
  116671. set loadingUIBackgroundColor(color: string);
  116672. private _resizeLoadingUI;
  116673. }
  116674. }
  116675. declare module BABYLON {
  116676. /**
  116677. * Interface for any object that can request an animation frame
  116678. */
  116679. export interface ICustomAnimationFrameRequester {
  116680. /**
  116681. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  116682. */
  116683. renderFunction?: Function;
  116684. /**
  116685. * Called to request the next frame to render to
  116686. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  116687. */
  116688. requestAnimationFrame: Function;
  116689. /**
  116690. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  116691. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  116692. */
  116693. requestID?: number;
  116694. }
  116695. }
  116696. declare module BABYLON {
  116697. /**
  116698. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  116699. */
  116700. export class PerformanceMonitor {
  116701. private _enabled;
  116702. private _rollingFrameTime;
  116703. private _lastFrameTimeMs;
  116704. /**
  116705. * constructor
  116706. * @param frameSampleSize The number of samples required to saturate the sliding window
  116707. */
  116708. constructor(frameSampleSize?: number);
  116709. /**
  116710. * Samples current frame
  116711. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  116712. */
  116713. sampleFrame(timeMs?: number): void;
  116714. /**
  116715. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  116716. */
  116717. get averageFrameTime(): number;
  116718. /**
  116719. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  116720. */
  116721. get averageFrameTimeVariance(): number;
  116722. /**
  116723. * Returns the frame time of the most recent frame
  116724. */
  116725. get instantaneousFrameTime(): number;
  116726. /**
  116727. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  116728. */
  116729. get averageFPS(): number;
  116730. /**
  116731. * Returns the average framerate in frames per second using the most recent frame time
  116732. */
  116733. get instantaneousFPS(): number;
  116734. /**
  116735. * Returns true if enough samples have been taken to completely fill the sliding window
  116736. */
  116737. get isSaturated(): boolean;
  116738. /**
  116739. * Enables contributions to the sliding window sample set
  116740. */
  116741. enable(): void;
  116742. /**
  116743. * Disables contributions to the sliding window sample set
  116744. * Samples will not be interpolated over the disabled period
  116745. */
  116746. disable(): void;
  116747. /**
  116748. * Returns true if sampling is enabled
  116749. */
  116750. get isEnabled(): boolean;
  116751. /**
  116752. * Resets performance monitor
  116753. */
  116754. reset(): void;
  116755. }
  116756. /**
  116757. * RollingAverage
  116758. *
  116759. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  116760. */
  116761. export class RollingAverage {
  116762. /**
  116763. * Current average
  116764. */
  116765. average: number;
  116766. /**
  116767. * Current variance
  116768. */
  116769. variance: number;
  116770. protected _samples: Array<number>;
  116771. protected _sampleCount: number;
  116772. protected _pos: number;
  116773. protected _m2: number;
  116774. /**
  116775. * constructor
  116776. * @param length The number of samples required to saturate the sliding window
  116777. */
  116778. constructor(length: number);
  116779. /**
  116780. * Adds a sample to the sample set
  116781. * @param v The sample value
  116782. */
  116783. add(v: number): void;
  116784. /**
  116785. * Returns previously added values or null if outside of history or outside the sliding window domain
  116786. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  116787. * @return Value previously recorded with add() or null if outside of range
  116788. */
  116789. history(i: number): number;
  116790. /**
  116791. * Returns true if enough samples have been taken to completely fill the sliding window
  116792. * @return true if sample-set saturated
  116793. */
  116794. isSaturated(): boolean;
  116795. /**
  116796. * Resets the rolling average (equivalent to 0 samples taken so far)
  116797. */
  116798. reset(): void;
  116799. /**
  116800. * Wraps a value around the sample range boundaries
  116801. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  116802. * @return Wrapped position in sample range
  116803. */
  116804. protected _wrapPosition(i: number): number;
  116805. }
  116806. }
  116807. declare module BABYLON {
  116808. /**
  116809. * This class is used to track a performance counter which is number based.
  116810. * The user has access to many properties which give statistics of different nature.
  116811. *
  116812. * The implementer can track two kinds of Performance Counter: time and count.
  116813. * 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.
  116814. * 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.
  116815. */
  116816. export class PerfCounter {
  116817. /**
  116818. * Gets or sets a global boolean to turn on and off all the counters
  116819. */
  116820. static Enabled: boolean;
  116821. /**
  116822. * Returns the smallest value ever
  116823. */
  116824. get min(): number;
  116825. /**
  116826. * Returns the biggest value ever
  116827. */
  116828. get max(): number;
  116829. /**
  116830. * Returns the average value since the performance counter is running
  116831. */
  116832. get average(): number;
  116833. /**
  116834. * Returns the average value of the last second the counter was monitored
  116835. */
  116836. get lastSecAverage(): number;
  116837. /**
  116838. * Returns the current value
  116839. */
  116840. get current(): number;
  116841. /**
  116842. * Gets the accumulated total
  116843. */
  116844. get total(): number;
  116845. /**
  116846. * Gets the total value count
  116847. */
  116848. get count(): number;
  116849. /**
  116850. * Creates a new counter
  116851. */
  116852. constructor();
  116853. /**
  116854. * Call this method to start monitoring a new frame.
  116855. * 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.
  116856. */
  116857. fetchNewFrame(): void;
  116858. /**
  116859. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  116860. * @param newCount the count value to add to the monitored count
  116861. * @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.
  116862. */
  116863. addCount(newCount: number, fetchResult: boolean): void;
  116864. /**
  116865. * Start monitoring this performance counter
  116866. */
  116867. beginMonitoring(): void;
  116868. /**
  116869. * Compute the time lapsed since the previous beginMonitoring() call.
  116870. * @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
  116871. */
  116872. endMonitoring(newFrame?: boolean): void;
  116873. private _fetchResult;
  116874. private _startMonitoringTime;
  116875. private _min;
  116876. private _max;
  116877. private _average;
  116878. private _current;
  116879. private _totalValueCount;
  116880. private _totalAccumulated;
  116881. private _lastSecAverage;
  116882. private _lastSecAccumulated;
  116883. private _lastSecTime;
  116884. private _lastSecValueCount;
  116885. }
  116886. }
  116887. declare module BABYLON {
  116888. interface ThinEngine {
  116889. /** @hidden */
  116890. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  116891. }
  116892. }
  116893. declare module BABYLON {
  116894. /**
  116895. * Defines the interface used by display changed events
  116896. */
  116897. export interface IDisplayChangedEventArgs {
  116898. /** Gets the vrDisplay object (if any) */
  116899. vrDisplay: Nullable<any>;
  116900. /** Gets a boolean indicating if webVR is supported */
  116901. vrSupported: boolean;
  116902. }
  116903. /**
  116904. * Defines the interface used by objects containing a viewport (like a camera)
  116905. */
  116906. interface IViewportOwnerLike {
  116907. /**
  116908. * Gets or sets the viewport
  116909. */
  116910. viewport: IViewportLike;
  116911. }
  116912. /**
  116913. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  116914. */
  116915. export class Engine extends ThinEngine {
  116916. /** Defines that alpha blending is disabled */
  116917. static readonly ALPHA_DISABLE: number;
  116918. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  116919. static readonly ALPHA_ADD: number;
  116920. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  116921. static readonly ALPHA_COMBINE: number;
  116922. /** Defines that alpha blending to DEST - SRC * DEST */
  116923. static readonly ALPHA_SUBTRACT: number;
  116924. /** Defines that alpha blending to SRC * DEST */
  116925. static readonly ALPHA_MULTIPLY: number;
  116926. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  116927. static readonly ALPHA_MAXIMIZED: number;
  116928. /** Defines that alpha blending to SRC + DEST */
  116929. static readonly ALPHA_ONEONE: number;
  116930. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  116931. static readonly ALPHA_PREMULTIPLIED: number;
  116932. /**
  116933. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  116934. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  116935. */
  116936. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  116937. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  116938. static readonly ALPHA_INTERPOLATE: number;
  116939. /**
  116940. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  116941. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  116942. */
  116943. static readonly ALPHA_SCREENMODE: number;
  116944. /** Defines that the ressource is not delayed*/
  116945. static readonly DELAYLOADSTATE_NONE: number;
  116946. /** Defines that the ressource was successfully delay loaded */
  116947. static readonly DELAYLOADSTATE_LOADED: number;
  116948. /** Defines that the ressource is currently delay loading */
  116949. static readonly DELAYLOADSTATE_LOADING: number;
  116950. /** Defines that the ressource is delayed and has not started loading */
  116951. static readonly DELAYLOADSTATE_NOTLOADED: number;
  116952. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  116953. static readonly NEVER: number;
  116954. /** 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 */
  116955. static readonly ALWAYS: number;
  116956. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  116957. static readonly LESS: number;
  116958. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  116959. static readonly EQUAL: number;
  116960. /** 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 */
  116961. static readonly LEQUAL: number;
  116962. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  116963. static readonly GREATER: number;
  116964. /** 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 */
  116965. static readonly GEQUAL: number;
  116966. /** 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 */
  116967. static readonly NOTEQUAL: number;
  116968. /** Passed to stencilOperation to specify that stencil value must be kept */
  116969. static readonly KEEP: number;
  116970. /** Passed to stencilOperation to specify that stencil value must be replaced */
  116971. static readonly REPLACE: number;
  116972. /** Passed to stencilOperation to specify that stencil value must be incremented */
  116973. static readonly INCR: number;
  116974. /** Passed to stencilOperation to specify that stencil value must be decremented */
  116975. static readonly DECR: number;
  116976. /** Passed to stencilOperation to specify that stencil value must be inverted */
  116977. static readonly INVERT: number;
  116978. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  116979. static readonly INCR_WRAP: number;
  116980. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  116981. static readonly DECR_WRAP: number;
  116982. /** Texture is not repeating outside of 0..1 UVs */
  116983. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  116984. /** Texture is repeating outside of 0..1 UVs */
  116985. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  116986. /** Texture is repeating and mirrored */
  116987. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  116988. /** ALPHA */
  116989. static readonly TEXTUREFORMAT_ALPHA: number;
  116990. /** LUMINANCE */
  116991. static readonly TEXTUREFORMAT_LUMINANCE: number;
  116992. /** LUMINANCE_ALPHA */
  116993. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  116994. /** RGB */
  116995. static readonly TEXTUREFORMAT_RGB: number;
  116996. /** RGBA */
  116997. static readonly TEXTUREFORMAT_RGBA: number;
  116998. /** RED */
  116999. static readonly TEXTUREFORMAT_RED: number;
  117000. /** RED (2nd reference) */
  117001. static readonly TEXTUREFORMAT_R: number;
  117002. /** RG */
  117003. static readonly TEXTUREFORMAT_RG: number;
  117004. /** RED_INTEGER */
  117005. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  117006. /** RED_INTEGER (2nd reference) */
  117007. static readonly TEXTUREFORMAT_R_INTEGER: number;
  117008. /** RG_INTEGER */
  117009. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  117010. /** RGB_INTEGER */
  117011. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  117012. /** RGBA_INTEGER */
  117013. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  117014. /** UNSIGNED_BYTE */
  117015. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  117016. /** UNSIGNED_BYTE (2nd reference) */
  117017. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  117018. /** FLOAT */
  117019. static readonly TEXTURETYPE_FLOAT: number;
  117020. /** HALF_FLOAT */
  117021. static readonly TEXTURETYPE_HALF_FLOAT: number;
  117022. /** BYTE */
  117023. static readonly TEXTURETYPE_BYTE: number;
  117024. /** SHORT */
  117025. static readonly TEXTURETYPE_SHORT: number;
  117026. /** UNSIGNED_SHORT */
  117027. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  117028. /** INT */
  117029. static readonly TEXTURETYPE_INT: number;
  117030. /** UNSIGNED_INT */
  117031. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  117032. /** UNSIGNED_SHORT_4_4_4_4 */
  117033. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  117034. /** UNSIGNED_SHORT_5_5_5_1 */
  117035. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  117036. /** UNSIGNED_SHORT_5_6_5 */
  117037. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  117038. /** UNSIGNED_INT_2_10_10_10_REV */
  117039. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  117040. /** UNSIGNED_INT_24_8 */
  117041. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  117042. /** UNSIGNED_INT_10F_11F_11F_REV */
  117043. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  117044. /** UNSIGNED_INT_5_9_9_9_REV */
  117045. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  117046. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  117047. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  117048. /** nearest is mag = nearest and min = nearest and mip = linear */
  117049. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  117050. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117051. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  117052. /** Trilinear is mag = linear and min = linear and mip = linear */
  117053. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  117054. /** nearest is mag = nearest and min = nearest and mip = linear */
  117055. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  117056. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117057. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  117058. /** Trilinear is mag = linear and min = linear and mip = linear */
  117059. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  117060. /** mag = nearest and min = nearest and mip = nearest */
  117061. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  117062. /** mag = nearest and min = linear and mip = nearest */
  117063. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  117064. /** mag = nearest and min = linear and mip = linear */
  117065. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  117066. /** mag = nearest and min = linear and mip = none */
  117067. static readonly TEXTURE_NEAREST_LINEAR: number;
  117068. /** mag = nearest and min = nearest and mip = none */
  117069. static readonly TEXTURE_NEAREST_NEAREST: number;
  117070. /** mag = linear and min = nearest and mip = nearest */
  117071. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  117072. /** mag = linear and min = nearest and mip = linear */
  117073. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  117074. /** mag = linear and min = linear and mip = none */
  117075. static readonly TEXTURE_LINEAR_LINEAR: number;
  117076. /** mag = linear and min = nearest and mip = none */
  117077. static readonly TEXTURE_LINEAR_NEAREST: number;
  117078. /** Explicit coordinates mode */
  117079. static readonly TEXTURE_EXPLICIT_MODE: number;
  117080. /** Spherical coordinates mode */
  117081. static readonly TEXTURE_SPHERICAL_MODE: number;
  117082. /** Planar coordinates mode */
  117083. static readonly TEXTURE_PLANAR_MODE: number;
  117084. /** Cubic coordinates mode */
  117085. static readonly TEXTURE_CUBIC_MODE: number;
  117086. /** Projection coordinates mode */
  117087. static readonly TEXTURE_PROJECTION_MODE: number;
  117088. /** Skybox coordinates mode */
  117089. static readonly TEXTURE_SKYBOX_MODE: number;
  117090. /** Inverse Cubic coordinates mode */
  117091. static readonly TEXTURE_INVCUBIC_MODE: number;
  117092. /** Equirectangular coordinates mode */
  117093. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  117094. /** Equirectangular Fixed coordinates mode */
  117095. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  117096. /** Equirectangular Fixed Mirrored coordinates mode */
  117097. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  117098. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  117099. static readonly SCALEMODE_FLOOR: number;
  117100. /** Defines that texture rescaling will look for the nearest power of 2 size */
  117101. static readonly SCALEMODE_NEAREST: number;
  117102. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  117103. static readonly SCALEMODE_CEILING: number;
  117104. /**
  117105. * Returns the current npm package of the sdk
  117106. */
  117107. static get NpmPackage(): string;
  117108. /**
  117109. * Returns the current version of the framework
  117110. */
  117111. static get Version(): string;
  117112. /** Gets the list of created engines */
  117113. static get Instances(): Engine[];
  117114. /**
  117115. * Gets the latest created engine
  117116. */
  117117. static get LastCreatedEngine(): Nullable<Engine>;
  117118. /**
  117119. * Gets the latest created scene
  117120. */
  117121. static get LastCreatedScene(): Nullable<Scene>;
  117122. /**
  117123. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  117124. * @param flag defines which part of the materials must be marked as dirty
  117125. * @param predicate defines a predicate used to filter which materials should be affected
  117126. */
  117127. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117128. /**
  117129. * Method called to create the default loading screen.
  117130. * This can be overriden in your own app.
  117131. * @param canvas The rendering canvas element
  117132. * @returns The loading screen
  117133. */
  117134. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  117135. /**
  117136. * Method called to create the default rescale post process on each engine.
  117137. */
  117138. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  117139. /**
  117140. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  117141. **/
  117142. enableOfflineSupport: boolean;
  117143. /**
  117144. * 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)
  117145. **/
  117146. disableManifestCheck: boolean;
  117147. /**
  117148. * Gets the list of created scenes
  117149. */
  117150. scenes: Scene[];
  117151. /**
  117152. * Event raised when a new scene is created
  117153. */
  117154. onNewSceneAddedObservable: Observable<Scene>;
  117155. /**
  117156. * Gets the list of created postprocesses
  117157. */
  117158. postProcesses: PostProcess[];
  117159. /**
  117160. * Gets a boolean indicating if the pointer is currently locked
  117161. */
  117162. isPointerLock: boolean;
  117163. /**
  117164. * Observable event triggered each time the rendering canvas is resized
  117165. */
  117166. onResizeObservable: Observable<Engine>;
  117167. /**
  117168. * Observable event triggered each time the canvas loses focus
  117169. */
  117170. onCanvasBlurObservable: Observable<Engine>;
  117171. /**
  117172. * Observable event triggered each time the canvas gains focus
  117173. */
  117174. onCanvasFocusObservable: Observable<Engine>;
  117175. /**
  117176. * Observable event triggered each time the canvas receives pointerout event
  117177. */
  117178. onCanvasPointerOutObservable: Observable<PointerEvent>;
  117179. /**
  117180. * Observable raised when the engine begins a new frame
  117181. */
  117182. onBeginFrameObservable: Observable<Engine>;
  117183. /**
  117184. * If set, will be used to request the next animation frame for the render loop
  117185. */
  117186. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  117187. /**
  117188. * Observable raised when the engine ends the current frame
  117189. */
  117190. onEndFrameObservable: Observable<Engine>;
  117191. /**
  117192. * Observable raised when the engine is about to compile a shader
  117193. */
  117194. onBeforeShaderCompilationObservable: Observable<Engine>;
  117195. /**
  117196. * Observable raised when the engine has jsut compiled a shader
  117197. */
  117198. onAfterShaderCompilationObservable: Observable<Engine>;
  117199. /**
  117200. * Gets the audio engine
  117201. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117202. * @ignorenaming
  117203. */
  117204. static audioEngine: IAudioEngine;
  117205. /**
  117206. * Default AudioEngine factory responsible of creating the Audio Engine.
  117207. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  117208. */
  117209. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  117210. /**
  117211. * Default offline support factory responsible of creating a tool used to store data locally.
  117212. * By default, this will create a Database object if the workload has been embedded.
  117213. */
  117214. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  117215. private _loadingScreen;
  117216. private _pointerLockRequested;
  117217. private _rescalePostProcess;
  117218. private _deterministicLockstep;
  117219. private _lockstepMaxSteps;
  117220. private _timeStep;
  117221. protected get _supportsHardwareTextureRescaling(): boolean;
  117222. private _fps;
  117223. private _deltaTime;
  117224. /** @hidden */
  117225. _drawCalls: PerfCounter;
  117226. /** 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 */
  117227. canvasTabIndex: number;
  117228. /**
  117229. * Turn this value on if you want to pause FPS computation when in background
  117230. */
  117231. disablePerformanceMonitorInBackground: boolean;
  117232. private _performanceMonitor;
  117233. /**
  117234. * Gets the performance monitor attached to this engine
  117235. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117236. */
  117237. get performanceMonitor(): PerformanceMonitor;
  117238. private _onFocus;
  117239. private _onBlur;
  117240. private _onCanvasPointerOut;
  117241. private _onCanvasBlur;
  117242. private _onCanvasFocus;
  117243. private _onFullscreenChange;
  117244. private _onPointerLockChange;
  117245. /**
  117246. * Gets the HTML element used to attach event listeners
  117247. * @returns a HTML element
  117248. */
  117249. getInputElement(): Nullable<HTMLElement>;
  117250. /**
  117251. * Creates a new engine
  117252. * @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
  117253. * @param antialias defines enable antialiasing (default: false)
  117254. * @param options defines further options to be sent to the getContext() function
  117255. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  117256. */
  117257. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  117258. /**
  117259. * Gets current aspect ratio
  117260. * @param viewportOwner defines the camera to use to get the aspect ratio
  117261. * @param useScreen defines if screen size must be used (or the current render target if any)
  117262. * @returns a number defining the aspect ratio
  117263. */
  117264. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  117265. /**
  117266. * Gets current screen aspect ratio
  117267. * @returns a number defining the aspect ratio
  117268. */
  117269. getScreenAspectRatio(): number;
  117270. /**
  117271. * Gets the client rect of the HTML canvas attached with the current webGL context
  117272. * @returns a client rectanglee
  117273. */
  117274. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  117275. /**
  117276. * Gets the client rect of the HTML element used for events
  117277. * @returns a client rectanglee
  117278. */
  117279. getInputElementClientRect(): Nullable<ClientRect>;
  117280. /**
  117281. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  117282. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117283. * @returns true if engine is in deterministic lock step mode
  117284. */
  117285. isDeterministicLockStep(): boolean;
  117286. /**
  117287. * Gets the max steps when engine is running in deterministic lock step
  117288. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117289. * @returns the max steps
  117290. */
  117291. getLockstepMaxSteps(): number;
  117292. /**
  117293. * Returns the time in ms between steps when using deterministic lock step.
  117294. * @returns time step in (ms)
  117295. */
  117296. getTimeStep(): number;
  117297. /**
  117298. * Force the mipmap generation for the given render target texture
  117299. * @param texture defines the render target texture to use
  117300. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  117301. */
  117302. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  117303. /** States */
  117304. /**
  117305. * Set various states to the webGL context
  117306. * @param culling defines backface culling state
  117307. * @param zOffset defines the value to apply to zOffset (0 by default)
  117308. * @param force defines if states must be applied even if cache is up to date
  117309. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  117310. */
  117311. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  117312. /**
  117313. * Set the z offset to apply to current rendering
  117314. * @param value defines the offset to apply
  117315. */
  117316. setZOffset(value: number): void;
  117317. /**
  117318. * Gets the current value of the zOffset
  117319. * @returns the current zOffset state
  117320. */
  117321. getZOffset(): number;
  117322. /**
  117323. * Enable or disable depth buffering
  117324. * @param enable defines the state to set
  117325. */
  117326. setDepthBuffer(enable: boolean): void;
  117327. /**
  117328. * Gets a boolean indicating if depth writing is enabled
  117329. * @returns the current depth writing state
  117330. */
  117331. getDepthWrite(): boolean;
  117332. /**
  117333. * Enable or disable depth writing
  117334. * @param enable defines the state to set
  117335. */
  117336. setDepthWrite(enable: boolean): void;
  117337. /**
  117338. * Gets a boolean indicating if stencil buffer is enabled
  117339. * @returns the current stencil buffer state
  117340. */
  117341. getStencilBuffer(): boolean;
  117342. /**
  117343. * Enable or disable the stencil buffer
  117344. * @param enable defines if the stencil buffer must be enabled or disabled
  117345. */
  117346. setStencilBuffer(enable: boolean): void;
  117347. /**
  117348. * Gets the current stencil mask
  117349. * @returns a number defining the new stencil mask to use
  117350. */
  117351. getStencilMask(): number;
  117352. /**
  117353. * Sets the current stencil mask
  117354. * @param mask defines the new stencil mask to use
  117355. */
  117356. setStencilMask(mask: number): void;
  117357. /**
  117358. * Gets the current stencil function
  117359. * @returns a number defining the stencil function to use
  117360. */
  117361. getStencilFunction(): number;
  117362. /**
  117363. * Gets the current stencil reference value
  117364. * @returns a number defining the stencil reference value to use
  117365. */
  117366. getStencilFunctionReference(): number;
  117367. /**
  117368. * Gets the current stencil mask
  117369. * @returns a number defining the stencil mask to use
  117370. */
  117371. getStencilFunctionMask(): number;
  117372. /**
  117373. * Sets the current stencil function
  117374. * @param stencilFunc defines the new stencil function to use
  117375. */
  117376. setStencilFunction(stencilFunc: number): void;
  117377. /**
  117378. * Sets the current stencil reference
  117379. * @param reference defines the new stencil reference to use
  117380. */
  117381. setStencilFunctionReference(reference: number): void;
  117382. /**
  117383. * Sets the current stencil mask
  117384. * @param mask defines the new stencil mask to use
  117385. */
  117386. setStencilFunctionMask(mask: number): void;
  117387. /**
  117388. * Gets the current stencil operation when stencil fails
  117389. * @returns a number defining stencil operation to use when stencil fails
  117390. */
  117391. getStencilOperationFail(): number;
  117392. /**
  117393. * Gets the current stencil operation when depth fails
  117394. * @returns a number defining stencil operation to use when depth fails
  117395. */
  117396. getStencilOperationDepthFail(): number;
  117397. /**
  117398. * Gets the current stencil operation when stencil passes
  117399. * @returns a number defining stencil operation to use when stencil passes
  117400. */
  117401. getStencilOperationPass(): number;
  117402. /**
  117403. * Sets the stencil operation to use when stencil fails
  117404. * @param operation defines the stencil operation to use when stencil fails
  117405. */
  117406. setStencilOperationFail(operation: number): void;
  117407. /**
  117408. * Sets the stencil operation to use when depth fails
  117409. * @param operation defines the stencil operation to use when depth fails
  117410. */
  117411. setStencilOperationDepthFail(operation: number): void;
  117412. /**
  117413. * Sets the stencil operation to use when stencil passes
  117414. * @param operation defines the stencil operation to use when stencil passes
  117415. */
  117416. setStencilOperationPass(operation: number): void;
  117417. /**
  117418. * Sets a boolean indicating if the dithering state is enabled or disabled
  117419. * @param value defines the dithering state
  117420. */
  117421. setDitheringState(value: boolean): void;
  117422. /**
  117423. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  117424. * @param value defines the rasterizer state
  117425. */
  117426. setRasterizerState(value: boolean): void;
  117427. /**
  117428. * Gets the current depth function
  117429. * @returns a number defining the depth function
  117430. */
  117431. getDepthFunction(): Nullable<number>;
  117432. /**
  117433. * Sets the current depth function
  117434. * @param depthFunc defines the function to use
  117435. */
  117436. setDepthFunction(depthFunc: number): void;
  117437. /**
  117438. * Sets the current depth function to GREATER
  117439. */
  117440. setDepthFunctionToGreater(): void;
  117441. /**
  117442. * Sets the current depth function to GEQUAL
  117443. */
  117444. setDepthFunctionToGreaterOrEqual(): void;
  117445. /**
  117446. * Sets the current depth function to LESS
  117447. */
  117448. setDepthFunctionToLess(): void;
  117449. /**
  117450. * Sets the current depth function to LEQUAL
  117451. */
  117452. setDepthFunctionToLessOrEqual(): void;
  117453. private _cachedStencilBuffer;
  117454. private _cachedStencilFunction;
  117455. private _cachedStencilMask;
  117456. private _cachedStencilOperationPass;
  117457. private _cachedStencilOperationFail;
  117458. private _cachedStencilOperationDepthFail;
  117459. private _cachedStencilReference;
  117460. /**
  117461. * Caches the the state of the stencil buffer
  117462. */
  117463. cacheStencilState(): void;
  117464. /**
  117465. * Restores the state of the stencil buffer
  117466. */
  117467. restoreStencilState(): void;
  117468. /**
  117469. * Directly set the WebGL Viewport
  117470. * @param x defines the x coordinate of the viewport (in screen space)
  117471. * @param y defines the y coordinate of the viewport (in screen space)
  117472. * @param width defines the width of the viewport (in screen space)
  117473. * @param height defines the height of the viewport (in screen space)
  117474. * @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
  117475. */
  117476. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  117477. /**
  117478. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  117479. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  117480. * @param y defines the y-coordinate of the corner of the clear rectangle
  117481. * @param width defines the width of the clear rectangle
  117482. * @param height defines the height of the clear rectangle
  117483. * @param clearColor defines the clear color
  117484. */
  117485. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  117486. /**
  117487. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  117488. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  117489. * @param y defines the y-coordinate of the corner of the clear rectangle
  117490. * @param width defines the width of the clear rectangle
  117491. * @param height defines the height of the clear rectangle
  117492. */
  117493. enableScissor(x: number, y: number, width: number, height: number): void;
  117494. /**
  117495. * Disable previously set scissor test rectangle
  117496. */
  117497. disableScissor(): void;
  117498. protected _reportDrawCall(): void;
  117499. /**
  117500. * Initializes a webVR display and starts listening to display change events
  117501. * The onVRDisplayChangedObservable will be notified upon these changes
  117502. * @returns The onVRDisplayChangedObservable
  117503. */
  117504. initWebVR(): Observable<IDisplayChangedEventArgs>;
  117505. /** @hidden */
  117506. _prepareVRComponent(): void;
  117507. /** @hidden */
  117508. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  117509. /** @hidden */
  117510. _submitVRFrame(): void;
  117511. /**
  117512. * Call this function to leave webVR mode
  117513. * Will do nothing if webVR is not supported or if there is no webVR device
  117514. * @see https://doc.babylonjs.com/how_to/webvr_camera
  117515. */
  117516. disableVR(): void;
  117517. /**
  117518. * Gets a boolean indicating that the system is in VR mode and is presenting
  117519. * @returns true if VR mode is engaged
  117520. */
  117521. isVRPresenting(): boolean;
  117522. /** @hidden */
  117523. _requestVRFrame(): void;
  117524. /** @hidden */
  117525. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117526. /**
  117527. * Gets the source code of the vertex shader associated with a specific webGL program
  117528. * @param program defines the program to use
  117529. * @returns a string containing the source code of the vertex shader associated with the program
  117530. */
  117531. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  117532. /**
  117533. * Gets the source code of the fragment shader associated with a specific webGL program
  117534. * @param program defines the program to use
  117535. * @returns a string containing the source code of the fragment shader associated with the program
  117536. */
  117537. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  117538. /**
  117539. * Sets a depth stencil texture from a render target to the according uniform.
  117540. * @param channel The texture channel
  117541. * @param uniform The uniform to set
  117542. * @param texture The render target texture containing the depth stencil texture to apply
  117543. */
  117544. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  117545. /**
  117546. * Sets a texture to the webGL context from a postprocess
  117547. * @param channel defines the channel to use
  117548. * @param postProcess defines the source postprocess
  117549. */
  117550. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  117551. /**
  117552. * Binds the output of the passed in post process to the texture channel specified
  117553. * @param channel The channel the texture should be bound to
  117554. * @param postProcess The post process which's output should be bound
  117555. */
  117556. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  117557. protected _rebuildBuffers(): void;
  117558. /** @hidden */
  117559. _renderFrame(): void;
  117560. _renderLoop(): void;
  117561. /** @hidden */
  117562. _renderViews(): boolean;
  117563. /**
  117564. * Toggle full screen mode
  117565. * @param requestPointerLock defines if a pointer lock should be requested from the user
  117566. */
  117567. switchFullscreen(requestPointerLock: boolean): void;
  117568. /**
  117569. * Enters full screen mode
  117570. * @param requestPointerLock defines if a pointer lock should be requested from the user
  117571. */
  117572. enterFullscreen(requestPointerLock: boolean): void;
  117573. /**
  117574. * Exits full screen mode
  117575. */
  117576. exitFullscreen(): void;
  117577. /**
  117578. * Enters Pointerlock mode
  117579. */
  117580. enterPointerlock(): void;
  117581. /**
  117582. * Exits Pointerlock mode
  117583. */
  117584. exitPointerlock(): void;
  117585. /**
  117586. * Begin a new frame
  117587. */
  117588. beginFrame(): void;
  117589. /**
  117590. * Enf the current frame
  117591. */
  117592. endFrame(): void;
  117593. resize(): void;
  117594. /**
  117595. * Force a specific size of the canvas
  117596. * @param width defines the new canvas' width
  117597. * @param height defines the new canvas' height
  117598. * @returns true if the size was changed
  117599. */
  117600. setSize(width: number, height: number): boolean;
  117601. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  117602. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  117603. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  117604. _releaseTexture(texture: InternalTexture): void;
  117605. /**
  117606. * @hidden
  117607. * Rescales a texture
  117608. * @param source input texutre
  117609. * @param destination destination texture
  117610. * @param scene scene to use to render the resize
  117611. * @param internalFormat format to use when resizing
  117612. * @param onComplete callback to be called when resize has completed
  117613. */
  117614. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  117615. /**
  117616. * Gets the current framerate
  117617. * @returns a number representing the framerate
  117618. */
  117619. getFps(): number;
  117620. /**
  117621. * Gets the time spent between current and previous frame
  117622. * @returns a number representing the delta time in ms
  117623. */
  117624. getDeltaTime(): number;
  117625. private _measureFps;
  117626. /** @hidden */
  117627. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  117628. /**
  117629. * Updates the sample count of a render target texture
  117630. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  117631. * @param texture defines the texture to update
  117632. * @param samples defines the sample count to set
  117633. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  117634. */
  117635. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  117636. /**
  117637. * Updates a depth texture Comparison Mode and Function.
  117638. * If the comparison Function is equal to 0, the mode will be set to none.
  117639. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  117640. * @param texture The texture to set the comparison function for
  117641. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  117642. */
  117643. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  117644. /**
  117645. * Creates a webGL buffer to use with instanciation
  117646. * @param capacity defines the size of the buffer
  117647. * @returns the webGL buffer
  117648. */
  117649. createInstancesBuffer(capacity: number): DataBuffer;
  117650. /**
  117651. * Delete a webGL buffer used with instanciation
  117652. * @param buffer defines the webGL buffer to delete
  117653. */
  117654. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  117655. private _clientWaitAsync;
  117656. /** @hidden */
  117657. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  117658. dispose(): void;
  117659. private _disableTouchAction;
  117660. /**
  117661. * Display the loading screen
  117662. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117663. */
  117664. displayLoadingUI(): void;
  117665. /**
  117666. * Hide the loading screen
  117667. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117668. */
  117669. hideLoadingUI(): void;
  117670. /**
  117671. * Gets the current loading screen object
  117672. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117673. */
  117674. get loadingScreen(): ILoadingScreen;
  117675. /**
  117676. * Sets the current loading screen object
  117677. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117678. */
  117679. set loadingScreen(loadingScreen: ILoadingScreen);
  117680. /**
  117681. * Sets the current loading screen text
  117682. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117683. */
  117684. set loadingUIText(text: string);
  117685. /**
  117686. * Sets the current loading screen background color
  117687. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117688. */
  117689. set loadingUIBackgroundColor(color: string);
  117690. /** Pointerlock and fullscreen */
  117691. /**
  117692. * Ask the browser to promote the current element to pointerlock mode
  117693. * @param element defines the DOM element to promote
  117694. */
  117695. static _RequestPointerlock(element: HTMLElement): void;
  117696. /**
  117697. * Asks the browser to exit pointerlock mode
  117698. */
  117699. static _ExitPointerlock(): void;
  117700. /**
  117701. * Ask the browser to promote the current element to fullscreen rendering mode
  117702. * @param element defines the DOM element to promote
  117703. */
  117704. static _RequestFullscreen(element: HTMLElement): void;
  117705. /**
  117706. * Asks the browser to exit fullscreen mode
  117707. */
  117708. static _ExitFullscreen(): void;
  117709. }
  117710. }
  117711. declare module BABYLON {
  117712. /**
  117713. * The engine store class is responsible to hold all the instances of Engine and Scene created
  117714. * during the life time of the application.
  117715. */
  117716. export class EngineStore {
  117717. /** Gets the list of created engines */
  117718. static Instances: Engine[];
  117719. /** @hidden */
  117720. static _LastCreatedScene: Nullable<Scene>;
  117721. /**
  117722. * Gets the latest created engine
  117723. */
  117724. static get LastCreatedEngine(): Nullable<Engine>;
  117725. /**
  117726. * Gets the latest created scene
  117727. */
  117728. static get LastCreatedScene(): Nullable<Scene>;
  117729. /**
  117730. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  117731. * @ignorenaming
  117732. */
  117733. static UseFallbackTexture: boolean;
  117734. /**
  117735. * Texture content used if a texture cannot loaded
  117736. * @ignorenaming
  117737. */
  117738. static FallbackTexture: string;
  117739. }
  117740. }
  117741. declare module BABYLON {
  117742. /**
  117743. * Helper class that provides a small promise polyfill
  117744. */
  117745. export class PromisePolyfill {
  117746. /**
  117747. * Static function used to check if the polyfill is required
  117748. * If this is the case then the function will inject the polyfill to window.Promise
  117749. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  117750. */
  117751. static Apply(force?: boolean): void;
  117752. }
  117753. }
  117754. declare module BABYLON {
  117755. /**
  117756. * Interface for screenshot methods with describe argument called `size` as object with options
  117757. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  117758. */
  117759. export interface IScreenshotSize {
  117760. /**
  117761. * number in pixels for canvas height
  117762. */
  117763. height?: number;
  117764. /**
  117765. * multiplier allowing render at a higher or lower resolution
  117766. * If value is defined then height and width will be ignored and taken from camera
  117767. */
  117768. precision?: number;
  117769. /**
  117770. * number in pixels for canvas width
  117771. */
  117772. width?: number;
  117773. }
  117774. }
  117775. declare module BABYLON {
  117776. interface IColor4Like {
  117777. r: float;
  117778. g: float;
  117779. b: float;
  117780. a: float;
  117781. }
  117782. /**
  117783. * Class containing a set of static utilities functions
  117784. */
  117785. export class Tools {
  117786. /**
  117787. * Gets or sets the base URL to use to load assets
  117788. */
  117789. static get BaseUrl(): string;
  117790. static set BaseUrl(value: string);
  117791. /**
  117792. * Enable/Disable Custom HTTP Request Headers globally.
  117793. * default = false
  117794. * @see CustomRequestHeaders
  117795. */
  117796. static UseCustomRequestHeaders: boolean;
  117797. /**
  117798. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  117799. * i.e. when loading files, where the server/service expects an Authorization header
  117800. */
  117801. static CustomRequestHeaders: {
  117802. [key: string]: string;
  117803. };
  117804. /**
  117805. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  117806. */
  117807. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  117808. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  117809. /**
  117810. * Default behaviour for cors in the application.
  117811. * It can be a string if the expected behavior is identical in the entire app.
  117812. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  117813. */
  117814. static get CorsBehavior(): string | ((url: string | string[]) => string);
  117815. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  117816. /**
  117817. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  117818. * @ignorenaming
  117819. */
  117820. static get UseFallbackTexture(): boolean;
  117821. static set UseFallbackTexture(value: boolean);
  117822. /**
  117823. * Use this object to register external classes like custom textures or material
  117824. * to allow the laoders to instantiate them
  117825. */
  117826. static get RegisteredExternalClasses(): {
  117827. [key: string]: Object;
  117828. };
  117829. static set RegisteredExternalClasses(classes: {
  117830. [key: string]: Object;
  117831. });
  117832. /**
  117833. * Texture content used if a texture cannot loaded
  117834. * @ignorenaming
  117835. */
  117836. static get fallbackTexture(): string;
  117837. static set fallbackTexture(value: string);
  117838. /**
  117839. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  117840. * @param u defines the coordinate on X axis
  117841. * @param v defines the coordinate on Y axis
  117842. * @param width defines the width of the source data
  117843. * @param height defines the height of the source data
  117844. * @param pixels defines the source byte array
  117845. * @param color defines the output color
  117846. */
  117847. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  117848. /**
  117849. * Interpolates between a and b via alpha
  117850. * @param a The lower value (returned when alpha = 0)
  117851. * @param b The upper value (returned when alpha = 1)
  117852. * @param alpha The interpolation-factor
  117853. * @return The mixed value
  117854. */
  117855. static Mix(a: number, b: number, alpha: number): number;
  117856. /**
  117857. * Tries to instantiate a new object from a given class name
  117858. * @param className defines the class name to instantiate
  117859. * @returns the new object or null if the system was not able to do the instantiation
  117860. */
  117861. static Instantiate(className: string): any;
  117862. /**
  117863. * Provides a slice function that will work even on IE
  117864. * @param data defines the array to slice
  117865. * @param start defines the start of the data (optional)
  117866. * @param end defines the end of the data (optional)
  117867. * @returns the new sliced array
  117868. */
  117869. static Slice<T>(data: T, start?: number, end?: number): T;
  117870. /**
  117871. * Polyfill for setImmediate
  117872. * @param action defines the action to execute after the current execution block
  117873. */
  117874. static SetImmediate(action: () => void): void;
  117875. /**
  117876. * Function indicating if a number is an exponent of 2
  117877. * @param value defines the value to test
  117878. * @returns true if the value is an exponent of 2
  117879. */
  117880. static IsExponentOfTwo(value: number): boolean;
  117881. private static _tmpFloatArray;
  117882. /**
  117883. * Returns the nearest 32-bit single precision float representation of a Number
  117884. * @param value A Number. If the parameter is of a different type, it will get converted
  117885. * to a number or to NaN if it cannot be converted
  117886. * @returns number
  117887. */
  117888. static FloatRound(value: number): number;
  117889. /**
  117890. * Extracts the filename from a path
  117891. * @param path defines the path to use
  117892. * @returns the filename
  117893. */
  117894. static GetFilename(path: string): string;
  117895. /**
  117896. * Extracts the "folder" part of a path (everything before the filename).
  117897. * @param uri The URI to extract the info from
  117898. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  117899. * @returns The "folder" part of the path
  117900. */
  117901. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  117902. /**
  117903. * Extracts text content from a DOM element hierarchy
  117904. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  117905. */
  117906. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  117907. /**
  117908. * Convert an angle in radians to degrees
  117909. * @param angle defines the angle to convert
  117910. * @returns the angle in degrees
  117911. */
  117912. static ToDegrees(angle: number): number;
  117913. /**
  117914. * Convert an angle in degrees to radians
  117915. * @param angle defines the angle to convert
  117916. * @returns the angle in radians
  117917. */
  117918. static ToRadians(angle: number): number;
  117919. /**
  117920. * Returns an array if obj is not an array
  117921. * @param obj defines the object to evaluate as an array
  117922. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  117923. * @returns either obj directly if obj is an array or a new array containing obj
  117924. */
  117925. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  117926. /**
  117927. * Gets the pointer prefix to use
  117928. * @param engine defines the engine we are finding the prefix for
  117929. * @returns "pointer" if touch is enabled. Else returns "mouse"
  117930. */
  117931. static GetPointerPrefix(engine: Engine): string;
  117932. /**
  117933. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  117934. * @param url define the url we are trying
  117935. * @param element define the dom element where to configure the cors policy
  117936. */
  117937. static SetCorsBehavior(url: string | string[], element: {
  117938. crossOrigin: string | null;
  117939. }): void;
  117940. /**
  117941. * Removes unwanted characters from an url
  117942. * @param url defines the url to clean
  117943. * @returns the cleaned url
  117944. */
  117945. static CleanUrl(url: string): string;
  117946. /**
  117947. * Gets or sets a function used to pre-process url before using them to load assets
  117948. */
  117949. static get PreprocessUrl(): (url: string) => string;
  117950. static set PreprocessUrl(processor: (url: string) => string);
  117951. /**
  117952. * Loads an image as an HTMLImageElement.
  117953. * @param input url string, ArrayBuffer, or Blob to load
  117954. * @param onLoad callback called when the image successfully loads
  117955. * @param onError callback called when the image fails to load
  117956. * @param offlineProvider offline provider for caching
  117957. * @param mimeType optional mime type
  117958. * @returns the HTMLImageElement of the loaded image
  117959. */
  117960. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  117961. /**
  117962. * Loads a file from a url
  117963. * @param url url string, ArrayBuffer, or Blob to load
  117964. * @param onSuccess callback called when the file successfully loads
  117965. * @param onProgress callback called while file is loading (if the server supports this mode)
  117966. * @param offlineProvider defines the offline provider for caching
  117967. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117968. * @param onError callback called when the file fails to load
  117969. * @returns a file request object
  117970. */
  117971. 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;
  117972. /**
  117973. * Loads a file from a url
  117974. * @param url the file url to load
  117975. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117976. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  117977. */
  117978. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  117979. /**
  117980. * Load a script (identified by an url). When the url returns, the
  117981. * content of this file is added into a new script element, attached to the DOM (body element)
  117982. * @param scriptUrl defines the url of the script to laod
  117983. * @param onSuccess defines the callback called when the script is loaded
  117984. * @param onError defines the callback to call if an error occurs
  117985. * @param scriptId defines the id of the script element
  117986. */
  117987. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  117988. /**
  117989. * Load an asynchronous script (identified by an url). When the url returns, the
  117990. * content of this file is added into a new script element, attached to the DOM (body element)
  117991. * @param scriptUrl defines the url of the script to laod
  117992. * @param scriptId defines the id of the script element
  117993. * @returns a promise request object
  117994. */
  117995. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  117996. /**
  117997. * Loads a file from a blob
  117998. * @param fileToLoad defines the blob to use
  117999. * @param callback defines the callback to call when data is loaded
  118000. * @param progressCallback defines the callback to call during loading process
  118001. * @returns a file request object
  118002. */
  118003. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  118004. /**
  118005. * Reads a file from a File object
  118006. * @param file defines the file to load
  118007. * @param onSuccess defines the callback to call when data is loaded
  118008. * @param onProgress defines the callback to call during loading process
  118009. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  118010. * @param onError defines the callback to call when an error occurs
  118011. * @returns a file request object
  118012. */
  118013. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118014. /**
  118015. * Creates a data url from a given string content
  118016. * @param content defines the content to convert
  118017. * @returns the new data url link
  118018. */
  118019. static FileAsURL(content: string): string;
  118020. /**
  118021. * Format the given number to a specific decimal format
  118022. * @param value defines the number to format
  118023. * @param decimals defines the number of decimals to use
  118024. * @returns the formatted string
  118025. */
  118026. static Format(value: number, decimals?: number): string;
  118027. /**
  118028. * Tries to copy an object by duplicating every property
  118029. * @param source defines the source object
  118030. * @param destination defines the target object
  118031. * @param doNotCopyList defines a list of properties to avoid
  118032. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  118033. */
  118034. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  118035. /**
  118036. * Gets a boolean indicating if the given object has no own property
  118037. * @param obj defines the object to test
  118038. * @returns true if object has no own property
  118039. */
  118040. static IsEmpty(obj: any): boolean;
  118041. /**
  118042. * Function used to register events at window level
  118043. * @param windowElement defines the Window object to use
  118044. * @param events defines the events to register
  118045. */
  118046. static RegisterTopRootEvents(windowElement: Window, events: {
  118047. name: string;
  118048. handler: Nullable<(e: FocusEvent) => any>;
  118049. }[]): void;
  118050. /**
  118051. * Function used to unregister events from window level
  118052. * @param windowElement defines the Window object to use
  118053. * @param events defines the events to unregister
  118054. */
  118055. static UnregisterTopRootEvents(windowElement: Window, events: {
  118056. name: string;
  118057. handler: Nullable<(e: FocusEvent) => any>;
  118058. }[]): void;
  118059. /**
  118060. * @ignore
  118061. */
  118062. static _ScreenshotCanvas: HTMLCanvasElement;
  118063. /**
  118064. * Dumps the current bound framebuffer
  118065. * @param width defines the rendering width
  118066. * @param height defines the rendering height
  118067. * @param engine defines the hosting engine
  118068. * @param successCallback defines the callback triggered once the data are available
  118069. * @param mimeType defines the mime type of the result
  118070. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  118071. */
  118072. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118073. /**
  118074. * Converts the canvas data to blob.
  118075. * This acts as a polyfill for browsers not supporting the to blob function.
  118076. * @param canvas Defines the canvas to extract the data from
  118077. * @param successCallback Defines the callback triggered once the data are available
  118078. * @param mimeType Defines the mime type of the result
  118079. */
  118080. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  118081. /**
  118082. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  118083. * @param successCallback defines the callback triggered once the data are available
  118084. * @param mimeType defines the mime type of the result
  118085. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  118086. */
  118087. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118088. /**
  118089. * Downloads a blob in the browser
  118090. * @param blob defines the blob to download
  118091. * @param fileName defines the name of the downloaded file
  118092. */
  118093. static Download(blob: Blob, fileName: string): void;
  118094. /**
  118095. * Captures a screenshot of the current rendering
  118096. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118097. * @param engine defines the rendering engine
  118098. * @param camera defines the source camera
  118099. * @param size This parameter can be set to a single number or to an object with the
  118100. * following (optional) properties: precision, width, height. If a single number is passed,
  118101. * it will be used for both width and height. If an object is passed, the screenshot size
  118102. * will be derived from the parameters. The precision property is a multiplier allowing
  118103. * rendering at a higher or lower resolution
  118104. * @param successCallback defines the callback receives a single parameter which contains the
  118105. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118106. * src parameter of an <img> to display it
  118107. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118108. * Check your browser for supported MIME types
  118109. */
  118110. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  118111. /**
  118112. * Captures a screenshot of the current rendering
  118113. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118114. * @param engine defines the rendering engine
  118115. * @param camera defines the source camera
  118116. * @param size This parameter can be set to a single number or to an object with the
  118117. * following (optional) properties: precision, width, height. If a single number is passed,
  118118. * it will be used for both width and height. If an object is passed, the screenshot size
  118119. * will be derived from the parameters. The precision property is a multiplier allowing
  118120. * rendering at a higher or lower resolution
  118121. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118122. * Check your browser for supported MIME types
  118123. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118124. * to the src parameter of an <img> to display it
  118125. */
  118126. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  118127. /**
  118128. * Generates an image screenshot from the specified camera.
  118129. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118130. * @param engine The engine to use for rendering
  118131. * @param camera The camera to use for rendering
  118132. * @param size This parameter can be set to a single number or to an object with the
  118133. * following (optional) properties: precision, width, height. If a single number is passed,
  118134. * it will be used for both width and height. If an object is passed, the screenshot size
  118135. * will be derived from the parameters. The precision property is a multiplier allowing
  118136. * rendering at a higher or lower resolution
  118137. * @param successCallback The callback receives a single parameter which contains the
  118138. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118139. * src parameter of an <img> to display it
  118140. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118141. * Check your browser for supported MIME types
  118142. * @param samples Texture samples (default: 1)
  118143. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118144. * @param fileName A name for for the downloaded file.
  118145. */
  118146. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  118147. /**
  118148. * Generates an image screenshot from the specified camera.
  118149. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118150. * @param engine The engine to use for rendering
  118151. * @param camera The camera to use for rendering
  118152. * @param size This parameter can be set to a single number or to an object with the
  118153. * following (optional) properties: precision, width, height. If a single number is passed,
  118154. * it will be used for both width and height. If an object is passed, the screenshot size
  118155. * will be derived from the parameters. The precision property is a multiplier allowing
  118156. * rendering at a higher or lower resolution
  118157. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118158. * Check your browser for supported MIME types
  118159. * @param samples Texture samples (default: 1)
  118160. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118161. * @param fileName A name for for the downloaded file.
  118162. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118163. * to the src parameter of an <img> to display it
  118164. */
  118165. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  118166. /**
  118167. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  118168. * Be aware Math.random() could cause collisions, but:
  118169. * "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"
  118170. * @returns a pseudo random id
  118171. */
  118172. static RandomId(): string;
  118173. /**
  118174. * Test if the given uri is a base64 string
  118175. * @param uri The uri to test
  118176. * @return True if the uri is a base64 string or false otherwise
  118177. */
  118178. static IsBase64(uri: string): boolean;
  118179. /**
  118180. * Decode the given base64 uri.
  118181. * @param uri The uri to decode
  118182. * @return The decoded base64 data.
  118183. */
  118184. static DecodeBase64(uri: string): ArrayBuffer;
  118185. /**
  118186. * Gets the absolute url.
  118187. * @param url the input url
  118188. * @return the absolute url
  118189. */
  118190. static GetAbsoluteUrl(url: string): string;
  118191. /**
  118192. * No log
  118193. */
  118194. static readonly NoneLogLevel: number;
  118195. /**
  118196. * Only message logs
  118197. */
  118198. static readonly MessageLogLevel: number;
  118199. /**
  118200. * Only warning logs
  118201. */
  118202. static readonly WarningLogLevel: number;
  118203. /**
  118204. * Only error logs
  118205. */
  118206. static readonly ErrorLogLevel: number;
  118207. /**
  118208. * All logs
  118209. */
  118210. static readonly AllLogLevel: number;
  118211. /**
  118212. * Gets a value indicating the number of loading errors
  118213. * @ignorenaming
  118214. */
  118215. static get errorsCount(): number;
  118216. /**
  118217. * Callback called when a new log is added
  118218. */
  118219. static OnNewCacheEntry: (entry: string) => void;
  118220. /**
  118221. * Log a message to the console
  118222. * @param message defines the message to log
  118223. */
  118224. static Log(message: string): void;
  118225. /**
  118226. * Write a warning message to the console
  118227. * @param message defines the message to log
  118228. */
  118229. static Warn(message: string): void;
  118230. /**
  118231. * Write an error message to the console
  118232. * @param message defines the message to log
  118233. */
  118234. static Error(message: string): void;
  118235. /**
  118236. * Gets current log cache (list of logs)
  118237. */
  118238. static get LogCache(): string;
  118239. /**
  118240. * Clears the log cache
  118241. */
  118242. static ClearLogCache(): void;
  118243. /**
  118244. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  118245. */
  118246. static set LogLevels(level: number);
  118247. /**
  118248. * Checks if the window object exists
  118249. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  118250. */
  118251. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  118252. /**
  118253. * No performance log
  118254. */
  118255. static readonly PerformanceNoneLogLevel: number;
  118256. /**
  118257. * Use user marks to log performance
  118258. */
  118259. static readonly PerformanceUserMarkLogLevel: number;
  118260. /**
  118261. * Log performance to the console
  118262. */
  118263. static readonly PerformanceConsoleLogLevel: number;
  118264. private static _performance;
  118265. /**
  118266. * Sets the current performance log level
  118267. */
  118268. static set PerformanceLogLevel(level: number);
  118269. private static _StartPerformanceCounterDisabled;
  118270. private static _EndPerformanceCounterDisabled;
  118271. private static _StartUserMark;
  118272. private static _EndUserMark;
  118273. private static _StartPerformanceConsole;
  118274. private static _EndPerformanceConsole;
  118275. /**
  118276. * Starts a performance counter
  118277. */
  118278. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  118279. /**
  118280. * Ends a specific performance coutner
  118281. */
  118282. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  118283. /**
  118284. * Gets either window.performance.now() if supported or Date.now() else
  118285. */
  118286. static get Now(): number;
  118287. /**
  118288. * This method will return the name of the class used to create the instance of the given object.
  118289. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  118290. * @param object the object to get the class name from
  118291. * @param isType defines if the object is actually a type
  118292. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  118293. */
  118294. static GetClassName(object: any, isType?: boolean): string;
  118295. /**
  118296. * Gets the first element of an array satisfying a given predicate
  118297. * @param array defines the array to browse
  118298. * @param predicate defines the predicate to use
  118299. * @returns null if not found or the element
  118300. */
  118301. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  118302. /**
  118303. * This method will return the name of the full name of the class, including its owning module (if any).
  118304. * 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).
  118305. * @param object the object to get the class name from
  118306. * @param isType defines if the object is actually a type
  118307. * @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.
  118308. * @ignorenaming
  118309. */
  118310. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  118311. /**
  118312. * Returns a promise that resolves after the given amount of time.
  118313. * @param delay Number of milliseconds to delay
  118314. * @returns Promise that resolves after the given amount of time
  118315. */
  118316. static DelayAsync(delay: number): Promise<void>;
  118317. /**
  118318. * Utility function to detect if the current user agent is Safari
  118319. * @returns whether or not the current user agent is safari
  118320. */
  118321. static IsSafari(): boolean;
  118322. }
  118323. /**
  118324. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  118325. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  118326. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  118327. * @param name The name of the class, case should be preserved
  118328. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  118329. */
  118330. export function className(name: string, module?: string): (target: Object) => void;
  118331. /**
  118332. * An implementation of a loop for asynchronous functions.
  118333. */
  118334. export class AsyncLoop {
  118335. /**
  118336. * Defines the number of iterations for the loop
  118337. */
  118338. iterations: number;
  118339. /**
  118340. * Defines the current index of the loop.
  118341. */
  118342. index: number;
  118343. private _done;
  118344. private _fn;
  118345. private _successCallback;
  118346. /**
  118347. * Constructor.
  118348. * @param iterations the number of iterations.
  118349. * @param func the function to run each iteration
  118350. * @param successCallback the callback that will be called upon succesful execution
  118351. * @param offset starting offset.
  118352. */
  118353. constructor(
  118354. /**
  118355. * Defines the number of iterations for the loop
  118356. */
  118357. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  118358. /**
  118359. * Execute the next iteration. Must be called after the last iteration was finished.
  118360. */
  118361. executeNext(): void;
  118362. /**
  118363. * Break the loop and run the success callback.
  118364. */
  118365. breakLoop(): void;
  118366. /**
  118367. * Create and run an async loop.
  118368. * @param iterations the number of iterations.
  118369. * @param fn the function to run each iteration
  118370. * @param successCallback the callback that will be called upon succesful execution
  118371. * @param offset starting offset.
  118372. * @returns the created async loop object
  118373. */
  118374. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  118375. /**
  118376. * A for-loop that will run a given number of iterations synchronous and the rest async.
  118377. * @param iterations total number of iterations
  118378. * @param syncedIterations number of synchronous iterations in each async iteration.
  118379. * @param fn the function to call each iteration.
  118380. * @param callback a success call back that will be called when iterating stops.
  118381. * @param breakFunction a break condition (optional)
  118382. * @param timeout timeout settings for the setTimeout function. default - 0.
  118383. * @returns the created async loop object
  118384. */
  118385. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  118386. }
  118387. }
  118388. declare module BABYLON {
  118389. /**
  118390. * This class implement a typical dictionary using a string as key and the generic type T as value.
  118391. * The underlying implementation relies on an associative array to ensure the best performances.
  118392. * The value can be anything including 'null' but except 'undefined'
  118393. */
  118394. export class StringDictionary<T> {
  118395. /**
  118396. * This will clear this dictionary and copy the content from the 'source' one.
  118397. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  118398. * @param source the dictionary to take the content from and copy to this dictionary
  118399. */
  118400. copyFrom(source: StringDictionary<T>): void;
  118401. /**
  118402. * Get a value based from its key
  118403. * @param key the given key to get the matching value from
  118404. * @return the value if found, otherwise undefined is returned
  118405. */
  118406. get(key: string): T | undefined;
  118407. /**
  118408. * Get a value from its key or add it if it doesn't exist.
  118409. * This method will ensure you that a given key/data will be present in the dictionary.
  118410. * @param key the given key to get the matching value from
  118411. * @param factory the factory that will create the value if the key is not present in the dictionary.
  118412. * The factory will only be invoked if there's no data for the given key.
  118413. * @return the value corresponding to the key.
  118414. */
  118415. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  118416. /**
  118417. * Get a value from its key if present in the dictionary otherwise add it
  118418. * @param key the key to get the value from
  118419. * @param val if there's no such key/value pair in the dictionary add it with this value
  118420. * @return the value corresponding to the key
  118421. */
  118422. getOrAdd(key: string, val: T): T;
  118423. /**
  118424. * Check if there's a given key in the dictionary
  118425. * @param key the key to check for
  118426. * @return true if the key is present, false otherwise
  118427. */
  118428. contains(key: string): boolean;
  118429. /**
  118430. * Add a new key and its corresponding value
  118431. * @param key the key to add
  118432. * @param value the value corresponding to the key
  118433. * @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
  118434. */
  118435. add(key: string, value: T): boolean;
  118436. /**
  118437. * Update a specific value associated to a key
  118438. * @param key defines the key to use
  118439. * @param value defines the value to store
  118440. * @returns true if the value was updated (or false if the key was not found)
  118441. */
  118442. set(key: string, value: T): boolean;
  118443. /**
  118444. * Get the element of the given key and remove it from the dictionary
  118445. * @param key defines the key to search
  118446. * @returns the value associated with the key or null if not found
  118447. */
  118448. getAndRemove(key: string): Nullable<T>;
  118449. /**
  118450. * Remove a key/value from the dictionary.
  118451. * @param key the key to remove
  118452. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  118453. */
  118454. remove(key: string): boolean;
  118455. /**
  118456. * Clear the whole content of the dictionary
  118457. */
  118458. clear(): void;
  118459. /**
  118460. * Gets the current count
  118461. */
  118462. get count(): number;
  118463. /**
  118464. * Execute a callback on each key/val of the dictionary.
  118465. * Note that you can remove any element in this dictionary in the callback implementation
  118466. * @param callback the callback to execute on a given key/value pair
  118467. */
  118468. forEach(callback: (key: string, val: T) => void): void;
  118469. /**
  118470. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  118471. * If the callback returns null or undefined the method will iterate to the next key/value pair
  118472. * Note that you can remove any element in this dictionary in the callback implementation
  118473. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  118474. * @returns the first item
  118475. */
  118476. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  118477. private _count;
  118478. private _data;
  118479. }
  118480. }
  118481. declare module BABYLON {
  118482. /** @hidden */
  118483. export interface ICollisionCoordinator {
  118484. createCollider(): Collider;
  118485. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  118486. init(scene: Scene): void;
  118487. }
  118488. /** @hidden */
  118489. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  118490. private _scene;
  118491. private _scaledPosition;
  118492. private _scaledVelocity;
  118493. private _finalPosition;
  118494. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  118495. createCollider(): Collider;
  118496. init(scene: Scene): void;
  118497. private _collideWithWorld;
  118498. }
  118499. }
  118500. declare module BABYLON {
  118501. /**
  118502. * Class used to manage all inputs for the scene.
  118503. */
  118504. export class InputManager {
  118505. /** The distance in pixel that you have to move to prevent some events */
  118506. static DragMovementThreshold: number;
  118507. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  118508. static LongPressDelay: number;
  118509. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  118510. static DoubleClickDelay: number;
  118511. /** If you need to check double click without raising a single click at first click, enable this flag */
  118512. static ExclusiveDoubleClickMode: boolean;
  118513. /** 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. */
  118514. private _alreadyAttached;
  118515. private _wheelEventName;
  118516. private _onPointerMove;
  118517. private _onPointerDown;
  118518. private _onPointerUp;
  118519. private _initClickEvent;
  118520. private _initActionManager;
  118521. private _delayedSimpleClick;
  118522. private _delayedSimpleClickTimeout;
  118523. private _previousDelayedSimpleClickTimeout;
  118524. private _meshPickProceed;
  118525. private _previousButtonPressed;
  118526. private _currentPickResult;
  118527. private _previousPickResult;
  118528. private _totalPointersPressed;
  118529. private _doubleClickOccured;
  118530. private _pointerOverMesh;
  118531. private _pickedDownMesh;
  118532. private _pickedUpMesh;
  118533. private _pointerX;
  118534. private _pointerY;
  118535. private _unTranslatedPointerX;
  118536. private _unTranslatedPointerY;
  118537. private _startingPointerPosition;
  118538. private _previousStartingPointerPosition;
  118539. private _startingPointerTime;
  118540. private _previousStartingPointerTime;
  118541. private _pointerCaptures;
  118542. private _onKeyDown;
  118543. private _onKeyUp;
  118544. private _onCanvasFocusObserver;
  118545. private _onCanvasBlurObserver;
  118546. private _scene;
  118547. /**
  118548. * Creates a new InputManager
  118549. * @param scene defines the hosting scene
  118550. */
  118551. constructor(scene: Scene);
  118552. /**
  118553. * Gets the mesh that is currently under the pointer
  118554. */
  118555. get meshUnderPointer(): Nullable<AbstractMesh>;
  118556. /**
  118557. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  118558. */
  118559. get unTranslatedPointer(): Vector2;
  118560. /**
  118561. * Gets or sets the current on-screen X position of the pointer
  118562. */
  118563. get pointerX(): number;
  118564. set pointerX(value: number);
  118565. /**
  118566. * Gets or sets the current on-screen Y position of the pointer
  118567. */
  118568. get pointerY(): number;
  118569. set pointerY(value: number);
  118570. private _updatePointerPosition;
  118571. private _processPointerMove;
  118572. private _setRayOnPointerInfo;
  118573. private _checkPrePointerObservable;
  118574. /**
  118575. * Use this method to simulate a pointer move on a mesh
  118576. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118577. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118578. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118579. */
  118580. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  118581. /**
  118582. * Use this method to simulate a pointer down on a mesh
  118583. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118584. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118585. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118586. */
  118587. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  118588. private _processPointerDown;
  118589. /** @hidden */
  118590. _isPointerSwiping(): boolean;
  118591. /**
  118592. * Use this method to simulate a pointer up on a mesh
  118593. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118594. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118595. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118596. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  118597. */
  118598. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  118599. private _processPointerUp;
  118600. /**
  118601. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  118602. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  118603. * @returns true if the pointer was captured
  118604. */
  118605. isPointerCaptured(pointerId?: number): boolean;
  118606. /**
  118607. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  118608. * @param attachUp defines if you want to attach events to pointerup
  118609. * @param attachDown defines if you want to attach events to pointerdown
  118610. * @param attachMove defines if you want to attach events to pointermove
  118611. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  118612. */
  118613. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  118614. /**
  118615. * Detaches all event handlers
  118616. */
  118617. detachControl(): void;
  118618. /**
  118619. * Force the value of meshUnderPointer
  118620. * @param mesh defines the mesh to use
  118621. */
  118622. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  118623. /**
  118624. * Gets the mesh under the pointer
  118625. * @returns a Mesh or null if no mesh is under the pointer
  118626. */
  118627. getPointerOverMesh(): Nullable<AbstractMesh>;
  118628. }
  118629. }
  118630. declare module BABYLON {
  118631. /**
  118632. * This class defines the direct association between an animation and a target
  118633. */
  118634. export class TargetedAnimation {
  118635. /**
  118636. * Animation to perform
  118637. */
  118638. animation: Animation;
  118639. /**
  118640. * Target to animate
  118641. */
  118642. target: any;
  118643. /**
  118644. * Returns the string "TargetedAnimation"
  118645. * @returns "TargetedAnimation"
  118646. */
  118647. getClassName(): string;
  118648. /**
  118649. * Serialize the object
  118650. * @returns the JSON object representing the current entity
  118651. */
  118652. serialize(): any;
  118653. }
  118654. /**
  118655. * Use this class to create coordinated animations on multiple targets
  118656. */
  118657. export class AnimationGroup implements IDisposable {
  118658. /** The name of the animation group */
  118659. name: string;
  118660. private _scene;
  118661. private _targetedAnimations;
  118662. private _animatables;
  118663. private _from;
  118664. private _to;
  118665. private _isStarted;
  118666. private _isPaused;
  118667. private _speedRatio;
  118668. private _loopAnimation;
  118669. private _isAdditive;
  118670. /**
  118671. * Gets or sets the unique id of the node
  118672. */
  118673. uniqueId: number;
  118674. /**
  118675. * This observable will notify when one animation have ended
  118676. */
  118677. onAnimationEndObservable: Observable<TargetedAnimation>;
  118678. /**
  118679. * Observer raised when one animation loops
  118680. */
  118681. onAnimationLoopObservable: Observable<TargetedAnimation>;
  118682. /**
  118683. * Observer raised when all animations have looped
  118684. */
  118685. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  118686. /**
  118687. * This observable will notify when all animations have ended.
  118688. */
  118689. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  118690. /**
  118691. * This observable will notify when all animations have paused.
  118692. */
  118693. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  118694. /**
  118695. * This observable will notify when all animations are playing.
  118696. */
  118697. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  118698. /**
  118699. * Gets the first frame
  118700. */
  118701. get from(): number;
  118702. /**
  118703. * Gets the last frame
  118704. */
  118705. get to(): number;
  118706. /**
  118707. * Define if the animations are started
  118708. */
  118709. get isStarted(): boolean;
  118710. /**
  118711. * Gets a value indicating that the current group is playing
  118712. */
  118713. get isPlaying(): boolean;
  118714. /**
  118715. * Gets or sets the speed ratio to use for all animations
  118716. */
  118717. get speedRatio(): number;
  118718. /**
  118719. * Gets or sets the speed ratio to use for all animations
  118720. */
  118721. set speedRatio(value: number);
  118722. /**
  118723. * Gets or sets if all animations should loop or not
  118724. */
  118725. get loopAnimation(): boolean;
  118726. set loopAnimation(value: boolean);
  118727. /**
  118728. * Gets or sets if all animations should be evaluated additively
  118729. */
  118730. get isAdditive(): boolean;
  118731. set isAdditive(value: boolean);
  118732. /**
  118733. * Gets the targeted animations for this animation group
  118734. */
  118735. get targetedAnimations(): Array<TargetedAnimation>;
  118736. /**
  118737. * returning the list of animatables controlled by this animation group.
  118738. */
  118739. get animatables(): Array<Animatable>;
  118740. /**
  118741. * Gets the list of target animations
  118742. */
  118743. get children(): TargetedAnimation[];
  118744. /**
  118745. * Instantiates a new Animation Group.
  118746. * This helps managing several animations at once.
  118747. * @see https://doc.babylonjs.com/how_to/group
  118748. * @param name Defines the name of the group
  118749. * @param scene Defines the scene the group belongs to
  118750. */
  118751. constructor(
  118752. /** The name of the animation group */
  118753. name: string, scene?: Nullable<Scene>);
  118754. /**
  118755. * Add an animation (with its target) in the group
  118756. * @param animation defines the animation we want to add
  118757. * @param target defines the target of the animation
  118758. * @returns the TargetedAnimation object
  118759. */
  118760. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  118761. /**
  118762. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  118763. * It can add constant keys at begin or end
  118764. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  118765. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  118766. * @returns the animation group
  118767. */
  118768. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  118769. private _animationLoopCount;
  118770. private _animationLoopFlags;
  118771. private _processLoop;
  118772. /**
  118773. * Start all animations on given targets
  118774. * @param loop defines if animations must loop
  118775. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  118776. * @param from defines the from key (optional)
  118777. * @param to defines the to key (optional)
  118778. * @param isAdditive defines the additive state for the resulting animatables (optional)
  118779. * @returns the current animation group
  118780. */
  118781. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  118782. /**
  118783. * Pause all animations
  118784. * @returns the animation group
  118785. */
  118786. pause(): AnimationGroup;
  118787. /**
  118788. * Play all animations to initial state
  118789. * This function will start() the animations if they were not started or will restart() them if they were paused
  118790. * @param loop defines if animations must loop
  118791. * @returns the animation group
  118792. */
  118793. play(loop?: boolean): AnimationGroup;
  118794. /**
  118795. * Reset all animations to initial state
  118796. * @returns the animation group
  118797. */
  118798. reset(): AnimationGroup;
  118799. /**
  118800. * Restart animations from key 0
  118801. * @returns the animation group
  118802. */
  118803. restart(): AnimationGroup;
  118804. /**
  118805. * Stop all animations
  118806. * @returns the animation group
  118807. */
  118808. stop(): AnimationGroup;
  118809. /**
  118810. * Set animation weight for all animatables
  118811. * @param weight defines the weight to use
  118812. * @return the animationGroup
  118813. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  118814. */
  118815. setWeightForAllAnimatables(weight: number): AnimationGroup;
  118816. /**
  118817. * Synchronize and normalize all animatables with a source animatable
  118818. * @param root defines the root animatable to synchronize with
  118819. * @return the animationGroup
  118820. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  118821. */
  118822. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  118823. /**
  118824. * Goes to a specific frame in this animation group
  118825. * @param frame the frame number to go to
  118826. * @return the animationGroup
  118827. */
  118828. goToFrame(frame: number): AnimationGroup;
  118829. /**
  118830. * Dispose all associated resources
  118831. */
  118832. dispose(): void;
  118833. private _checkAnimationGroupEnded;
  118834. /**
  118835. * Clone the current animation group and returns a copy
  118836. * @param newName defines the name of the new group
  118837. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  118838. * @returns the new aniamtion group
  118839. */
  118840. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  118841. /**
  118842. * Serializes the animationGroup to an object
  118843. * @returns Serialized object
  118844. */
  118845. serialize(): any;
  118846. /**
  118847. * Returns a new AnimationGroup object parsed from the source provided.
  118848. * @param parsedAnimationGroup defines the source
  118849. * @param scene defines the scene that will receive the animationGroup
  118850. * @returns a new AnimationGroup
  118851. */
  118852. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  118853. /**
  118854. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  118855. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  118856. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  118857. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  118858. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  118859. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  118860. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  118861. */
  118862. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  118863. /**
  118864. * Returns the string "AnimationGroup"
  118865. * @returns "AnimationGroup"
  118866. */
  118867. getClassName(): string;
  118868. /**
  118869. * Creates a detailled string about the object
  118870. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  118871. * @returns a string representing the object
  118872. */
  118873. toString(fullDetails?: boolean): string;
  118874. }
  118875. }
  118876. declare module BABYLON {
  118877. /**
  118878. * Define an interface for all classes that will hold resources
  118879. */
  118880. export interface IDisposable {
  118881. /**
  118882. * Releases all held resources
  118883. */
  118884. dispose(): void;
  118885. }
  118886. /** Interface defining initialization parameters for Scene class */
  118887. export interface SceneOptions {
  118888. /**
  118889. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  118890. * It will improve performance when the number of geometries becomes important.
  118891. */
  118892. useGeometryUniqueIdsMap?: boolean;
  118893. /**
  118894. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  118895. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  118896. */
  118897. useMaterialMeshMap?: boolean;
  118898. /**
  118899. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  118900. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  118901. */
  118902. useClonedMeshMap?: boolean;
  118903. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  118904. virtual?: boolean;
  118905. }
  118906. /**
  118907. * Represents a scene to be rendered by the engine.
  118908. * @see https://doc.babylonjs.com/features/scene
  118909. */
  118910. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  118911. /** The fog is deactivated */
  118912. static readonly FOGMODE_NONE: number;
  118913. /** The fog density is following an exponential function */
  118914. static readonly FOGMODE_EXP: number;
  118915. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  118916. static readonly FOGMODE_EXP2: number;
  118917. /** The fog density is following a linear function. */
  118918. static readonly FOGMODE_LINEAR: number;
  118919. /**
  118920. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  118921. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118922. */
  118923. static MinDeltaTime: number;
  118924. /**
  118925. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  118926. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118927. */
  118928. static MaxDeltaTime: number;
  118929. /**
  118930. * Factory used to create the default material.
  118931. * @param name The name of the material to create
  118932. * @param scene The scene to create the material for
  118933. * @returns The default material
  118934. */
  118935. static DefaultMaterialFactory(scene: Scene): Material;
  118936. /**
  118937. * Factory used to create the a collision coordinator.
  118938. * @returns The collision coordinator
  118939. */
  118940. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  118941. /** @hidden */
  118942. _inputManager: InputManager;
  118943. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  118944. cameraToUseForPointers: Nullable<Camera>;
  118945. /** @hidden */
  118946. readonly _isScene: boolean;
  118947. /** @hidden */
  118948. _blockEntityCollection: boolean;
  118949. /**
  118950. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  118951. */
  118952. autoClear: boolean;
  118953. /**
  118954. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  118955. */
  118956. autoClearDepthAndStencil: boolean;
  118957. /**
  118958. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  118959. */
  118960. clearColor: Color4;
  118961. /**
  118962. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  118963. */
  118964. ambientColor: Color3;
  118965. /**
  118966. * This is use to store the default BRDF lookup for PBR materials in your scene.
  118967. * It should only be one of the following (if not the default embedded one):
  118968. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  118969. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  118970. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  118971. * The material properties need to be setup according to the type of texture in use.
  118972. */
  118973. environmentBRDFTexture: BaseTexture;
  118974. /** @hidden */
  118975. protected _environmentTexture: Nullable<BaseTexture>;
  118976. /**
  118977. * Texture used in all pbr material as the reflection texture.
  118978. * As in the majority of the scene they are the same (exception for multi room and so on),
  118979. * this is easier to reference from here than from all the materials.
  118980. */
  118981. get environmentTexture(): Nullable<BaseTexture>;
  118982. /**
  118983. * Texture used in all pbr material as the reflection texture.
  118984. * As in the majority of the scene they are the same (exception for multi room and so on),
  118985. * this is easier to set here than in all the materials.
  118986. */
  118987. set environmentTexture(value: Nullable<BaseTexture>);
  118988. /** @hidden */
  118989. protected _environmentIntensity: number;
  118990. /**
  118991. * Intensity of the environment in all pbr material.
  118992. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  118993. * As in the majority of the scene they are the same (exception for multi room and so on),
  118994. * this is easier to reference from here than from all the materials.
  118995. */
  118996. get environmentIntensity(): number;
  118997. /**
  118998. * Intensity of the environment in all pbr material.
  118999. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119000. * As in the majority of the scene they are the same (exception for multi room and so on),
  119001. * this is easier to set here than in all the materials.
  119002. */
  119003. set environmentIntensity(value: number);
  119004. /** @hidden */
  119005. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119006. /**
  119007. * Default image processing configuration used either in the rendering
  119008. * Forward main pass or through the imageProcessingPostProcess if present.
  119009. * As in the majority of the scene they are the same (exception for multi camera),
  119010. * this is easier to reference from here than from all the materials and post process.
  119011. *
  119012. * No setter as we it is a shared configuration, you can set the values instead.
  119013. */
  119014. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  119015. private _forceWireframe;
  119016. /**
  119017. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  119018. */
  119019. set forceWireframe(value: boolean);
  119020. get forceWireframe(): boolean;
  119021. private _skipFrustumClipping;
  119022. /**
  119023. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  119024. */
  119025. set skipFrustumClipping(value: boolean);
  119026. get skipFrustumClipping(): boolean;
  119027. private _forcePointsCloud;
  119028. /**
  119029. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  119030. */
  119031. set forcePointsCloud(value: boolean);
  119032. get forcePointsCloud(): boolean;
  119033. /**
  119034. * Gets or sets the active clipplane 1
  119035. */
  119036. clipPlane: Nullable<Plane>;
  119037. /**
  119038. * Gets or sets the active clipplane 2
  119039. */
  119040. clipPlane2: Nullable<Plane>;
  119041. /**
  119042. * Gets or sets the active clipplane 3
  119043. */
  119044. clipPlane3: Nullable<Plane>;
  119045. /**
  119046. * Gets or sets the active clipplane 4
  119047. */
  119048. clipPlane4: Nullable<Plane>;
  119049. /**
  119050. * Gets or sets the active clipplane 5
  119051. */
  119052. clipPlane5: Nullable<Plane>;
  119053. /**
  119054. * Gets or sets the active clipplane 6
  119055. */
  119056. clipPlane6: Nullable<Plane>;
  119057. /**
  119058. * Gets or sets a boolean indicating if animations are enabled
  119059. */
  119060. animationsEnabled: boolean;
  119061. private _animationPropertiesOverride;
  119062. /**
  119063. * Gets or sets the animation properties override
  119064. */
  119065. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  119066. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  119067. /**
  119068. * Gets or sets a boolean indicating if a constant deltatime has to be used
  119069. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  119070. */
  119071. useConstantAnimationDeltaTime: boolean;
  119072. /**
  119073. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  119074. * Please note that it requires to run a ray cast through the scene on every frame
  119075. */
  119076. constantlyUpdateMeshUnderPointer: boolean;
  119077. /**
  119078. * Defines the HTML cursor to use when hovering over interactive elements
  119079. */
  119080. hoverCursor: string;
  119081. /**
  119082. * Defines the HTML default cursor to use (empty by default)
  119083. */
  119084. defaultCursor: string;
  119085. /**
  119086. * Defines whether cursors are handled by the scene.
  119087. */
  119088. doNotHandleCursors: boolean;
  119089. /**
  119090. * This is used to call preventDefault() on pointer down
  119091. * in order to block unwanted artifacts like system double clicks
  119092. */
  119093. preventDefaultOnPointerDown: boolean;
  119094. /**
  119095. * This is used to call preventDefault() on pointer up
  119096. * in order to block unwanted artifacts like system double clicks
  119097. */
  119098. preventDefaultOnPointerUp: boolean;
  119099. /**
  119100. * Gets or sets user defined metadata
  119101. */
  119102. metadata: any;
  119103. /**
  119104. * For internal use only. Please do not use.
  119105. */
  119106. reservedDataStore: any;
  119107. /**
  119108. * Gets the name of the plugin used to load this scene (null by default)
  119109. */
  119110. loadingPluginName: string;
  119111. /**
  119112. * Use this array to add regular expressions used to disable offline support for specific urls
  119113. */
  119114. disableOfflineSupportExceptionRules: RegExp[];
  119115. /**
  119116. * An event triggered when the scene is disposed.
  119117. */
  119118. onDisposeObservable: Observable<Scene>;
  119119. private _onDisposeObserver;
  119120. /** Sets a function to be executed when this scene is disposed. */
  119121. set onDispose(callback: () => void);
  119122. /**
  119123. * An event triggered before rendering the scene (right after animations and physics)
  119124. */
  119125. onBeforeRenderObservable: Observable<Scene>;
  119126. private _onBeforeRenderObserver;
  119127. /** Sets a function to be executed before rendering this scene */
  119128. set beforeRender(callback: Nullable<() => void>);
  119129. /**
  119130. * An event triggered after rendering the scene
  119131. */
  119132. onAfterRenderObservable: Observable<Scene>;
  119133. /**
  119134. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  119135. */
  119136. onAfterRenderCameraObservable: Observable<Camera>;
  119137. private _onAfterRenderObserver;
  119138. /** Sets a function to be executed after rendering this scene */
  119139. set afterRender(callback: Nullable<() => void>);
  119140. /**
  119141. * An event triggered before animating the scene
  119142. */
  119143. onBeforeAnimationsObservable: Observable<Scene>;
  119144. /**
  119145. * An event triggered after animations processing
  119146. */
  119147. onAfterAnimationsObservable: Observable<Scene>;
  119148. /**
  119149. * An event triggered before draw calls are ready to be sent
  119150. */
  119151. onBeforeDrawPhaseObservable: Observable<Scene>;
  119152. /**
  119153. * An event triggered after draw calls have been sent
  119154. */
  119155. onAfterDrawPhaseObservable: Observable<Scene>;
  119156. /**
  119157. * An event triggered when the scene is ready
  119158. */
  119159. onReadyObservable: Observable<Scene>;
  119160. /**
  119161. * An event triggered before rendering a camera
  119162. */
  119163. onBeforeCameraRenderObservable: Observable<Camera>;
  119164. private _onBeforeCameraRenderObserver;
  119165. /** Sets a function to be executed before rendering a camera*/
  119166. set beforeCameraRender(callback: () => void);
  119167. /**
  119168. * An event triggered after rendering a camera
  119169. */
  119170. onAfterCameraRenderObservable: Observable<Camera>;
  119171. private _onAfterCameraRenderObserver;
  119172. /** Sets a function to be executed after rendering a camera*/
  119173. set afterCameraRender(callback: () => void);
  119174. /**
  119175. * An event triggered when active meshes evaluation is about to start
  119176. */
  119177. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  119178. /**
  119179. * An event triggered when active meshes evaluation is done
  119180. */
  119181. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  119182. /**
  119183. * An event triggered when particles rendering is about to start
  119184. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119185. */
  119186. onBeforeParticlesRenderingObservable: Observable<Scene>;
  119187. /**
  119188. * An event triggered when particles rendering is done
  119189. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119190. */
  119191. onAfterParticlesRenderingObservable: Observable<Scene>;
  119192. /**
  119193. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  119194. */
  119195. onDataLoadedObservable: Observable<Scene>;
  119196. /**
  119197. * An event triggered when a camera is created
  119198. */
  119199. onNewCameraAddedObservable: Observable<Camera>;
  119200. /**
  119201. * An event triggered when a camera is removed
  119202. */
  119203. onCameraRemovedObservable: Observable<Camera>;
  119204. /**
  119205. * An event triggered when a light is created
  119206. */
  119207. onNewLightAddedObservable: Observable<Light>;
  119208. /**
  119209. * An event triggered when a light is removed
  119210. */
  119211. onLightRemovedObservable: Observable<Light>;
  119212. /**
  119213. * An event triggered when a geometry is created
  119214. */
  119215. onNewGeometryAddedObservable: Observable<Geometry>;
  119216. /**
  119217. * An event triggered when a geometry is removed
  119218. */
  119219. onGeometryRemovedObservable: Observable<Geometry>;
  119220. /**
  119221. * An event triggered when a transform node is created
  119222. */
  119223. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  119224. /**
  119225. * An event triggered when a transform node is removed
  119226. */
  119227. onTransformNodeRemovedObservable: Observable<TransformNode>;
  119228. /**
  119229. * An event triggered when a mesh is created
  119230. */
  119231. onNewMeshAddedObservable: Observable<AbstractMesh>;
  119232. /**
  119233. * An event triggered when a mesh is removed
  119234. */
  119235. onMeshRemovedObservable: Observable<AbstractMesh>;
  119236. /**
  119237. * An event triggered when a skeleton is created
  119238. */
  119239. onNewSkeletonAddedObservable: Observable<Skeleton>;
  119240. /**
  119241. * An event triggered when a skeleton is removed
  119242. */
  119243. onSkeletonRemovedObservable: Observable<Skeleton>;
  119244. /**
  119245. * An event triggered when a material is created
  119246. */
  119247. onNewMaterialAddedObservable: Observable<Material>;
  119248. /**
  119249. * An event triggered when a material is removed
  119250. */
  119251. onMaterialRemovedObservable: Observable<Material>;
  119252. /**
  119253. * An event triggered when a texture is created
  119254. */
  119255. onNewTextureAddedObservable: Observable<BaseTexture>;
  119256. /**
  119257. * An event triggered when a texture is removed
  119258. */
  119259. onTextureRemovedObservable: Observable<BaseTexture>;
  119260. /**
  119261. * An event triggered when render targets are about to be rendered
  119262. * Can happen multiple times per frame.
  119263. */
  119264. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  119265. /**
  119266. * An event triggered when render targets were rendered.
  119267. * Can happen multiple times per frame.
  119268. */
  119269. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  119270. /**
  119271. * An event triggered before calculating deterministic simulation step
  119272. */
  119273. onBeforeStepObservable: Observable<Scene>;
  119274. /**
  119275. * An event triggered after calculating deterministic simulation step
  119276. */
  119277. onAfterStepObservable: Observable<Scene>;
  119278. /**
  119279. * An event triggered when the activeCamera property is updated
  119280. */
  119281. onActiveCameraChanged: Observable<Scene>;
  119282. /**
  119283. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  119284. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  119285. * 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)
  119286. */
  119287. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  119288. /**
  119289. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  119290. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  119291. * 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)
  119292. */
  119293. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  119294. /**
  119295. * This Observable will when a mesh has been imported into the scene.
  119296. */
  119297. onMeshImportedObservable: Observable<AbstractMesh>;
  119298. /**
  119299. * This Observable will when an animation file has been imported into the scene.
  119300. */
  119301. onAnimationFileImportedObservable: Observable<Scene>;
  119302. /**
  119303. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  119304. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  119305. */
  119306. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  119307. /** @hidden */
  119308. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  119309. /**
  119310. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  119311. */
  119312. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  119313. /**
  119314. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  119315. */
  119316. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  119317. /**
  119318. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  119319. */
  119320. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  119321. /** Callback called when a pointer move is detected */
  119322. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  119323. /** Callback called when a pointer down is detected */
  119324. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  119325. /** Callback called when a pointer up is detected */
  119326. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  119327. /** Callback called when a pointer pick is detected */
  119328. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  119329. /**
  119330. * 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).
  119331. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  119332. */
  119333. onPrePointerObservable: Observable<PointerInfoPre>;
  119334. /**
  119335. * Observable event triggered each time an input event is received from the rendering canvas
  119336. */
  119337. onPointerObservable: Observable<PointerInfo>;
  119338. /**
  119339. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  119340. */
  119341. get unTranslatedPointer(): Vector2;
  119342. /**
  119343. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  119344. */
  119345. static get DragMovementThreshold(): number;
  119346. static set DragMovementThreshold(value: number);
  119347. /**
  119348. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  119349. */
  119350. static get LongPressDelay(): number;
  119351. static set LongPressDelay(value: number);
  119352. /**
  119353. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  119354. */
  119355. static get DoubleClickDelay(): number;
  119356. static set DoubleClickDelay(value: number);
  119357. /** If you need to check double click without raising a single click at first click, enable this flag */
  119358. static get ExclusiveDoubleClickMode(): boolean;
  119359. static set ExclusiveDoubleClickMode(value: boolean);
  119360. /** @hidden */
  119361. _mirroredCameraPosition: Nullable<Vector3>;
  119362. /**
  119363. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  119364. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  119365. */
  119366. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  119367. /**
  119368. * Observable event triggered each time an keyboard event is received from the hosting window
  119369. */
  119370. onKeyboardObservable: Observable<KeyboardInfo>;
  119371. private _useRightHandedSystem;
  119372. /**
  119373. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  119374. */
  119375. set useRightHandedSystem(value: boolean);
  119376. get useRightHandedSystem(): boolean;
  119377. private _timeAccumulator;
  119378. private _currentStepId;
  119379. private _currentInternalStep;
  119380. /**
  119381. * Sets the step Id used by deterministic lock step
  119382. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119383. * @param newStepId defines the step Id
  119384. */
  119385. setStepId(newStepId: number): void;
  119386. /**
  119387. * Gets the step Id used by deterministic lock step
  119388. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119389. * @returns the step Id
  119390. */
  119391. getStepId(): number;
  119392. /**
  119393. * Gets the internal step used by deterministic lock step
  119394. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119395. * @returns the internal step
  119396. */
  119397. getInternalStep(): number;
  119398. private _fogEnabled;
  119399. /**
  119400. * Gets or sets a boolean indicating if fog is enabled on this scene
  119401. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119402. * (Default is true)
  119403. */
  119404. set fogEnabled(value: boolean);
  119405. get fogEnabled(): boolean;
  119406. private _fogMode;
  119407. /**
  119408. * Gets or sets the fog mode to use
  119409. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119410. * | mode | value |
  119411. * | --- | --- |
  119412. * | FOGMODE_NONE | 0 |
  119413. * | FOGMODE_EXP | 1 |
  119414. * | FOGMODE_EXP2 | 2 |
  119415. * | FOGMODE_LINEAR | 3 |
  119416. */
  119417. set fogMode(value: number);
  119418. get fogMode(): number;
  119419. /**
  119420. * Gets or sets the fog color to use
  119421. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119422. * (Default is Color3(0.2, 0.2, 0.3))
  119423. */
  119424. fogColor: Color3;
  119425. /**
  119426. * Gets or sets the fog density to use
  119427. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119428. * (Default is 0.1)
  119429. */
  119430. fogDensity: number;
  119431. /**
  119432. * Gets or sets the fog start distance to use
  119433. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119434. * (Default is 0)
  119435. */
  119436. fogStart: number;
  119437. /**
  119438. * Gets or sets the fog end distance to use
  119439. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119440. * (Default is 1000)
  119441. */
  119442. fogEnd: number;
  119443. /**
  119444. * Flag indicating that the frame buffer binding is handled by another component
  119445. */
  119446. prePass: boolean;
  119447. private _shadowsEnabled;
  119448. /**
  119449. * Gets or sets a boolean indicating if shadows are enabled on this scene
  119450. */
  119451. set shadowsEnabled(value: boolean);
  119452. get shadowsEnabled(): boolean;
  119453. private _lightsEnabled;
  119454. /**
  119455. * Gets or sets a boolean indicating if lights are enabled on this scene
  119456. */
  119457. set lightsEnabled(value: boolean);
  119458. get lightsEnabled(): boolean;
  119459. /** All of the active cameras added to this scene. */
  119460. activeCameras: Camera[];
  119461. /** @hidden */
  119462. _activeCamera: Nullable<Camera>;
  119463. /** Gets or sets the current active camera */
  119464. get activeCamera(): Nullable<Camera>;
  119465. set activeCamera(value: Nullable<Camera>);
  119466. private _defaultMaterial;
  119467. /** The default material used on meshes when no material is affected */
  119468. get defaultMaterial(): Material;
  119469. /** The default material used on meshes when no material is affected */
  119470. set defaultMaterial(value: Material);
  119471. private _texturesEnabled;
  119472. /**
  119473. * Gets or sets a boolean indicating if textures are enabled on this scene
  119474. */
  119475. set texturesEnabled(value: boolean);
  119476. get texturesEnabled(): boolean;
  119477. /**
  119478. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  119479. */
  119480. physicsEnabled: boolean;
  119481. /**
  119482. * Gets or sets a boolean indicating if particles are enabled on this scene
  119483. */
  119484. particlesEnabled: boolean;
  119485. /**
  119486. * Gets or sets a boolean indicating if sprites are enabled on this scene
  119487. */
  119488. spritesEnabled: boolean;
  119489. private _skeletonsEnabled;
  119490. /**
  119491. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  119492. */
  119493. set skeletonsEnabled(value: boolean);
  119494. get skeletonsEnabled(): boolean;
  119495. /**
  119496. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  119497. */
  119498. lensFlaresEnabled: boolean;
  119499. /**
  119500. * Gets or sets a boolean indicating if collisions are enabled on this scene
  119501. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  119502. */
  119503. collisionsEnabled: boolean;
  119504. private _collisionCoordinator;
  119505. /** @hidden */
  119506. get collisionCoordinator(): ICollisionCoordinator;
  119507. /**
  119508. * Defines the gravity applied to this scene (used only for collisions)
  119509. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  119510. */
  119511. gravity: Vector3;
  119512. /**
  119513. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  119514. */
  119515. postProcessesEnabled: boolean;
  119516. /**
  119517. * Gets the current postprocess manager
  119518. */
  119519. postProcessManager: PostProcessManager;
  119520. /**
  119521. * Gets or sets a boolean indicating if render targets are enabled on this scene
  119522. */
  119523. renderTargetsEnabled: boolean;
  119524. /**
  119525. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  119526. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  119527. */
  119528. dumpNextRenderTargets: boolean;
  119529. /**
  119530. * The list of user defined render targets added to the scene
  119531. */
  119532. customRenderTargets: RenderTargetTexture[];
  119533. /**
  119534. * Defines if texture loading must be delayed
  119535. * If true, textures will only be loaded when they need to be rendered
  119536. */
  119537. useDelayedTextureLoading: boolean;
  119538. /**
  119539. * Gets the list of meshes imported to the scene through SceneLoader
  119540. */
  119541. importedMeshesFiles: String[];
  119542. /**
  119543. * Gets or sets a boolean indicating if probes are enabled on this scene
  119544. */
  119545. probesEnabled: boolean;
  119546. /**
  119547. * Gets or sets the current offline provider to use to store scene data
  119548. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  119549. */
  119550. offlineProvider: IOfflineProvider;
  119551. /**
  119552. * Gets or sets the action manager associated with the scene
  119553. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  119554. */
  119555. actionManager: AbstractActionManager;
  119556. private _meshesForIntersections;
  119557. /**
  119558. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  119559. */
  119560. proceduralTexturesEnabled: boolean;
  119561. private _engine;
  119562. private _totalVertices;
  119563. /** @hidden */
  119564. _activeIndices: PerfCounter;
  119565. /** @hidden */
  119566. _activeParticles: PerfCounter;
  119567. /** @hidden */
  119568. _activeBones: PerfCounter;
  119569. private _animationRatio;
  119570. /** @hidden */
  119571. _animationTimeLast: number;
  119572. /** @hidden */
  119573. _animationTime: number;
  119574. /**
  119575. * Gets or sets a general scale for animation speed
  119576. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  119577. */
  119578. animationTimeScale: number;
  119579. /** @hidden */
  119580. _cachedMaterial: Nullable<Material>;
  119581. /** @hidden */
  119582. _cachedEffect: Nullable<Effect>;
  119583. /** @hidden */
  119584. _cachedVisibility: Nullable<number>;
  119585. private _renderId;
  119586. private _frameId;
  119587. private _executeWhenReadyTimeoutId;
  119588. private _intermediateRendering;
  119589. private _viewUpdateFlag;
  119590. private _projectionUpdateFlag;
  119591. /** @hidden */
  119592. _toBeDisposed: Nullable<IDisposable>[];
  119593. private _activeRequests;
  119594. /** @hidden */
  119595. _pendingData: any[];
  119596. private _isDisposed;
  119597. /**
  119598. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  119599. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  119600. */
  119601. dispatchAllSubMeshesOfActiveMeshes: boolean;
  119602. private _activeMeshes;
  119603. private _processedMaterials;
  119604. private _renderTargets;
  119605. /** @hidden */
  119606. _activeParticleSystems: SmartArray<IParticleSystem>;
  119607. private _activeSkeletons;
  119608. private _softwareSkinnedMeshes;
  119609. private _renderingManager;
  119610. /** @hidden */
  119611. _activeAnimatables: Animatable[];
  119612. private _transformMatrix;
  119613. private _sceneUbo;
  119614. /** @hidden */
  119615. _viewMatrix: Matrix;
  119616. private _projectionMatrix;
  119617. /** @hidden */
  119618. _forcedViewPosition: Nullable<Vector3>;
  119619. /** @hidden */
  119620. _frustumPlanes: Plane[];
  119621. /**
  119622. * Gets the list of frustum planes (built from the active camera)
  119623. */
  119624. get frustumPlanes(): Plane[];
  119625. /**
  119626. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  119627. * This is useful if there are more lights that the maximum simulteanous authorized
  119628. */
  119629. requireLightSorting: boolean;
  119630. /** @hidden */
  119631. readonly useMaterialMeshMap: boolean;
  119632. /** @hidden */
  119633. readonly useClonedMeshMap: boolean;
  119634. private _externalData;
  119635. private _uid;
  119636. /**
  119637. * @hidden
  119638. * Backing store of defined scene components.
  119639. */
  119640. _components: ISceneComponent[];
  119641. /**
  119642. * @hidden
  119643. * Backing store of defined scene components.
  119644. */
  119645. _serializableComponents: ISceneSerializableComponent[];
  119646. /**
  119647. * List of components to register on the next registration step.
  119648. */
  119649. private _transientComponents;
  119650. /**
  119651. * Registers the transient components if needed.
  119652. */
  119653. private _registerTransientComponents;
  119654. /**
  119655. * @hidden
  119656. * Add a component to the scene.
  119657. * Note that the ccomponent could be registered on th next frame if this is called after
  119658. * the register component stage.
  119659. * @param component Defines the component to add to the scene
  119660. */
  119661. _addComponent(component: ISceneComponent): void;
  119662. /**
  119663. * @hidden
  119664. * Gets a component from the scene.
  119665. * @param name defines the name of the component to retrieve
  119666. * @returns the component or null if not present
  119667. */
  119668. _getComponent(name: string): Nullable<ISceneComponent>;
  119669. /**
  119670. * @hidden
  119671. * Defines the actions happening before camera updates.
  119672. */
  119673. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  119674. /**
  119675. * @hidden
  119676. * Defines the actions happening before clear the canvas.
  119677. */
  119678. _beforeClearStage: Stage<SimpleStageAction>;
  119679. /**
  119680. * @hidden
  119681. * Defines the actions when collecting render targets for the frame.
  119682. */
  119683. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  119684. /**
  119685. * @hidden
  119686. * Defines the actions happening for one camera in the frame.
  119687. */
  119688. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  119689. /**
  119690. * @hidden
  119691. * Defines the actions happening during the per mesh ready checks.
  119692. */
  119693. _isReadyForMeshStage: Stage<MeshStageAction>;
  119694. /**
  119695. * @hidden
  119696. * Defines the actions happening before evaluate active mesh checks.
  119697. */
  119698. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  119699. /**
  119700. * @hidden
  119701. * Defines the actions happening during the evaluate sub mesh checks.
  119702. */
  119703. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  119704. /**
  119705. * @hidden
  119706. * Defines the actions happening during the active mesh stage.
  119707. */
  119708. _activeMeshStage: Stage<ActiveMeshStageAction>;
  119709. /**
  119710. * @hidden
  119711. * Defines the actions happening during the per camera render target step.
  119712. */
  119713. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  119714. /**
  119715. * @hidden
  119716. * Defines the actions happening just before the active camera is drawing.
  119717. */
  119718. _beforeCameraDrawStage: Stage<CameraStageAction>;
  119719. /**
  119720. * @hidden
  119721. * Defines the actions happening just before a render target is drawing.
  119722. */
  119723. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  119724. /**
  119725. * @hidden
  119726. * Defines the actions happening just before a rendering group is drawing.
  119727. */
  119728. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  119729. /**
  119730. * @hidden
  119731. * Defines the actions happening just before a mesh is drawing.
  119732. */
  119733. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  119734. /**
  119735. * @hidden
  119736. * Defines the actions happening just after a mesh has been drawn.
  119737. */
  119738. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  119739. /**
  119740. * @hidden
  119741. * Defines the actions happening just after a rendering group has been drawn.
  119742. */
  119743. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  119744. /**
  119745. * @hidden
  119746. * Defines the actions happening just after the active camera has been drawn.
  119747. */
  119748. _afterCameraDrawStage: Stage<CameraStageAction>;
  119749. /**
  119750. * @hidden
  119751. * Defines the actions happening just after a render target has been drawn.
  119752. */
  119753. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  119754. /**
  119755. * @hidden
  119756. * Defines the actions happening just after rendering all cameras and computing intersections.
  119757. */
  119758. _afterRenderStage: Stage<SimpleStageAction>;
  119759. /**
  119760. * @hidden
  119761. * Defines the actions happening when a pointer move event happens.
  119762. */
  119763. _pointerMoveStage: Stage<PointerMoveStageAction>;
  119764. /**
  119765. * @hidden
  119766. * Defines the actions happening when a pointer down event happens.
  119767. */
  119768. _pointerDownStage: Stage<PointerUpDownStageAction>;
  119769. /**
  119770. * @hidden
  119771. * Defines the actions happening when a pointer up event happens.
  119772. */
  119773. _pointerUpStage: Stage<PointerUpDownStageAction>;
  119774. /**
  119775. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  119776. */
  119777. private geometriesByUniqueId;
  119778. /**
  119779. * Creates a new Scene
  119780. * @param engine defines the engine to use to render this scene
  119781. * @param options defines the scene options
  119782. */
  119783. constructor(engine: Engine, options?: SceneOptions);
  119784. /**
  119785. * Gets a string identifying the name of the class
  119786. * @returns "Scene" string
  119787. */
  119788. getClassName(): string;
  119789. private _defaultMeshCandidates;
  119790. /**
  119791. * @hidden
  119792. */
  119793. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  119794. private _defaultSubMeshCandidates;
  119795. /**
  119796. * @hidden
  119797. */
  119798. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  119799. /**
  119800. * Sets the default candidate providers for the scene.
  119801. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  119802. * and getCollidingSubMeshCandidates to their default function
  119803. */
  119804. setDefaultCandidateProviders(): void;
  119805. /**
  119806. * Gets the mesh that is currently under the pointer
  119807. */
  119808. get meshUnderPointer(): Nullable<AbstractMesh>;
  119809. /**
  119810. * Gets or sets the current on-screen X position of the pointer
  119811. */
  119812. get pointerX(): number;
  119813. set pointerX(value: number);
  119814. /**
  119815. * Gets or sets the current on-screen Y position of the pointer
  119816. */
  119817. get pointerY(): number;
  119818. set pointerY(value: number);
  119819. /**
  119820. * Gets the cached material (ie. the latest rendered one)
  119821. * @returns the cached material
  119822. */
  119823. getCachedMaterial(): Nullable<Material>;
  119824. /**
  119825. * Gets the cached effect (ie. the latest rendered one)
  119826. * @returns the cached effect
  119827. */
  119828. getCachedEffect(): Nullable<Effect>;
  119829. /**
  119830. * Gets the cached visibility state (ie. the latest rendered one)
  119831. * @returns the cached visibility state
  119832. */
  119833. getCachedVisibility(): Nullable<number>;
  119834. /**
  119835. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  119836. * @param material defines the current material
  119837. * @param effect defines the current effect
  119838. * @param visibility defines the current visibility state
  119839. * @returns true if one parameter is not cached
  119840. */
  119841. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  119842. /**
  119843. * Gets the engine associated with the scene
  119844. * @returns an Engine
  119845. */
  119846. getEngine(): Engine;
  119847. /**
  119848. * Gets the total number of vertices rendered per frame
  119849. * @returns the total number of vertices rendered per frame
  119850. */
  119851. getTotalVertices(): number;
  119852. /**
  119853. * Gets the performance counter for total vertices
  119854. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119855. */
  119856. get totalVerticesPerfCounter(): PerfCounter;
  119857. /**
  119858. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  119859. * @returns the total number of active indices rendered per frame
  119860. */
  119861. getActiveIndices(): number;
  119862. /**
  119863. * Gets the performance counter for active indices
  119864. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119865. */
  119866. get totalActiveIndicesPerfCounter(): PerfCounter;
  119867. /**
  119868. * Gets the total number of active particles rendered per frame
  119869. * @returns the total number of active particles rendered per frame
  119870. */
  119871. getActiveParticles(): number;
  119872. /**
  119873. * Gets the performance counter for active particles
  119874. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119875. */
  119876. get activeParticlesPerfCounter(): PerfCounter;
  119877. /**
  119878. * Gets the total number of active bones rendered per frame
  119879. * @returns the total number of active bones rendered per frame
  119880. */
  119881. getActiveBones(): number;
  119882. /**
  119883. * Gets the performance counter for active bones
  119884. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119885. */
  119886. get activeBonesPerfCounter(): PerfCounter;
  119887. /**
  119888. * Gets the array of active meshes
  119889. * @returns an array of AbstractMesh
  119890. */
  119891. getActiveMeshes(): SmartArray<AbstractMesh>;
  119892. /**
  119893. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  119894. * @returns a number
  119895. */
  119896. getAnimationRatio(): number;
  119897. /**
  119898. * Gets an unique Id for the current render phase
  119899. * @returns a number
  119900. */
  119901. getRenderId(): number;
  119902. /**
  119903. * Gets an unique Id for the current frame
  119904. * @returns a number
  119905. */
  119906. getFrameId(): number;
  119907. /** Call this function if you want to manually increment the render Id*/
  119908. incrementRenderId(): void;
  119909. private _createUbo;
  119910. /**
  119911. * Use this method to simulate a pointer move on a mesh
  119912. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119913. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119914. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119915. * @returns the current scene
  119916. */
  119917. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119918. /**
  119919. * Use this method to simulate a pointer down on a mesh
  119920. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119921. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119922. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119923. * @returns the current scene
  119924. */
  119925. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119926. /**
  119927. * Use this method to simulate a pointer up on a mesh
  119928. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119929. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119930. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119931. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119932. * @returns the current scene
  119933. */
  119934. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  119935. /**
  119936. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119937. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119938. * @returns true if the pointer was captured
  119939. */
  119940. isPointerCaptured(pointerId?: number): boolean;
  119941. /**
  119942. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119943. * @param attachUp defines if you want to attach events to pointerup
  119944. * @param attachDown defines if you want to attach events to pointerdown
  119945. * @param attachMove defines if you want to attach events to pointermove
  119946. */
  119947. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  119948. /** Detaches all event handlers*/
  119949. detachControl(): void;
  119950. /**
  119951. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  119952. * Delay loaded resources are not taking in account
  119953. * @return true if all required resources are ready
  119954. */
  119955. isReady(): boolean;
  119956. /** Resets all cached information relative to material (including effect and visibility) */
  119957. resetCachedMaterial(): void;
  119958. /**
  119959. * Registers a function to be called before every frame render
  119960. * @param func defines the function to register
  119961. */
  119962. registerBeforeRender(func: () => void): void;
  119963. /**
  119964. * Unregisters a function called before every frame render
  119965. * @param func defines the function to unregister
  119966. */
  119967. unregisterBeforeRender(func: () => void): void;
  119968. /**
  119969. * Registers a function to be called after every frame render
  119970. * @param func defines the function to register
  119971. */
  119972. registerAfterRender(func: () => void): void;
  119973. /**
  119974. * Unregisters a function called after every frame render
  119975. * @param func defines the function to unregister
  119976. */
  119977. unregisterAfterRender(func: () => void): void;
  119978. private _executeOnceBeforeRender;
  119979. /**
  119980. * The provided function will run before render once and will be disposed afterwards.
  119981. * A timeout delay can be provided so that the function will be executed in N ms.
  119982. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  119983. * @param func The function to be executed.
  119984. * @param timeout optional delay in ms
  119985. */
  119986. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  119987. /** @hidden */
  119988. _addPendingData(data: any): void;
  119989. /** @hidden */
  119990. _removePendingData(data: any): void;
  119991. /**
  119992. * Returns the number of items waiting to be loaded
  119993. * @returns the number of items waiting to be loaded
  119994. */
  119995. getWaitingItemsCount(): number;
  119996. /**
  119997. * Returns a boolean indicating if the scene is still loading data
  119998. */
  119999. get isLoading(): boolean;
  120000. /**
  120001. * Registers a function to be executed when the scene is ready
  120002. * @param {Function} func - the function to be executed
  120003. */
  120004. executeWhenReady(func: () => void): void;
  120005. /**
  120006. * Returns a promise that resolves when the scene is ready
  120007. * @returns A promise that resolves when the scene is ready
  120008. */
  120009. whenReadyAsync(): Promise<void>;
  120010. /** @hidden */
  120011. _checkIsReady(): void;
  120012. /**
  120013. * Gets all animatable attached to the scene
  120014. */
  120015. get animatables(): Animatable[];
  120016. /**
  120017. * Resets the last animation time frame.
  120018. * Useful to override when animations start running when loading a scene for the first time.
  120019. */
  120020. resetLastAnimationTimeFrame(): void;
  120021. /**
  120022. * Gets the current view matrix
  120023. * @returns a Matrix
  120024. */
  120025. getViewMatrix(): Matrix;
  120026. /**
  120027. * Gets the current projection matrix
  120028. * @returns a Matrix
  120029. */
  120030. getProjectionMatrix(): Matrix;
  120031. /**
  120032. * Gets the current transform matrix
  120033. * @returns a Matrix made of View * Projection
  120034. */
  120035. getTransformMatrix(): Matrix;
  120036. /**
  120037. * Sets the current transform matrix
  120038. * @param viewL defines the View matrix to use
  120039. * @param projectionL defines the Projection matrix to use
  120040. * @param viewR defines the right View matrix to use (if provided)
  120041. * @param projectionR defines the right Projection matrix to use (if provided)
  120042. */
  120043. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  120044. /**
  120045. * Gets the uniform buffer used to store scene data
  120046. * @returns a UniformBuffer
  120047. */
  120048. getSceneUniformBuffer(): UniformBuffer;
  120049. /**
  120050. * Gets an unique (relatively to the current scene) Id
  120051. * @returns an unique number for the scene
  120052. */
  120053. getUniqueId(): number;
  120054. /**
  120055. * Add a mesh to the list of scene's meshes
  120056. * @param newMesh defines the mesh to add
  120057. * @param recursive if all child meshes should also be added to the scene
  120058. */
  120059. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  120060. /**
  120061. * Remove a mesh for the list of scene's meshes
  120062. * @param toRemove defines the mesh to remove
  120063. * @param recursive if all child meshes should also be removed from the scene
  120064. * @returns the index where the mesh was in the mesh list
  120065. */
  120066. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  120067. /**
  120068. * Add a transform node to the list of scene's transform nodes
  120069. * @param newTransformNode defines the transform node to add
  120070. */
  120071. addTransformNode(newTransformNode: TransformNode): void;
  120072. /**
  120073. * Remove a transform node for the list of scene's transform nodes
  120074. * @param toRemove defines the transform node to remove
  120075. * @returns the index where the transform node was in the transform node list
  120076. */
  120077. removeTransformNode(toRemove: TransformNode): number;
  120078. /**
  120079. * Remove a skeleton for the list of scene's skeletons
  120080. * @param toRemove defines the skeleton to remove
  120081. * @returns the index where the skeleton was in the skeleton list
  120082. */
  120083. removeSkeleton(toRemove: Skeleton): number;
  120084. /**
  120085. * Remove a morph target for the list of scene's morph targets
  120086. * @param toRemove defines the morph target to remove
  120087. * @returns the index where the morph target was in the morph target list
  120088. */
  120089. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  120090. /**
  120091. * Remove a light for the list of scene's lights
  120092. * @param toRemove defines the light to remove
  120093. * @returns the index where the light was in the light list
  120094. */
  120095. removeLight(toRemove: Light): number;
  120096. /**
  120097. * Remove a camera for the list of scene's cameras
  120098. * @param toRemove defines the camera to remove
  120099. * @returns the index where the camera was in the camera list
  120100. */
  120101. removeCamera(toRemove: Camera): number;
  120102. /**
  120103. * Remove a particle system for the list of scene's particle systems
  120104. * @param toRemove defines the particle system to remove
  120105. * @returns the index where the particle system was in the particle system list
  120106. */
  120107. removeParticleSystem(toRemove: IParticleSystem): number;
  120108. /**
  120109. * Remove a animation for the list of scene's animations
  120110. * @param toRemove defines the animation to remove
  120111. * @returns the index where the animation was in the animation list
  120112. */
  120113. removeAnimation(toRemove: Animation): number;
  120114. /**
  120115. * Will stop the animation of the given target
  120116. * @param target - the target
  120117. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  120118. * @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)
  120119. */
  120120. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  120121. /**
  120122. * Removes the given animation group from this scene.
  120123. * @param toRemove The animation group to remove
  120124. * @returns The index of the removed animation group
  120125. */
  120126. removeAnimationGroup(toRemove: AnimationGroup): number;
  120127. /**
  120128. * Removes the given multi-material from this scene.
  120129. * @param toRemove The multi-material to remove
  120130. * @returns The index of the removed multi-material
  120131. */
  120132. removeMultiMaterial(toRemove: MultiMaterial): number;
  120133. /**
  120134. * Removes the given material from this scene.
  120135. * @param toRemove The material to remove
  120136. * @returns The index of the removed material
  120137. */
  120138. removeMaterial(toRemove: Material): number;
  120139. /**
  120140. * Removes the given action manager from this scene.
  120141. * @param toRemove The action manager to remove
  120142. * @returns The index of the removed action manager
  120143. */
  120144. removeActionManager(toRemove: AbstractActionManager): number;
  120145. /**
  120146. * Removes the given texture from this scene.
  120147. * @param toRemove The texture to remove
  120148. * @returns The index of the removed texture
  120149. */
  120150. removeTexture(toRemove: BaseTexture): number;
  120151. /**
  120152. * Adds the given light to this scene
  120153. * @param newLight The light to add
  120154. */
  120155. addLight(newLight: Light): void;
  120156. /**
  120157. * Sorts the list list based on light priorities
  120158. */
  120159. sortLightsByPriority(): void;
  120160. /**
  120161. * Adds the given camera to this scene
  120162. * @param newCamera The camera to add
  120163. */
  120164. addCamera(newCamera: Camera): void;
  120165. /**
  120166. * Adds the given skeleton to this scene
  120167. * @param newSkeleton The skeleton to add
  120168. */
  120169. addSkeleton(newSkeleton: Skeleton): void;
  120170. /**
  120171. * Adds the given particle system to this scene
  120172. * @param newParticleSystem The particle system to add
  120173. */
  120174. addParticleSystem(newParticleSystem: IParticleSystem): void;
  120175. /**
  120176. * Adds the given animation to this scene
  120177. * @param newAnimation The animation to add
  120178. */
  120179. addAnimation(newAnimation: Animation): void;
  120180. /**
  120181. * Adds the given animation group to this scene.
  120182. * @param newAnimationGroup The animation group to add
  120183. */
  120184. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  120185. /**
  120186. * Adds the given multi-material to this scene
  120187. * @param newMultiMaterial The multi-material to add
  120188. */
  120189. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  120190. /**
  120191. * Adds the given material to this scene
  120192. * @param newMaterial The material to add
  120193. */
  120194. addMaterial(newMaterial: Material): void;
  120195. /**
  120196. * Adds the given morph target to this scene
  120197. * @param newMorphTargetManager The morph target to add
  120198. */
  120199. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  120200. /**
  120201. * Adds the given geometry to this scene
  120202. * @param newGeometry The geometry to add
  120203. */
  120204. addGeometry(newGeometry: Geometry): void;
  120205. /**
  120206. * Adds the given action manager to this scene
  120207. * @param newActionManager The action manager to add
  120208. */
  120209. addActionManager(newActionManager: AbstractActionManager): void;
  120210. /**
  120211. * Adds the given texture to this scene.
  120212. * @param newTexture The texture to add
  120213. */
  120214. addTexture(newTexture: BaseTexture): void;
  120215. /**
  120216. * Switch active camera
  120217. * @param newCamera defines the new active camera
  120218. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  120219. */
  120220. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  120221. /**
  120222. * sets the active camera of the scene using its ID
  120223. * @param id defines the camera's ID
  120224. * @return the new active camera or null if none found.
  120225. */
  120226. setActiveCameraByID(id: string): Nullable<Camera>;
  120227. /**
  120228. * sets the active camera of the scene using its name
  120229. * @param name defines the camera's name
  120230. * @returns the new active camera or null if none found.
  120231. */
  120232. setActiveCameraByName(name: string): Nullable<Camera>;
  120233. /**
  120234. * get an animation group using its name
  120235. * @param name defines the material's name
  120236. * @return the animation group or null if none found.
  120237. */
  120238. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  120239. /**
  120240. * Get a material using its unique id
  120241. * @param uniqueId defines the material's unique id
  120242. * @return the material or null if none found.
  120243. */
  120244. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  120245. /**
  120246. * get a material using its id
  120247. * @param id defines the material's ID
  120248. * @return the material or null if none found.
  120249. */
  120250. getMaterialByID(id: string): Nullable<Material>;
  120251. /**
  120252. * Gets a the last added material using a given id
  120253. * @param id defines the material's ID
  120254. * @return the last material with the given id or null if none found.
  120255. */
  120256. getLastMaterialByID(id: string): Nullable<Material>;
  120257. /**
  120258. * Gets a material using its name
  120259. * @param name defines the material's name
  120260. * @return the material or null if none found.
  120261. */
  120262. getMaterialByName(name: string): Nullable<Material>;
  120263. /**
  120264. * Get a texture using its unique id
  120265. * @param uniqueId defines the texture's unique id
  120266. * @return the texture or null if none found.
  120267. */
  120268. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  120269. /**
  120270. * Gets a camera using its id
  120271. * @param id defines the id to look for
  120272. * @returns the camera or null if not found
  120273. */
  120274. getCameraByID(id: string): Nullable<Camera>;
  120275. /**
  120276. * Gets a camera using its unique id
  120277. * @param uniqueId defines the unique id to look for
  120278. * @returns the camera or null if not found
  120279. */
  120280. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  120281. /**
  120282. * Gets a camera using its name
  120283. * @param name defines the camera's name
  120284. * @return the camera or null if none found.
  120285. */
  120286. getCameraByName(name: string): Nullable<Camera>;
  120287. /**
  120288. * Gets a bone using its id
  120289. * @param id defines the bone's id
  120290. * @return the bone or null if not found
  120291. */
  120292. getBoneByID(id: string): Nullable<Bone>;
  120293. /**
  120294. * Gets a bone using its id
  120295. * @param name defines the bone's name
  120296. * @return the bone or null if not found
  120297. */
  120298. getBoneByName(name: string): Nullable<Bone>;
  120299. /**
  120300. * Gets a light node using its name
  120301. * @param name defines the the light's name
  120302. * @return the light or null if none found.
  120303. */
  120304. getLightByName(name: string): Nullable<Light>;
  120305. /**
  120306. * Gets a light node using its id
  120307. * @param id defines the light's id
  120308. * @return the light or null if none found.
  120309. */
  120310. getLightByID(id: string): Nullable<Light>;
  120311. /**
  120312. * Gets a light node using its scene-generated unique ID
  120313. * @param uniqueId defines the light's unique id
  120314. * @return the light or null if none found.
  120315. */
  120316. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  120317. /**
  120318. * Gets a particle system by id
  120319. * @param id defines the particle system id
  120320. * @return the corresponding system or null if none found
  120321. */
  120322. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  120323. /**
  120324. * Gets a geometry using its ID
  120325. * @param id defines the geometry's id
  120326. * @return the geometry or null if none found.
  120327. */
  120328. getGeometryByID(id: string): Nullable<Geometry>;
  120329. private _getGeometryByUniqueID;
  120330. /**
  120331. * Add a new geometry to this scene
  120332. * @param geometry defines the geometry to be added to the scene.
  120333. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  120334. * @return a boolean defining if the geometry was added or not
  120335. */
  120336. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  120337. /**
  120338. * Removes an existing geometry
  120339. * @param geometry defines the geometry to be removed from the scene
  120340. * @return a boolean defining if the geometry was removed or not
  120341. */
  120342. removeGeometry(geometry: Geometry): boolean;
  120343. /**
  120344. * Gets the list of geometries attached to the scene
  120345. * @returns an array of Geometry
  120346. */
  120347. getGeometries(): Geometry[];
  120348. /**
  120349. * Gets the first added mesh found of a given ID
  120350. * @param id defines the id to search for
  120351. * @return the mesh found or null if not found at all
  120352. */
  120353. getMeshByID(id: string): Nullable<AbstractMesh>;
  120354. /**
  120355. * Gets a list of meshes using their id
  120356. * @param id defines the id to search for
  120357. * @returns a list of meshes
  120358. */
  120359. getMeshesByID(id: string): Array<AbstractMesh>;
  120360. /**
  120361. * Gets the first added transform node found of a given ID
  120362. * @param id defines the id to search for
  120363. * @return the found transform node or null if not found at all.
  120364. */
  120365. getTransformNodeByID(id: string): Nullable<TransformNode>;
  120366. /**
  120367. * Gets a transform node with its auto-generated unique id
  120368. * @param uniqueId efines the unique id to search for
  120369. * @return the found transform node or null if not found at all.
  120370. */
  120371. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  120372. /**
  120373. * Gets a list of transform nodes using their id
  120374. * @param id defines the id to search for
  120375. * @returns a list of transform nodes
  120376. */
  120377. getTransformNodesByID(id: string): Array<TransformNode>;
  120378. /**
  120379. * Gets a mesh with its auto-generated unique id
  120380. * @param uniqueId defines the unique id to search for
  120381. * @return the found mesh or null if not found at all.
  120382. */
  120383. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  120384. /**
  120385. * Gets a the last added mesh using a given id
  120386. * @param id defines the id to search for
  120387. * @return the found mesh or null if not found at all.
  120388. */
  120389. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  120390. /**
  120391. * Gets a the last added node (Mesh, Camera, Light) using a given id
  120392. * @param id defines the id to search for
  120393. * @return the found node or null if not found at all
  120394. */
  120395. getLastEntryByID(id: string): Nullable<Node>;
  120396. /**
  120397. * Gets a node (Mesh, Camera, Light) using a given id
  120398. * @param id defines the id to search for
  120399. * @return the found node or null if not found at all
  120400. */
  120401. getNodeByID(id: string): Nullable<Node>;
  120402. /**
  120403. * Gets a node (Mesh, Camera, Light) using a given name
  120404. * @param name defines the name to search for
  120405. * @return the found node or null if not found at all.
  120406. */
  120407. getNodeByName(name: string): Nullable<Node>;
  120408. /**
  120409. * Gets a mesh using a given name
  120410. * @param name defines the name to search for
  120411. * @return the found mesh or null if not found at all.
  120412. */
  120413. getMeshByName(name: string): Nullable<AbstractMesh>;
  120414. /**
  120415. * Gets a transform node using a given name
  120416. * @param name defines the name to search for
  120417. * @return the found transform node or null if not found at all.
  120418. */
  120419. getTransformNodeByName(name: string): Nullable<TransformNode>;
  120420. /**
  120421. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  120422. * @param id defines the id to search for
  120423. * @return the found skeleton or null if not found at all.
  120424. */
  120425. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  120426. /**
  120427. * Gets a skeleton using a given auto generated unique id
  120428. * @param uniqueId defines the unique id to search for
  120429. * @return the found skeleton or null if not found at all.
  120430. */
  120431. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  120432. /**
  120433. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  120434. * @param id defines the id to search for
  120435. * @return the found skeleton or null if not found at all.
  120436. */
  120437. getSkeletonById(id: string): Nullable<Skeleton>;
  120438. /**
  120439. * Gets a skeleton using a given name
  120440. * @param name defines the name to search for
  120441. * @return the found skeleton or null if not found at all.
  120442. */
  120443. getSkeletonByName(name: string): Nullable<Skeleton>;
  120444. /**
  120445. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  120446. * @param id defines the id to search for
  120447. * @return the found morph target manager or null if not found at all.
  120448. */
  120449. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  120450. /**
  120451. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  120452. * @param id defines the id to search for
  120453. * @return the found morph target or null if not found at all.
  120454. */
  120455. getMorphTargetById(id: string): Nullable<MorphTarget>;
  120456. /**
  120457. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  120458. * @param name defines the name to search for
  120459. * @return the found morph target or null if not found at all.
  120460. */
  120461. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  120462. /**
  120463. * Gets a post process using a given name (if many are found, this function will pick the first one)
  120464. * @param name defines the name to search for
  120465. * @return the found post process or null if not found at all.
  120466. */
  120467. getPostProcessByName(name: string): Nullable<PostProcess>;
  120468. /**
  120469. * Gets a boolean indicating if the given mesh is active
  120470. * @param mesh defines the mesh to look for
  120471. * @returns true if the mesh is in the active list
  120472. */
  120473. isActiveMesh(mesh: AbstractMesh): boolean;
  120474. /**
  120475. * Return a unique id as a string which can serve as an identifier for the scene
  120476. */
  120477. get uid(): string;
  120478. /**
  120479. * Add an externaly attached data from its key.
  120480. * This method call will fail and return false, if such key already exists.
  120481. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  120482. * @param key the unique key that identifies the data
  120483. * @param data the data object to associate to the key for this Engine instance
  120484. * @return true if no such key were already present and the data was added successfully, false otherwise
  120485. */
  120486. addExternalData<T>(key: string, data: T): boolean;
  120487. /**
  120488. * Get an externaly attached data from its key
  120489. * @param key the unique key that identifies the data
  120490. * @return the associated data, if present (can be null), or undefined if not present
  120491. */
  120492. getExternalData<T>(key: string): Nullable<T>;
  120493. /**
  120494. * Get an externaly attached data from its key, create it using a factory if it's not already present
  120495. * @param key the unique key that identifies the data
  120496. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  120497. * @return the associated data, can be null if the factory returned null.
  120498. */
  120499. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  120500. /**
  120501. * Remove an externaly attached data from the Engine instance
  120502. * @param key the unique key that identifies the data
  120503. * @return true if the data was successfully removed, false if it doesn't exist
  120504. */
  120505. removeExternalData(key: string): boolean;
  120506. private _evaluateSubMesh;
  120507. /**
  120508. * Clear the processed materials smart array preventing retention point in material dispose.
  120509. */
  120510. freeProcessedMaterials(): void;
  120511. private _preventFreeActiveMeshesAndRenderingGroups;
  120512. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  120513. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  120514. * when disposing several meshes in a row or a hierarchy of meshes.
  120515. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  120516. */
  120517. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  120518. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  120519. /**
  120520. * Clear the active meshes smart array preventing retention point in mesh dispose.
  120521. */
  120522. freeActiveMeshes(): void;
  120523. /**
  120524. * Clear the info related to rendering groups preventing retention points during dispose.
  120525. */
  120526. freeRenderingGroups(): void;
  120527. /** @hidden */
  120528. _isInIntermediateRendering(): boolean;
  120529. /**
  120530. * Lambda returning the list of potentially active meshes.
  120531. */
  120532. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  120533. /**
  120534. * Lambda returning the list of potentially active sub meshes.
  120535. */
  120536. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  120537. /**
  120538. * Lambda returning the list of potentially intersecting sub meshes.
  120539. */
  120540. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  120541. /**
  120542. * Lambda returning the list of potentially colliding sub meshes.
  120543. */
  120544. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  120545. private _activeMeshesFrozen;
  120546. private _skipEvaluateActiveMeshesCompletely;
  120547. /**
  120548. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  120549. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  120550. * @returns the current scene
  120551. */
  120552. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  120553. /**
  120554. * Use this function to restart evaluating active meshes on every frame
  120555. * @returns the current scene
  120556. */
  120557. unfreezeActiveMeshes(): Scene;
  120558. private _evaluateActiveMeshes;
  120559. private _activeMesh;
  120560. /**
  120561. * Update the transform matrix to update from the current active camera
  120562. * @param force defines a boolean used to force the update even if cache is up to date
  120563. */
  120564. updateTransformMatrix(force?: boolean): void;
  120565. private _bindFrameBuffer;
  120566. /** @hidden */
  120567. _allowPostProcessClearColor: boolean;
  120568. /** @hidden */
  120569. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  120570. private _processSubCameras;
  120571. private _checkIntersections;
  120572. /** @hidden */
  120573. _advancePhysicsEngineStep(step: number): void;
  120574. /**
  120575. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  120576. */
  120577. getDeterministicFrameTime: () => number;
  120578. /** @hidden */
  120579. _animate(): void;
  120580. /** Execute all animations (for a frame) */
  120581. animate(): void;
  120582. /**
  120583. * Render the scene
  120584. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  120585. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  120586. */
  120587. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  120588. /**
  120589. * Freeze all materials
  120590. * A frozen material will not be updatable but should be faster to render
  120591. */
  120592. freezeMaterials(): void;
  120593. /**
  120594. * Unfreeze all materials
  120595. * A frozen material will not be updatable but should be faster to render
  120596. */
  120597. unfreezeMaterials(): void;
  120598. /**
  120599. * Releases all held ressources
  120600. */
  120601. dispose(): void;
  120602. /**
  120603. * Gets if the scene is already disposed
  120604. */
  120605. get isDisposed(): boolean;
  120606. /**
  120607. * Call this function to reduce memory footprint of the scene.
  120608. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  120609. */
  120610. clearCachedVertexData(): void;
  120611. /**
  120612. * This function will remove the local cached buffer data from texture.
  120613. * It will save memory but will prevent the texture from being rebuilt
  120614. */
  120615. cleanCachedTextureBuffer(): void;
  120616. /**
  120617. * Get the world extend vectors with an optional filter
  120618. *
  120619. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  120620. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  120621. */
  120622. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  120623. min: Vector3;
  120624. max: Vector3;
  120625. };
  120626. /**
  120627. * Creates a ray that can be used to pick in the scene
  120628. * @param x defines the x coordinate of the origin (on-screen)
  120629. * @param y defines the y coordinate of the origin (on-screen)
  120630. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  120631. * @param camera defines the camera to use for the picking
  120632. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  120633. * @returns a Ray
  120634. */
  120635. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  120636. /**
  120637. * Creates a ray that can be used to pick in the scene
  120638. * @param x defines the x coordinate of the origin (on-screen)
  120639. * @param y defines the y coordinate of the origin (on-screen)
  120640. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  120641. * @param result defines the ray where to store the picking ray
  120642. * @param camera defines the camera to use for the picking
  120643. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  120644. * @returns the current scene
  120645. */
  120646. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  120647. /**
  120648. * Creates a ray that can be used to pick in the scene
  120649. * @param x defines the x coordinate of the origin (on-screen)
  120650. * @param y defines the y coordinate of the origin (on-screen)
  120651. * @param camera defines the camera to use for the picking
  120652. * @returns a Ray
  120653. */
  120654. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  120655. /**
  120656. * Creates a ray that can be used to pick in the scene
  120657. * @param x defines the x coordinate of the origin (on-screen)
  120658. * @param y defines the y coordinate of the origin (on-screen)
  120659. * @param result defines the ray where to store the picking ray
  120660. * @param camera defines the camera to use for the picking
  120661. * @returns the current scene
  120662. */
  120663. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  120664. /** Launch a ray to try to pick a mesh in the scene
  120665. * @param x position on screen
  120666. * @param y position on screen
  120667. * @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
  120668. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120669. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120670. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120671. * @returns a PickingInfo
  120672. */
  120673. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  120674. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  120675. * @param x position on screen
  120676. * @param y position on screen
  120677. * @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
  120678. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120679. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120680. * @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)
  120681. */
  120682. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  120683. /** Use the given ray to pick a mesh in the scene
  120684. * @param ray The ray to use to pick meshes
  120685. * @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
  120686. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120687. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120688. * @returns a PickingInfo
  120689. */
  120690. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  120691. /**
  120692. * Launch a ray to try to pick a mesh in the scene
  120693. * @param x X position on screen
  120694. * @param y Y position on screen
  120695. * @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
  120696. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120697. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120698. * @returns an array of PickingInfo
  120699. */
  120700. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  120701. /**
  120702. * Launch a ray to try to pick a mesh in the scene
  120703. * @param ray Ray to use
  120704. * @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
  120705. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120706. * @returns an array of PickingInfo
  120707. */
  120708. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  120709. /**
  120710. * Force the value of meshUnderPointer
  120711. * @param mesh defines the mesh to use
  120712. */
  120713. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  120714. /**
  120715. * Gets the mesh under the pointer
  120716. * @returns a Mesh or null if no mesh is under the pointer
  120717. */
  120718. getPointerOverMesh(): Nullable<AbstractMesh>;
  120719. /** @hidden */
  120720. _rebuildGeometries(): void;
  120721. /** @hidden */
  120722. _rebuildTextures(): void;
  120723. private _getByTags;
  120724. /**
  120725. * Get a list of meshes by tags
  120726. * @param tagsQuery defines the tags query to use
  120727. * @param forEach defines a predicate used to filter results
  120728. * @returns an array of Mesh
  120729. */
  120730. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  120731. /**
  120732. * Get a list of cameras by tags
  120733. * @param tagsQuery defines the tags query to use
  120734. * @param forEach defines a predicate used to filter results
  120735. * @returns an array of Camera
  120736. */
  120737. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  120738. /**
  120739. * Get a list of lights by tags
  120740. * @param tagsQuery defines the tags query to use
  120741. * @param forEach defines a predicate used to filter results
  120742. * @returns an array of Light
  120743. */
  120744. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  120745. /**
  120746. * Get a list of materials by tags
  120747. * @param tagsQuery defines the tags query to use
  120748. * @param forEach defines a predicate used to filter results
  120749. * @returns an array of Material
  120750. */
  120751. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  120752. /**
  120753. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  120754. * This allowed control for front to back rendering or reversly depending of the special needs.
  120755. *
  120756. * @param renderingGroupId The rendering group id corresponding to its index
  120757. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  120758. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  120759. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  120760. */
  120761. 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;
  120762. /**
  120763. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  120764. *
  120765. * @param renderingGroupId The rendering group id corresponding to its index
  120766. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120767. * @param depth Automatically clears depth between groups if true and autoClear is true.
  120768. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  120769. */
  120770. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  120771. /**
  120772. * Gets the current auto clear configuration for one rendering group of the rendering
  120773. * manager.
  120774. * @param index the rendering group index to get the information for
  120775. * @returns The auto clear setup for the requested rendering group
  120776. */
  120777. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  120778. private _blockMaterialDirtyMechanism;
  120779. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  120780. get blockMaterialDirtyMechanism(): boolean;
  120781. set blockMaterialDirtyMechanism(value: boolean);
  120782. /**
  120783. * Will flag all materials as dirty to trigger new shader compilation
  120784. * @param flag defines the flag used to specify which material part must be marked as dirty
  120785. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  120786. */
  120787. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  120788. /** @hidden */
  120789. _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;
  120790. /** @hidden */
  120791. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  120792. /** @hidden */
  120793. _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;
  120794. /** @hidden */
  120795. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  120796. /** @hidden */
  120797. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  120798. /** @hidden */
  120799. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  120800. }
  120801. }
  120802. declare module BABYLON {
  120803. /**
  120804. * Set of assets to keep when moving a scene into an asset container.
  120805. */
  120806. export class KeepAssets extends AbstractScene {
  120807. }
  120808. /**
  120809. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  120810. */
  120811. export class InstantiatedEntries {
  120812. /**
  120813. * List of new root nodes (eg. nodes with no parent)
  120814. */
  120815. rootNodes: TransformNode[];
  120816. /**
  120817. * List of new skeletons
  120818. */
  120819. skeletons: Skeleton[];
  120820. /**
  120821. * List of new animation groups
  120822. */
  120823. animationGroups: AnimationGroup[];
  120824. }
  120825. /**
  120826. * Container with a set of assets that can be added or removed from a scene.
  120827. */
  120828. export class AssetContainer extends AbstractScene {
  120829. private _wasAddedToScene;
  120830. /**
  120831. * The scene the AssetContainer belongs to.
  120832. */
  120833. scene: Scene;
  120834. /**
  120835. * Instantiates an AssetContainer.
  120836. * @param scene The scene the AssetContainer belongs to.
  120837. */
  120838. constructor(scene: Scene);
  120839. /**
  120840. * Instantiate or clone all meshes and add the new ones to the scene.
  120841. * Skeletons and animation groups will all be cloned
  120842. * @param nameFunction defines an optional function used to get new names for clones
  120843. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  120844. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  120845. */
  120846. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  120847. /**
  120848. * Adds all the assets from the container to the scene.
  120849. */
  120850. addAllToScene(): void;
  120851. /**
  120852. * Removes all the assets in the container from the scene
  120853. */
  120854. removeAllFromScene(): void;
  120855. /**
  120856. * Disposes all the assets in the container
  120857. */
  120858. dispose(): void;
  120859. private _moveAssets;
  120860. /**
  120861. * Removes all the assets contained in the scene and adds them to the container.
  120862. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  120863. */
  120864. moveAllFromScene(keepAssets?: KeepAssets): void;
  120865. /**
  120866. * 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.
  120867. * @returns the root mesh
  120868. */
  120869. createRootMesh(): Mesh;
  120870. /**
  120871. * Merge animations (direct and animation groups) from this asset container into a scene
  120872. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120873. * @param animatables set of animatables to retarget to a node from the scene
  120874. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  120875. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  120876. */
  120877. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  120878. }
  120879. }
  120880. declare module BABYLON {
  120881. /**
  120882. * Defines how the parser contract is defined.
  120883. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  120884. */
  120885. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  120886. /**
  120887. * Defines how the individual parser contract is defined.
  120888. * These parser can parse an individual asset
  120889. */
  120890. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  120891. /**
  120892. * Base class of the scene acting as a container for the different elements composing a scene.
  120893. * This class is dynamically extended by the different components of the scene increasing
  120894. * flexibility and reducing coupling
  120895. */
  120896. export abstract class AbstractScene {
  120897. /**
  120898. * Stores the list of available parsers in the application.
  120899. */
  120900. private static _BabylonFileParsers;
  120901. /**
  120902. * Stores the list of available individual parsers in the application.
  120903. */
  120904. private static _IndividualBabylonFileParsers;
  120905. /**
  120906. * Adds a parser in the list of available ones
  120907. * @param name Defines the name of the parser
  120908. * @param parser Defines the parser to add
  120909. */
  120910. static AddParser(name: string, parser: BabylonFileParser): void;
  120911. /**
  120912. * Gets a general parser from the list of avaialble ones
  120913. * @param name Defines the name of the parser
  120914. * @returns the requested parser or null
  120915. */
  120916. static GetParser(name: string): Nullable<BabylonFileParser>;
  120917. /**
  120918. * Adds n individual parser in the list of available ones
  120919. * @param name Defines the name of the parser
  120920. * @param parser Defines the parser to add
  120921. */
  120922. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  120923. /**
  120924. * Gets an individual parser from the list of avaialble ones
  120925. * @param name Defines the name of the parser
  120926. * @returns the requested parser or null
  120927. */
  120928. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  120929. /**
  120930. * Parser json data and populate both a scene and its associated container object
  120931. * @param jsonData Defines the data to parse
  120932. * @param scene Defines the scene to parse the data for
  120933. * @param container Defines the container attached to the parsing sequence
  120934. * @param rootUrl Defines the root url of the data
  120935. */
  120936. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  120937. /**
  120938. * Gets the list of root nodes (ie. nodes with no parent)
  120939. */
  120940. rootNodes: Node[];
  120941. /** All of the cameras added to this scene
  120942. * @see https://doc.babylonjs.com/babylon101/cameras
  120943. */
  120944. cameras: Camera[];
  120945. /**
  120946. * All of the lights added to this scene
  120947. * @see https://doc.babylonjs.com/babylon101/lights
  120948. */
  120949. lights: Light[];
  120950. /**
  120951. * All of the (abstract) meshes added to this scene
  120952. */
  120953. meshes: AbstractMesh[];
  120954. /**
  120955. * The list of skeletons added to the scene
  120956. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  120957. */
  120958. skeletons: Skeleton[];
  120959. /**
  120960. * All of the particle systems added to this scene
  120961. * @see https://doc.babylonjs.com/babylon101/particles
  120962. */
  120963. particleSystems: IParticleSystem[];
  120964. /**
  120965. * Gets a list of Animations associated with the scene
  120966. */
  120967. animations: Animation[];
  120968. /**
  120969. * All of the animation groups added to this scene
  120970. * @see https://doc.babylonjs.com/how_to/group
  120971. */
  120972. animationGroups: AnimationGroup[];
  120973. /**
  120974. * All of the multi-materials added to this scene
  120975. * @see https://doc.babylonjs.com/how_to/multi_materials
  120976. */
  120977. multiMaterials: MultiMaterial[];
  120978. /**
  120979. * All of the materials added to this scene
  120980. * In the context of a Scene, it is not supposed to be modified manually.
  120981. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  120982. * Note also that the order of the Material within the array is not significant and might change.
  120983. * @see https://doc.babylonjs.com/babylon101/materials
  120984. */
  120985. materials: Material[];
  120986. /**
  120987. * The list of morph target managers added to the scene
  120988. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  120989. */
  120990. morphTargetManagers: MorphTargetManager[];
  120991. /**
  120992. * The list of geometries used in the scene.
  120993. */
  120994. geometries: Geometry[];
  120995. /**
  120996. * All of the tranform nodes added to this scene
  120997. * In the context of a Scene, it is not supposed to be modified manually.
  120998. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  120999. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  121000. * @see https://doc.babylonjs.com/how_to/transformnode
  121001. */
  121002. transformNodes: TransformNode[];
  121003. /**
  121004. * ActionManagers available on the scene.
  121005. */
  121006. actionManagers: AbstractActionManager[];
  121007. /**
  121008. * Textures to keep.
  121009. */
  121010. textures: BaseTexture[];
  121011. /**
  121012. * Environment texture for the scene
  121013. */
  121014. environmentTexture: Nullable<BaseTexture>;
  121015. /**
  121016. * The list of postprocesses added to the scene
  121017. */
  121018. postProcesses: PostProcess[];
  121019. /**
  121020. * @returns all meshes, lights, cameras, transformNodes and bones
  121021. */
  121022. getNodes(): Array<Node>;
  121023. }
  121024. }
  121025. declare module BABYLON {
  121026. /**
  121027. * Interface used to define options for Sound class
  121028. */
  121029. export interface ISoundOptions {
  121030. /**
  121031. * Does the sound autoplay once loaded.
  121032. */
  121033. autoplay?: boolean;
  121034. /**
  121035. * Does the sound loop after it finishes playing once.
  121036. */
  121037. loop?: boolean;
  121038. /**
  121039. * Sound's volume
  121040. */
  121041. volume?: number;
  121042. /**
  121043. * Is it a spatial sound?
  121044. */
  121045. spatialSound?: boolean;
  121046. /**
  121047. * Maximum distance to hear that sound
  121048. */
  121049. maxDistance?: number;
  121050. /**
  121051. * Uses user defined attenuation function
  121052. */
  121053. useCustomAttenuation?: boolean;
  121054. /**
  121055. * Define the roll off factor of spatial sounds.
  121056. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121057. */
  121058. rolloffFactor?: number;
  121059. /**
  121060. * Define the reference distance the sound should be heard perfectly.
  121061. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121062. */
  121063. refDistance?: number;
  121064. /**
  121065. * Define the distance attenuation model the sound will follow.
  121066. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121067. */
  121068. distanceModel?: string;
  121069. /**
  121070. * Defines the playback speed (1 by default)
  121071. */
  121072. playbackRate?: number;
  121073. /**
  121074. * Defines if the sound is from a streaming source
  121075. */
  121076. streaming?: boolean;
  121077. /**
  121078. * Defines an optional length (in seconds) inside the sound file
  121079. */
  121080. length?: number;
  121081. /**
  121082. * Defines an optional offset (in seconds) inside the sound file
  121083. */
  121084. offset?: number;
  121085. /**
  121086. * If true, URLs will not be required to state the audio file codec to use.
  121087. */
  121088. skipCodecCheck?: boolean;
  121089. }
  121090. /**
  121091. * Defines a sound that can be played in the application.
  121092. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  121093. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121094. */
  121095. export class Sound {
  121096. /**
  121097. * The name of the sound in the scene.
  121098. */
  121099. name: string;
  121100. /**
  121101. * Does the sound autoplay once loaded.
  121102. */
  121103. autoplay: boolean;
  121104. /**
  121105. * Does the sound loop after it finishes playing once.
  121106. */
  121107. loop: boolean;
  121108. /**
  121109. * Does the sound use a custom attenuation curve to simulate the falloff
  121110. * happening when the source gets further away from the camera.
  121111. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121112. */
  121113. useCustomAttenuation: boolean;
  121114. /**
  121115. * The sound track id this sound belongs to.
  121116. */
  121117. soundTrackId: number;
  121118. /**
  121119. * Is this sound currently played.
  121120. */
  121121. isPlaying: boolean;
  121122. /**
  121123. * Is this sound currently paused.
  121124. */
  121125. isPaused: boolean;
  121126. /**
  121127. * Does this sound enables spatial sound.
  121128. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121129. */
  121130. spatialSound: boolean;
  121131. /**
  121132. * Define the reference distance the sound should be heard perfectly.
  121133. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121134. */
  121135. refDistance: number;
  121136. /**
  121137. * Define the roll off factor of spatial sounds.
  121138. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121139. */
  121140. rolloffFactor: number;
  121141. /**
  121142. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  121143. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121144. */
  121145. maxDistance: number;
  121146. /**
  121147. * Define the distance attenuation model the sound will follow.
  121148. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121149. */
  121150. distanceModel: string;
  121151. /**
  121152. * @hidden
  121153. * Back Compat
  121154. **/
  121155. onended: () => any;
  121156. /**
  121157. * Gets or sets an object used to store user defined information for the sound.
  121158. */
  121159. metadata: any;
  121160. /**
  121161. * Observable event when the current playing sound finishes.
  121162. */
  121163. onEndedObservable: Observable<Sound>;
  121164. private _panningModel;
  121165. private _playbackRate;
  121166. private _streaming;
  121167. private _startTime;
  121168. private _startOffset;
  121169. private _position;
  121170. /** @hidden */
  121171. _positionInEmitterSpace: boolean;
  121172. private _localDirection;
  121173. private _volume;
  121174. private _isReadyToPlay;
  121175. private _isDirectional;
  121176. private _readyToPlayCallback;
  121177. private _audioBuffer;
  121178. private _soundSource;
  121179. private _streamingSource;
  121180. private _soundPanner;
  121181. private _soundGain;
  121182. private _inputAudioNode;
  121183. private _outputAudioNode;
  121184. private _coneInnerAngle;
  121185. private _coneOuterAngle;
  121186. private _coneOuterGain;
  121187. private _scene;
  121188. private _connectedTransformNode;
  121189. private _customAttenuationFunction;
  121190. private _registerFunc;
  121191. private _isOutputConnected;
  121192. private _htmlAudioElement;
  121193. private _urlType;
  121194. private _length?;
  121195. private _offset?;
  121196. /** @hidden */
  121197. static _SceneComponentInitialization: (scene: Scene) => void;
  121198. /**
  121199. * Create a sound and attach it to a scene
  121200. * @param name Name of your sound
  121201. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  121202. * @param scene defines the scene the sound belongs to
  121203. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  121204. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  121205. */
  121206. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  121207. /**
  121208. * Release the sound and its associated resources
  121209. */
  121210. dispose(): void;
  121211. /**
  121212. * Gets if the sounds is ready to be played or not.
  121213. * @returns true if ready, otherwise false
  121214. */
  121215. isReady(): boolean;
  121216. private _soundLoaded;
  121217. /**
  121218. * Sets the data of the sound from an audiobuffer
  121219. * @param audioBuffer The audioBuffer containing the data
  121220. */
  121221. setAudioBuffer(audioBuffer: AudioBuffer): void;
  121222. /**
  121223. * Updates the current sounds options such as maxdistance, loop...
  121224. * @param options A JSON object containing values named as the object properties
  121225. */
  121226. updateOptions(options: ISoundOptions): void;
  121227. private _createSpatialParameters;
  121228. private _updateSpatialParameters;
  121229. /**
  121230. * Switch the panning model to HRTF:
  121231. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  121232. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121233. */
  121234. switchPanningModelToHRTF(): void;
  121235. /**
  121236. * Switch the panning model to Equal Power:
  121237. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  121238. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121239. */
  121240. switchPanningModelToEqualPower(): void;
  121241. private _switchPanningModel;
  121242. /**
  121243. * Connect this sound to a sound track audio node like gain...
  121244. * @param soundTrackAudioNode the sound track audio node to connect to
  121245. */
  121246. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  121247. /**
  121248. * Transform this sound into a directional source
  121249. * @param coneInnerAngle Size of the inner cone in degree
  121250. * @param coneOuterAngle Size of the outer cone in degree
  121251. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  121252. */
  121253. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  121254. /**
  121255. * Gets or sets the inner angle for the directional cone.
  121256. */
  121257. get directionalConeInnerAngle(): number;
  121258. /**
  121259. * Gets or sets the inner angle for the directional cone.
  121260. */
  121261. set directionalConeInnerAngle(value: number);
  121262. /**
  121263. * Gets or sets the outer angle for the directional cone.
  121264. */
  121265. get directionalConeOuterAngle(): number;
  121266. /**
  121267. * Gets or sets the outer angle for the directional cone.
  121268. */
  121269. set directionalConeOuterAngle(value: number);
  121270. /**
  121271. * Sets the position of the emitter if spatial sound is enabled
  121272. * @param newPosition Defines the new posisiton
  121273. */
  121274. setPosition(newPosition: Vector3): void;
  121275. /**
  121276. * Sets the local direction of the emitter if spatial sound is enabled
  121277. * @param newLocalDirection Defines the new local direction
  121278. */
  121279. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  121280. private _updateDirection;
  121281. /** @hidden */
  121282. updateDistanceFromListener(): void;
  121283. /**
  121284. * Sets a new custom attenuation function for the sound.
  121285. * @param callback Defines the function used for the attenuation
  121286. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121287. */
  121288. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  121289. /**
  121290. * Play the sound
  121291. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  121292. * @param offset (optional) Start the sound at a specific time in seconds
  121293. * @param length (optional) Sound duration (in seconds)
  121294. */
  121295. play(time?: number, offset?: number, length?: number): void;
  121296. private _onended;
  121297. /**
  121298. * Stop the sound
  121299. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  121300. */
  121301. stop(time?: number): void;
  121302. /**
  121303. * Put the sound in pause
  121304. */
  121305. pause(): void;
  121306. /**
  121307. * Sets a dedicated volume for this sounds
  121308. * @param newVolume Define the new volume of the sound
  121309. * @param time Define time for gradual change to new volume
  121310. */
  121311. setVolume(newVolume: number, time?: number): void;
  121312. /**
  121313. * Set the sound play back rate
  121314. * @param newPlaybackRate Define the playback rate the sound should be played at
  121315. */
  121316. setPlaybackRate(newPlaybackRate: number): void;
  121317. /**
  121318. * Gets the volume of the sound.
  121319. * @returns the volume of the sound
  121320. */
  121321. getVolume(): number;
  121322. /**
  121323. * Attach the sound to a dedicated mesh
  121324. * @param transformNode The transform node to connect the sound with
  121325. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  121326. */
  121327. attachToMesh(transformNode: TransformNode): void;
  121328. /**
  121329. * Detach the sound from the previously attached mesh
  121330. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  121331. */
  121332. detachFromMesh(): void;
  121333. private _onRegisterAfterWorldMatrixUpdate;
  121334. /**
  121335. * Clone the current sound in the scene.
  121336. * @returns the new sound clone
  121337. */
  121338. clone(): Nullable<Sound>;
  121339. /**
  121340. * Gets the current underlying audio buffer containing the data
  121341. * @returns the audio buffer
  121342. */
  121343. getAudioBuffer(): Nullable<AudioBuffer>;
  121344. /**
  121345. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  121346. * @returns the source node
  121347. */
  121348. getSoundSource(): Nullable<AudioBufferSourceNode>;
  121349. /**
  121350. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  121351. * @returns the gain node
  121352. */
  121353. getSoundGain(): Nullable<GainNode>;
  121354. /**
  121355. * Serializes the Sound in a JSON representation
  121356. * @returns the JSON representation of the sound
  121357. */
  121358. serialize(): any;
  121359. /**
  121360. * Parse a JSON representation of a sound to innstantiate in a given scene
  121361. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  121362. * @param scene Define the scene the new parsed sound should be created in
  121363. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  121364. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  121365. * @returns the newly parsed sound
  121366. */
  121367. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  121368. }
  121369. }
  121370. declare module BABYLON {
  121371. /**
  121372. * This defines an action helpful to play a defined sound on a triggered action.
  121373. */
  121374. export class PlaySoundAction extends Action {
  121375. private _sound;
  121376. /**
  121377. * Instantiate the action
  121378. * @param triggerOptions defines the trigger options
  121379. * @param sound defines the sound to play
  121380. * @param condition defines the trigger related conditions
  121381. */
  121382. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  121383. /** @hidden */
  121384. _prepare(): void;
  121385. /**
  121386. * Execute the action and play the sound.
  121387. */
  121388. execute(): void;
  121389. /**
  121390. * Serializes the actions and its related information.
  121391. * @param parent defines the object to serialize in
  121392. * @returns the serialized object
  121393. */
  121394. serialize(parent: any): any;
  121395. }
  121396. /**
  121397. * This defines an action helpful to stop a defined sound on a triggered action.
  121398. */
  121399. export class StopSoundAction extends Action {
  121400. private _sound;
  121401. /**
  121402. * Instantiate the action
  121403. * @param triggerOptions defines the trigger options
  121404. * @param sound defines the sound to stop
  121405. * @param condition defines the trigger related conditions
  121406. */
  121407. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  121408. /** @hidden */
  121409. _prepare(): void;
  121410. /**
  121411. * Execute the action and stop the sound.
  121412. */
  121413. execute(): void;
  121414. /**
  121415. * Serializes the actions and its related information.
  121416. * @param parent defines the object to serialize in
  121417. * @returns the serialized object
  121418. */
  121419. serialize(parent: any): any;
  121420. }
  121421. }
  121422. declare module BABYLON {
  121423. /**
  121424. * This defines an action responsible to change the value of a property
  121425. * by interpolating between its current value and the newly set one once triggered.
  121426. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  121427. */
  121428. export class InterpolateValueAction extends Action {
  121429. /**
  121430. * Defines the path of the property where the value should be interpolated
  121431. */
  121432. propertyPath: string;
  121433. /**
  121434. * Defines the target value at the end of the interpolation.
  121435. */
  121436. value: any;
  121437. /**
  121438. * Defines the time it will take for the property to interpolate to the value.
  121439. */
  121440. duration: number;
  121441. /**
  121442. * Defines if the other scene animations should be stopped when the action has been triggered
  121443. */
  121444. stopOtherAnimations?: boolean;
  121445. /**
  121446. * Defines a callback raised once the interpolation animation has been done.
  121447. */
  121448. onInterpolationDone?: () => void;
  121449. /**
  121450. * Observable triggered once the interpolation animation has been done.
  121451. */
  121452. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  121453. private _target;
  121454. private _effectiveTarget;
  121455. private _property;
  121456. /**
  121457. * Instantiate the action
  121458. * @param triggerOptions defines the trigger options
  121459. * @param target defines the object containing the value to interpolate
  121460. * @param propertyPath defines the path to the property in the target object
  121461. * @param value defines the target value at the end of the interpolation
  121462. * @param duration deines the time it will take for the property to interpolate to the value.
  121463. * @param condition defines the trigger related conditions
  121464. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  121465. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  121466. */
  121467. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  121468. /** @hidden */
  121469. _prepare(): void;
  121470. /**
  121471. * Execute the action starts the value interpolation.
  121472. */
  121473. execute(): void;
  121474. /**
  121475. * Serializes the actions and its related information.
  121476. * @param parent defines the object to serialize in
  121477. * @returns the serialized object
  121478. */
  121479. serialize(parent: any): any;
  121480. }
  121481. }
  121482. declare module BABYLON {
  121483. /**
  121484. * Options allowed during the creation of a sound track.
  121485. */
  121486. export interface ISoundTrackOptions {
  121487. /**
  121488. * The volume the sound track should take during creation
  121489. */
  121490. volume?: number;
  121491. /**
  121492. * Define if the sound track is the main sound track of the scene
  121493. */
  121494. mainTrack?: boolean;
  121495. }
  121496. /**
  121497. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  121498. * It will be also used in a future release to apply effects on a specific track.
  121499. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  121500. */
  121501. export class SoundTrack {
  121502. /**
  121503. * The unique identifier of the sound track in the scene.
  121504. */
  121505. id: number;
  121506. /**
  121507. * The list of sounds included in the sound track.
  121508. */
  121509. soundCollection: Array<Sound>;
  121510. private _outputAudioNode;
  121511. private _scene;
  121512. private _connectedAnalyser;
  121513. private _options;
  121514. private _isInitialized;
  121515. /**
  121516. * Creates a new sound track.
  121517. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  121518. * @param scene Define the scene the sound track belongs to
  121519. * @param options
  121520. */
  121521. constructor(scene: Scene, options?: ISoundTrackOptions);
  121522. private _initializeSoundTrackAudioGraph;
  121523. /**
  121524. * Release the sound track and its associated resources
  121525. */
  121526. dispose(): void;
  121527. /**
  121528. * Adds a sound to this sound track
  121529. * @param sound define the cound to add
  121530. * @ignoreNaming
  121531. */
  121532. AddSound(sound: Sound): void;
  121533. /**
  121534. * Removes a sound to this sound track
  121535. * @param sound define the cound to remove
  121536. * @ignoreNaming
  121537. */
  121538. RemoveSound(sound: Sound): void;
  121539. /**
  121540. * Set a global volume for the full sound track.
  121541. * @param newVolume Define the new volume of the sound track
  121542. */
  121543. setVolume(newVolume: number): void;
  121544. /**
  121545. * Switch the panning model to HRTF:
  121546. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  121547. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121548. */
  121549. switchPanningModelToHRTF(): void;
  121550. /**
  121551. * Switch the panning model to Equal Power:
  121552. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  121553. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121554. */
  121555. switchPanningModelToEqualPower(): void;
  121556. /**
  121557. * Connect the sound track to an audio analyser allowing some amazing
  121558. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  121559. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  121560. * @param analyser The analyser to connect to the engine
  121561. */
  121562. connectToAnalyser(analyser: Analyser): void;
  121563. }
  121564. }
  121565. declare module BABYLON {
  121566. interface AbstractScene {
  121567. /**
  121568. * The list of sounds used in the scene.
  121569. */
  121570. sounds: Nullable<Array<Sound>>;
  121571. }
  121572. interface Scene {
  121573. /**
  121574. * @hidden
  121575. * Backing field
  121576. */
  121577. _mainSoundTrack: SoundTrack;
  121578. /**
  121579. * The main sound track played by the scene.
  121580. * It cotains your primary collection of sounds.
  121581. */
  121582. mainSoundTrack: SoundTrack;
  121583. /**
  121584. * The list of sound tracks added to the scene
  121585. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121586. */
  121587. soundTracks: Nullable<Array<SoundTrack>>;
  121588. /**
  121589. * Gets a sound using a given name
  121590. * @param name defines the name to search for
  121591. * @return the found sound or null if not found at all.
  121592. */
  121593. getSoundByName(name: string): Nullable<Sound>;
  121594. /**
  121595. * Gets or sets if audio support is enabled
  121596. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121597. */
  121598. audioEnabled: boolean;
  121599. /**
  121600. * Gets or sets if audio will be output to headphones
  121601. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121602. */
  121603. headphone: boolean;
  121604. /**
  121605. * Gets or sets custom audio listener position provider
  121606. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121607. */
  121608. audioListenerPositionProvider: Nullable<() => Vector3>;
  121609. /**
  121610. * Gets or sets a refresh rate when using 3D audio positioning
  121611. */
  121612. audioPositioningRefreshRate: number;
  121613. }
  121614. /**
  121615. * Defines the sound scene component responsible to manage any sounds
  121616. * in a given scene.
  121617. */
  121618. export class AudioSceneComponent implements ISceneSerializableComponent {
  121619. /**
  121620. * The component name helpfull to identify the component in the list of scene components.
  121621. */
  121622. readonly name: string;
  121623. /**
  121624. * The scene the component belongs to.
  121625. */
  121626. scene: Scene;
  121627. private _audioEnabled;
  121628. /**
  121629. * Gets whether audio is enabled or not.
  121630. * Please use related enable/disable method to switch state.
  121631. */
  121632. get audioEnabled(): boolean;
  121633. private _headphone;
  121634. /**
  121635. * Gets whether audio is outputing to headphone or not.
  121636. * Please use the according Switch methods to change output.
  121637. */
  121638. get headphone(): boolean;
  121639. /**
  121640. * Gets or sets a refresh rate when using 3D audio positioning
  121641. */
  121642. audioPositioningRefreshRate: number;
  121643. private _audioListenerPositionProvider;
  121644. /**
  121645. * Gets the current audio listener position provider
  121646. */
  121647. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  121648. /**
  121649. * Sets a custom listener position for all sounds in the scene
  121650. * By default, this is the position of the first active camera
  121651. */
  121652. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  121653. /**
  121654. * Creates a new instance of the component for the given scene
  121655. * @param scene Defines the scene to register the component in
  121656. */
  121657. constructor(scene: Scene);
  121658. /**
  121659. * Registers the component in a given scene
  121660. */
  121661. register(): void;
  121662. /**
  121663. * Rebuilds the elements related to this component in case of
  121664. * context lost for instance.
  121665. */
  121666. rebuild(): void;
  121667. /**
  121668. * Serializes the component data to the specified json object
  121669. * @param serializationObject The object to serialize to
  121670. */
  121671. serialize(serializationObject: any): void;
  121672. /**
  121673. * Adds all the elements from the container to the scene
  121674. * @param container the container holding the elements
  121675. */
  121676. addFromContainer(container: AbstractScene): void;
  121677. /**
  121678. * Removes all the elements in the container from the scene
  121679. * @param container contains the elements to remove
  121680. * @param dispose if the removed element should be disposed (default: false)
  121681. */
  121682. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  121683. /**
  121684. * Disposes the component and the associated ressources.
  121685. */
  121686. dispose(): void;
  121687. /**
  121688. * Disables audio in the associated scene.
  121689. */
  121690. disableAudio(): void;
  121691. /**
  121692. * Enables audio in the associated scene.
  121693. */
  121694. enableAudio(): void;
  121695. /**
  121696. * Switch audio to headphone output.
  121697. */
  121698. switchAudioModeForHeadphones(): void;
  121699. /**
  121700. * Switch audio to normal speakers.
  121701. */
  121702. switchAudioModeForNormalSpeakers(): void;
  121703. private _cachedCameraDirection;
  121704. private _cachedCameraPosition;
  121705. private _lastCheck;
  121706. private _afterRender;
  121707. }
  121708. }
  121709. declare module BABYLON {
  121710. /**
  121711. * Wraps one or more Sound objects and selects one with random weight for playback.
  121712. */
  121713. export class WeightedSound {
  121714. /** When true a Sound will be selected and played when the current playing Sound completes. */
  121715. loop: boolean;
  121716. private _coneInnerAngle;
  121717. private _coneOuterAngle;
  121718. private _volume;
  121719. /** A Sound is currently playing. */
  121720. isPlaying: boolean;
  121721. /** A Sound is currently paused. */
  121722. isPaused: boolean;
  121723. private _sounds;
  121724. private _weights;
  121725. private _currentIndex?;
  121726. /**
  121727. * Creates a new WeightedSound from the list of sounds given.
  121728. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  121729. * @param sounds Array of Sounds that will be selected from.
  121730. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  121731. */
  121732. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  121733. /**
  121734. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  121735. */
  121736. get directionalConeInnerAngle(): number;
  121737. /**
  121738. * The size of cone in degress for a directional sound in which there will be no attenuation.
  121739. */
  121740. set directionalConeInnerAngle(value: number);
  121741. /**
  121742. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  121743. * Listener angles between innerAngle and outerAngle will falloff linearly.
  121744. */
  121745. get directionalConeOuterAngle(): number;
  121746. /**
  121747. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  121748. * Listener angles between innerAngle and outerAngle will falloff linearly.
  121749. */
  121750. set directionalConeOuterAngle(value: number);
  121751. /**
  121752. * Playback volume.
  121753. */
  121754. get volume(): number;
  121755. /**
  121756. * Playback volume.
  121757. */
  121758. set volume(value: number);
  121759. private _onended;
  121760. /**
  121761. * Suspend playback
  121762. */
  121763. pause(): void;
  121764. /**
  121765. * Stop playback
  121766. */
  121767. stop(): void;
  121768. /**
  121769. * Start playback.
  121770. * @param startOffset Position the clip head at a specific time in seconds.
  121771. */
  121772. play(startOffset?: number): void;
  121773. }
  121774. }
  121775. declare module BABYLON {
  121776. /**
  121777. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  121778. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121779. */
  121780. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  121781. /**
  121782. * Gets the name of the behavior.
  121783. */
  121784. get name(): string;
  121785. /**
  121786. * The easing function used by animations
  121787. */
  121788. static EasingFunction: BackEase;
  121789. /**
  121790. * The easing mode used by animations
  121791. */
  121792. static EasingMode: number;
  121793. /**
  121794. * The duration of the animation, in milliseconds
  121795. */
  121796. transitionDuration: number;
  121797. /**
  121798. * Length of the distance animated by the transition when lower radius is reached
  121799. */
  121800. lowerRadiusTransitionRange: number;
  121801. /**
  121802. * Length of the distance animated by the transition when upper radius is reached
  121803. */
  121804. upperRadiusTransitionRange: number;
  121805. private _autoTransitionRange;
  121806. /**
  121807. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  121808. */
  121809. get autoTransitionRange(): boolean;
  121810. /**
  121811. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  121812. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  121813. */
  121814. set autoTransitionRange(value: boolean);
  121815. private _attachedCamera;
  121816. private _onAfterCheckInputsObserver;
  121817. private _onMeshTargetChangedObserver;
  121818. /**
  121819. * Initializes the behavior.
  121820. */
  121821. init(): void;
  121822. /**
  121823. * Attaches the behavior to its arc rotate camera.
  121824. * @param camera Defines the camera to attach the behavior to
  121825. */
  121826. attach(camera: ArcRotateCamera): void;
  121827. /**
  121828. * Detaches the behavior from its current arc rotate camera.
  121829. */
  121830. detach(): void;
  121831. private _radiusIsAnimating;
  121832. private _radiusBounceTransition;
  121833. private _animatables;
  121834. private _cachedWheelPrecision;
  121835. /**
  121836. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  121837. * @param radiusLimit The limit to check against.
  121838. * @return Bool to indicate if at limit.
  121839. */
  121840. private _isRadiusAtLimit;
  121841. /**
  121842. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  121843. * @param radiusDelta The delta by which to animate to. Can be negative.
  121844. */
  121845. private _applyBoundRadiusAnimation;
  121846. /**
  121847. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  121848. */
  121849. protected _clearAnimationLocks(): void;
  121850. /**
  121851. * Stops and removes all animations that have been applied to the camera
  121852. */
  121853. stopAllAnimations(): void;
  121854. }
  121855. }
  121856. declare module BABYLON {
  121857. /**
  121858. * 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.
  121859. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121860. */
  121861. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  121862. /**
  121863. * Gets the name of the behavior.
  121864. */
  121865. get name(): string;
  121866. private _mode;
  121867. private _radiusScale;
  121868. private _positionScale;
  121869. private _defaultElevation;
  121870. private _elevationReturnTime;
  121871. private _elevationReturnWaitTime;
  121872. private _zoomStopsAnimation;
  121873. private _framingTime;
  121874. /**
  121875. * The easing function used by animations
  121876. */
  121877. static EasingFunction: ExponentialEase;
  121878. /**
  121879. * The easing mode used by animations
  121880. */
  121881. static EasingMode: number;
  121882. /**
  121883. * Sets the current mode used by the behavior
  121884. */
  121885. set mode(mode: number);
  121886. /**
  121887. * Gets current mode used by the behavior.
  121888. */
  121889. get mode(): number;
  121890. /**
  121891. * Sets the scale applied to the radius (1 by default)
  121892. */
  121893. set radiusScale(radius: number);
  121894. /**
  121895. * Gets the scale applied to the radius
  121896. */
  121897. get radiusScale(): number;
  121898. /**
  121899. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  121900. */
  121901. set positionScale(scale: number);
  121902. /**
  121903. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  121904. */
  121905. get positionScale(): number;
  121906. /**
  121907. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  121908. * behaviour is triggered, in radians.
  121909. */
  121910. set defaultElevation(elevation: number);
  121911. /**
  121912. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  121913. * behaviour is triggered, in radians.
  121914. */
  121915. get defaultElevation(): number;
  121916. /**
  121917. * Sets the time (in milliseconds) taken to return to the default beta position.
  121918. * Negative value indicates camera should not return to default.
  121919. */
  121920. set elevationReturnTime(speed: number);
  121921. /**
  121922. * Gets the time (in milliseconds) taken to return to the default beta position.
  121923. * Negative value indicates camera should not return to default.
  121924. */
  121925. get elevationReturnTime(): number;
  121926. /**
  121927. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  121928. */
  121929. set elevationReturnWaitTime(time: number);
  121930. /**
  121931. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  121932. */
  121933. get elevationReturnWaitTime(): number;
  121934. /**
  121935. * Sets the flag that indicates if user zooming should stop animation.
  121936. */
  121937. set zoomStopsAnimation(flag: boolean);
  121938. /**
  121939. * Gets the flag that indicates if user zooming should stop animation.
  121940. */
  121941. get zoomStopsAnimation(): boolean;
  121942. /**
  121943. * Sets the transition time when framing the mesh, in milliseconds
  121944. */
  121945. set framingTime(time: number);
  121946. /**
  121947. * Gets the transition time when framing the mesh, in milliseconds
  121948. */
  121949. get framingTime(): number;
  121950. /**
  121951. * Define if the behavior should automatically change the configured
  121952. * camera limits and sensibilities.
  121953. */
  121954. autoCorrectCameraLimitsAndSensibility: boolean;
  121955. private _onPrePointerObservableObserver;
  121956. private _onAfterCheckInputsObserver;
  121957. private _onMeshTargetChangedObserver;
  121958. private _attachedCamera;
  121959. private _isPointerDown;
  121960. private _lastInteractionTime;
  121961. /**
  121962. * Initializes the behavior.
  121963. */
  121964. init(): void;
  121965. /**
  121966. * Attaches the behavior to its arc rotate camera.
  121967. * @param camera Defines the camera to attach the behavior to
  121968. */
  121969. attach(camera: ArcRotateCamera): void;
  121970. /**
  121971. * Detaches the behavior from its current arc rotate camera.
  121972. */
  121973. detach(): void;
  121974. private _animatables;
  121975. private _betaIsAnimating;
  121976. private _betaTransition;
  121977. private _radiusTransition;
  121978. private _vectorTransition;
  121979. /**
  121980. * Targets the given mesh and updates zoom level accordingly.
  121981. * @param mesh The mesh to target.
  121982. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121983. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121984. */
  121985. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121986. /**
  121987. * Targets the given mesh with its children and updates zoom level accordingly.
  121988. * @param mesh The mesh to target.
  121989. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121990. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121991. */
  121992. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121993. /**
  121994. * Targets the given meshes with their children and updates zoom level accordingly.
  121995. * @param meshes The mesh to target.
  121996. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121997. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121998. */
  121999. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122000. /**
  122001. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  122002. * @param minimumWorld Determines the smaller position of the bounding box extend
  122003. * @param maximumWorld Determines the bigger position of the bounding box extend
  122004. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122005. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122006. */
  122007. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122008. /**
  122009. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  122010. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  122011. * frustum width.
  122012. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  122013. * to fully enclose the mesh in the viewing frustum.
  122014. */
  122015. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  122016. /**
  122017. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  122018. * is automatically returned to its default position (expected to be above ground plane).
  122019. */
  122020. private _maintainCameraAboveGround;
  122021. /**
  122022. * Returns the frustum slope based on the canvas ratio and camera FOV
  122023. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  122024. */
  122025. private _getFrustumSlope;
  122026. /**
  122027. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  122028. */
  122029. private _clearAnimationLocks;
  122030. /**
  122031. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122032. */
  122033. private _applyUserInteraction;
  122034. /**
  122035. * Stops and removes all animations that have been applied to the camera
  122036. */
  122037. stopAllAnimations(): void;
  122038. /**
  122039. * Gets a value indicating if the user is moving the camera
  122040. */
  122041. get isUserIsMoving(): boolean;
  122042. /**
  122043. * The camera can move all the way towards the mesh.
  122044. */
  122045. static IgnoreBoundsSizeMode: number;
  122046. /**
  122047. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  122048. */
  122049. static FitFrustumSidesMode: number;
  122050. }
  122051. }
  122052. declare module BABYLON {
  122053. /**
  122054. * Base class for Camera Pointer Inputs.
  122055. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  122056. * for example usage.
  122057. */
  122058. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  122059. /**
  122060. * Defines the camera the input is attached to.
  122061. */
  122062. abstract camera: Camera;
  122063. /**
  122064. * Whether keyboard modifier keys are pressed at time of last mouse event.
  122065. */
  122066. protected _altKey: boolean;
  122067. protected _ctrlKey: boolean;
  122068. protected _metaKey: boolean;
  122069. protected _shiftKey: boolean;
  122070. /**
  122071. * Which mouse buttons were pressed at time of last mouse event.
  122072. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  122073. */
  122074. protected _buttonsPressed: number;
  122075. /**
  122076. * Defines the buttons associated with the input to handle camera move.
  122077. */
  122078. buttons: number[];
  122079. /**
  122080. * Attach the input controls to a specific dom element to get the input from.
  122081. * @param element Defines the element the controls should be listened from
  122082. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122083. */
  122084. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122085. /**
  122086. * Detach the current controls from the specified dom element.
  122087. * @param element Defines the element to stop listening the inputs from
  122088. */
  122089. detachControl(element: Nullable<HTMLElement>): void;
  122090. /**
  122091. * Gets the class name of the current input.
  122092. * @returns the class name
  122093. */
  122094. getClassName(): string;
  122095. /**
  122096. * Get the friendly name associated with the input class.
  122097. * @returns the input friendly name
  122098. */
  122099. getSimpleName(): string;
  122100. /**
  122101. * Called on pointer POINTERDOUBLETAP event.
  122102. * Override this method to provide functionality on POINTERDOUBLETAP event.
  122103. */
  122104. protected onDoubleTap(type: string): void;
  122105. /**
  122106. * Called on pointer POINTERMOVE event if only a single touch is active.
  122107. * Override this method to provide functionality.
  122108. */
  122109. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122110. /**
  122111. * Called on pointer POINTERMOVE event if multiple touches are active.
  122112. * Override this method to provide functionality.
  122113. */
  122114. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122115. /**
  122116. * Called on JS contextmenu event.
  122117. * Override this method to provide functionality.
  122118. */
  122119. protected onContextMenu(evt: PointerEvent): void;
  122120. /**
  122121. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122122. * press.
  122123. * Override this method to provide functionality.
  122124. */
  122125. protected onButtonDown(evt: PointerEvent): void;
  122126. /**
  122127. * Called each time a new POINTERUP event occurs. Ie, for each button
  122128. * release.
  122129. * Override this method to provide functionality.
  122130. */
  122131. protected onButtonUp(evt: PointerEvent): void;
  122132. /**
  122133. * Called when window becomes inactive.
  122134. * Override this method to provide functionality.
  122135. */
  122136. protected onLostFocus(): void;
  122137. private _pointerInput;
  122138. private _observer;
  122139. private _onLostFocus;
  122140. private pointA;
  122141. private pointB;
  122142. }
  122143. }
  122144. declare module BABYLON {
  122145. /**
  122146. * Manage the pointers inputs to control an arc rotate camera.
  122147. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122148. */
  122149. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  122150. /**
  122151. * Defines the camera the input is attached to.
  122152. */
  122153. camera: ArcRotateCamera;
  122154. /**
  122155. * Gets the class name of the current input.
  122156. * @returns the class name
  122157. */
  122158. getClassName(): string;
  122159. /**
  122160. * Defines the buttons associated with the input to handle camera move.
  122161. */
  122162. buttons: number[];
  122163. /**
  122164. * Defines the pointer angular sensibility along the X axis or how fast is
  122165. * the camera rotating.
  122166. */
  122167. angularSensibilityX: number;
  122168. /**
  122169. * Defines the pointer angular sensibility along the Y axis or how fast is
  122170. * the camera rotating.
  122171. */
  122172. angularSensibilityY: number;
  122173. /**
  122174. * Defines the pointer pinch precision or how fast is the camera zooming.
  122175. */
  122176. pinchPrecision: number;
  122177. /**
  122178. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  122179. * from 0.
  122180. * It defines the percentage of current camera.radius to use as delta when
  122181. * pinch zoom is used.
  122182. */
  122183. pinchDeltaPercentage: number;
  122184. /**
  122185. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  122186. * that any object in the plane at the camera's target point will scale
  122187. * perfectly with finger motion.
  122188. * Overrides pinchDeltaPercentage and pinchPrecision.
  122189. */
  122190. useNaturalPinchZoom: boolean;
  122191. /**
  122192. * Defines the pointer panning sensibility or how fast is the camera moving.
  122193. */
  122194. panningSensibility: number;
  122195. /**
  122196. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  122197. */
  122198. multiTouchPanning: boolean;
  122199. /**
  122200. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  122201. * zoom (pinch) through multitouch.
  122202. */
  122203. multiTouchPanAndZoom: boolean;
  122204. /**
  122205. * Revers pinch action direction.
  122206. */
  122207. pinchInwards: boolean;
  122208. private _isPanClick;
  122209. private _twoFingerActivityCount;
  122210. private _isPinching;
  122211. /**
  122212. * Called on pointer POINTERMOVE event if only a single touch is active.
  122213. */
  122214. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122215. /**
  122216. * Called on pointer POINTERDOUBLETAP event.
  122217. */
  122218. protected onDoubleTap(type: string): void;
  122219. /**
  122220. * Called on pointer POINTERMOVE event if multiple touches are active.
  122221. */
  122222. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122223. /**
  122224. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122225. * press.
  122226. */
  122227. protected onButtonDown(evt: PointerEvent): void;
  122228. /**
  122229. * Called each time a new POINTERUP event occurs. Ie, for each button
  122230. * release.
  122231. */
  122232. protected onButtonUp(evt: PointerEvent): void;
  122233. /**
  122234. * Called when window becomes inactive.
  122235. */
  122236. protected onLostFocus(): void;
  122237. }
  122238. }
  122239. declare module BABYLON {
  122240. /**
  122241. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  122242. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122243. */
  122244. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  122245. /**
  122246. * Defines the camera the input is attached to.
  122247. */
  122248. camera: ArcRotateCamera;
  122249. /**
  122250. * Defines the list of key codes associated with the up action (increase alpha)
  122251. */
  122252. keysUp: number[];
  122253. /**
  122254. * Defines the list of key codes associated with the down action (decrease alpha)
  122255. */
  122256. keysDown: number[];
  122257. /**
  122258. * Defines the list of key codes associated with the left action (increase beta)
  122259. */
  122260. keysLeft: number[];
  122261. /**
  122262. * Defines the list of key codes associated with the right action (decrease beta)
  122263. */
  122264. keysRight: number[];
  122265. /**
  122266. * Defines the list of key codes associated with the reset action.
  122267. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  122268. */
  122269. keysReset: number[];
  122270. /**
  122271. * Defines the panning sensibility of the inputs.
  122272. * (How fast is the camera panning)
  122273. */
  122274. panningSensibility: number;
  122275. /**
  122276. * Defines the zooming sensibility of the inputs.
  122277. * (How fast is the camera zooming)
  122278. */
  122279. zoomingSensibility: number;
  122280. /**
  122281. * Defines whether maintaining the alt key down switch the movement mode from
  122282. * orientation to zoom.
  122283. */
  122284. useAltToZoom: boolean;
  122285. /**
  122286. * Rotation speed of the camera
  122287. */
  122288. angularSpeed: number;
  122289. private _keys;
  122290. private _ctrlPressed;
  122291. private _altPressed;
  122292. private _onCanvasBlurObserver;
  122293. private _onKeyboardObserver;
  122294. private _engine;
  122295. private _scene;
  122296. /**
  122297. * Attach the input controls to a specific dom element to get the input from.
  122298. * @param element Defines the element the controls should be listened from
  122299. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122300. */
  122301. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122302. /**
  122303. * Detach the current controls from the specified dom element.
  122304. * @param element Defines the element to stop listening the inputs from
  122305. */
  122306. detachControl(element: Nullable<HTMLElement>): void;
  122307. /**
  122308. * Update the current camera state depending on the inputs that have been used this frame.
  122309. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122310. */
  122311. checkInputs(): void;
  122312. /**
  122313. * Gets the class name of the current intput.
  122314. * @returns the class name
  122315. */
  122316. getClassName(): string;
  122317. /**
  122318. * Get the friendly name associated with the input class.
  122319. * @returns the input friendly name
  122320. */
  122321. getSimpleName(): string;
  122322. }
  122323. }
  122324. declare module BABYLON {
  122325. /**
  122326. * Manage the mouse wheel inputs to control an arc rotate camera.
  122327. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122328. */
  122329. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  122330. /**
  122331. * Defines the camera the input is attached to.
  122332. */
  122333. camera: ArcRotateCamera;
  122334. /**
  122335. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  122336. */
  122337. wheelPrecision: number;
  122338. /**
  122339. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  122340. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  122341. */
  122342. wheelDeltaPercentage: number;
  122343. private _wheel;
  122344. private _observer;
  122345. private computeDeltaFromMouseWheelLegacyEvent;
  122346. /**
  122347. * Attach the input controls to a specific dom element to get the input from.
  122348. * @param element Defines the element the controls should be listened from
  122349. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122350. */
  122351. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122352. /**
  122353. * Detach the current controls from the specified dom element.
  122354. * @param element Defines the element to stop listening the inputs from
  122355. */
  122356. detachControl(element: Nullable<HTMLElement>): void;
  122357. /**
  122358. * Gets the class name of the current intput.
  122359. * @returns the class name
  122360. */
  122361. getClassName(): string;
  122362. /**
  122363. * Get the friendly name associated with the input class.
  122364. * @returns the input friendly name
  122365. */
  122366. getSimpleName(): string;
  122367. }
  122368. }
  122369. declare module BABYLON {
  122370. /**
  122371. * Default Inputs manager for the ArcRotateCamera.
  122372. * It groups all the default supported inputs for ease of use.
  122373. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122374. */
  122375. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  122376. /**
  122377. * Instantiates a new ArcRotateCameraInputsManager.
  122378. * @param camera Defines the camera the inputs belong to
  122379. */
  122380. constructor(camera: ArcRotateCamera);
  122381. /**
  122382. * Add mouse wheel input support to the input manager.
  122383. * @returns the current input manager
  122384. */
  122385. addMouseWheel(): ArcRotateCameraInputsManager;
  122386. /**
  122387. * Add pointers input support to the input manager.
  122388. * @returns the current input manager
  122389. */
  122390. addPointers(): ArcRotateCameraInputsManager;
  122391. /**
  122392. * Add keyboard input support to the input manager.
  122393. * @returns the current input manager
  122394. */
  122395. addKeyboard(): ArcRotateCameraInputsManager;
  122396. }
  122397. }
  122398. declare module BABYLON {
  122399. /**
  122400. * This represents an orbital type of camera.
  122401. *
  122402. * 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.
  122403. * 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.
  122404. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  122405. */
  122406. export class ArcRotateCamera extends TargetCamera {
  122407. /**
  122408. * Defines the rotation angle of the camera along the longitudinal axis.
  122409. */
  122410. alpha: number;
  122411. /**
  122412. * Defines the rotation angle of the camera along the latitudinal axis.
  122413. */
  122414. beta: number;
  122415. /**
  122416. * Defines the radius of the camera from it s target point.
  122417. */
  122418. radius: number;
  122419. protected _target: Vector3;
  122420. protected _targetHost: Nullable<AbstractMesh>;
  122421. /**
  122422. * Defines the target point of the camera.
  122423. * The camera looks towards it form the radius distance.
  122424. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  122425. */
  122426. get target(): Vector3;
  122427. set target(value: Vector3);
  122428. /**
  122429. * Define the current local position of the camera in the scene
  122430. */
  122431. get position(): Vector3;
  122432. set position(newPosition: Vector3);
  122433. protected _upVector: Vector3;
  122434. protected _upToYMatrix: Matrix;
  122435. protected _YToUpMatrix: Matrix;
  122436. /**
  122437. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  122438. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  122439. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  122440. */
  122441. set upVector(vec: Vector3);
  122442. get upVector(): Vector3;
  122443. /**
  122444. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  122445. */
  122446. setMatUp(): void;
  122447. /**
  122448. * Current inertia value on the longitudinal axis.
  122449. * The bigger this number the longer it will take for the camera to stop.
  122450. */
  122451. inertialAlphaOffset: number;
  122452. /**
  122453. * Current inertia value on the latitudinal axis.
  122454. * The bigger this number the longer it will take for the camera to stop.
  122455. */
  122456. inertialBetaOffset: number;
  122457. /**
  122458. * Current inertia value on the radius axis.
  122459. * The bigger this number the longer it will take for the camera to stop.
  122460. */
  122461. inertialRadiusOffset: number;
  122462. /**
  122463. * Minimum allowed angle on the longitudinal axis.
  122464. * This can help limiting how the Camera is able to move in the scene.
  122465. */
  122466. lowerAlphaLimit: Nullable<number>;
  122467. /**
  122468. * Maximum allowed angle on the longitudinal axis.
  122469. * This can help limiting how the Camera is able to move in the scene.
  122470. */
  122471. upperAlphaLimit: Nullable<number>;
  122472. /**
  122473. * Minimum allowed angle on the latitudinal axis.
  122474. * This can help limiting how the Camera is able to move in the scene.
  122475. */
  122476. lowerBetaLimit: number;
  122477. /**
  122478. * Maximum allowed angle on the latitudinal axis.
  122479. * This can help limiting how the Camera is able to move in the scene.
  122480. */
  122481. upperBetaLimit: number;
  122482. /**
  122483. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  122484. * This can help limiting how the Camera is able to move in the scene.
  122485. */
  122486. lowerRadiusLimit: Nullable<number>;
  122487. /**
  122488. * Maximum allowed distance of the camera to the target (The camera can not get further).
  122489. * This can help limiting how the Camera is able to move in the scene.
  122490. */
  122491. upperRadiusLimit: Nullable<number>;
  122492. /**
  122493. * Defines the current inertia value used during panning of the camera along the X axis.
  122494. */
  122495. inertialPanningX: number;
  122496. /**
  122497. * Defines the current inertia value used during panning of the camera along the Y axis.
  122498. */
  122499. inertialPanningY: number;
  122500. /**
  122501. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  122502. * Basically if your fingers moves away from more than this distance you will be considered
  122503. * in pinch mode.
  122504. */
  122505. pinchToPanMaxDistance: number;
  122506. /**
  122507. * Defines the maximum distance the camera can pan.
  122508. * This could help keeping the cammera always in your scene.
  122509. */
  122510. panningDistanceLimit: Nullable<number>;
  122511. /**
  122512. * Defines the target of the camera before paning.
  122513. */
  122514. panningOriginTarget: Vector3;
  122515. /**
  122516. * Defines the value of the inertia used during panning.
  122517. * 0 would mean stop inertia and one would mean no decelleration at all.
  122518. */
  122519. panningInertia: number;
  122520. /**
  122521. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  122522. */
  122523. get angularSensibilityX(): number;
  122524. set angularSensibilityX(value: number);
  122525. /**
  122526. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  122527. */
  122528. get angularSensibilityY(): number;
  122529. set angularSensibilityY(value: number);
  122530. /**
  122531. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  122532. */
  122533. get pinchPrecision(): number;
  122534. set pinchPrecision(value: number);
  122535. /**
  122536. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  122537. * It will be used instead of pinchDeltaPrecision if different from 0.
  122538. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  122539. */
  122540. get pinchDeltaPercentage(): number;
  122541. set pinchDeltaPercentage(value: number);
  122542. /**
  122543. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  122544. * and pinch delta percentage.
  122545. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  122546. * that any object in the plane at the camera's target point will scale
  122547. * perfectly with finger motion.
  122548. */
  122549. get useNaturalPinchZoom(): boolean;
  122550. set useNaturalPinchZoom(value: boolean);
  122551. /**
  122552. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  122553. */
  122554. get panningSensibility(): number;
  122555. set panningSensibility(value: number);
  122556. /**
  122557. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  122558. */
  122559. get keysUp(): number[];
  122560. set keysUp(value: number[]);
  122561. /**
  122562. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  122563. */
  122564. get keysDown(): number[];
  122565. set keysDown(value: number[]);
  122566. /**
  122567. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  122568. */
  122569. get keysLeft(): number[];
  122570. set keysLeft(value: number[]);
  122571. /**
  122572. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  122573. */
  122574. get keysRight(): number[];
  122575. set keysRight(value: number[]);
  122576. /**
  122577. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  122578. */
  122579. get wheelPrecision(): number;
  122580. set wheelPrecision(value: number);
  122581. /**
  122582. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  122583. * It will be used instead of pinchDeltaPrecision if different from 0.
  122584. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  122585. */
  122586. get wheelDeltaPercentage(): number;
  122587. set wheelDeltaPercentage(value: number);
  122588. /**
  122589. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  122590. */
  122591. zoomOnFactor: number;
  122592. /**
  122593. * Defines a screen offset for the camera position.
  122594. */
  122595. targetScreenOffset: Vector2;
  122596. /**
  122597. * Allows the camera to be completely reversed.
  122598. * If false the camera can not arrive upside down.
  122599. */
  122600. allowUpsideDown: boolean;
  122601. /**
  122602. * Define if double tap/click is used to restore the previously saved state of the camera.
  122603. */
  122604. useInputToRestoreState: boolean;
  122605. /** @hidden */
  122606. _viewMatrix: Matrix;
  122607. /** @hidden */
  122608. _useCtrlForPanning: boolean;
  122609. /** @hidden */
  122610. _panningMouseButton: number;
  122611. /**
  122612. * Defines the input associated to the camera.
  122613. */
  122614. inputs: ArcRotateCameraInputsManager;
  122615. /** @hidden */
  122616. _reset: () => void;
  122617. /**
  122618. * Defines the allowed panning axis.
  122619. */
  122620. panningAxis: Vector3;
  122621. protected _localDirection: Vector3;
  122622. protected _transformedDirection: Vector3;
  122623. private _bouncingBehavior;
  122624. /**
  122625. * Gets the bouncing behavior of the camera if it has been enabled.
  122626. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122627. */
  122628. get bouncingBehavior(): Nullable<BouncingBehavior>;
  122629. /**
  122630. * Defines if the bouncing behavior of the camera is enabled on the camera.
  122631. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122632. */
  122633. get useBouncingBehavior(): boolean;
  122634. set useBouncingBehavior(value: boolean);
  122635. private _framingBehavior;
  122636. /**
  122637. * Gets the framing behavior of the camera if it has been enabled.
  122638. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122639. */
  122640. get framingBehavior(): Nullable<FramingBehavior>;
  122641. /**
  122642. * Defines if the framing behavior of the camera is enabled on the camera.
  122643. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122644. */
  122645. get useFramingBehavior(): boolean;
  122646. set useFramingBehavior(value: boolean);
  122647. private _autoRotationBehavior;
  122648. /**
  122649. * Gets the auto rotation behavior of the camera if it has been enabled.
  122650. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122651. */
  122652. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  122653. /**
  122654. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  122655. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122656. */
  122657. get useAutoRotationBehavior(): boolean;
  122658. set useAutoRotationBehavior(value: boolean);
  122659. /**
  122660. * Observable triggered when the mesh target has been changed on the camera.
  122661. */
  122662. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  122663. /**
  122664. * Event raised when the camera is colliding with a mesh.
  122665. */
  122666. onCollide: (collidedMesh: AbstractMesh) => void;
  122667. /**
  122668. * Defines whether the camera should check collision with the objects oh the scene.
  122669. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  122670. */
  122671. checkCollisions: boolean;
  122672. /**
  122673. * Defines the collision radius of the camera.
  122674. * This simulates a sphere around the camera.
  122675. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  122676. */
  122677. collisionRadius: Vector3;
  122678. protected _collider: Collider;
  122679. protected _previousPosition: Vector3;
  122680. protected _collisionVelocity: Vector3;
  122681. protected _newPosition: Vector3;
  122682. protected _previousAlpha: number;
  122683. protected _previousBeta: number;
  122684. protected _previousRadius: number;
  122685. protected _collisionTriggered: boolean;
  122686. protected _targetBoundingCenter: Nullable<Vector3>;
  122687. private _computationVector;
  122688. /**
  122689. * Instantiates a new ArcRotateCamera in a given scene
  122690. * @param name Defines the name of the camera
  122691. * @param alpha Defines the camera rotation along the logitudinal axis
  122692. * @param beta Defines the camera rotation along the latitudinal axis
  122693. * @param radius Defines the camera distance from its target
  122694. * @param target Defines the camera target
  122695. * @param scene Defines the scene the camera belongs to
  122696. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  122697. */
  122698. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  122699. /** @hidden */
  122700. _initCache(): void;
  122701. /** @hidden */
  122702. _updateCache(ignoreParentClass?: boolean): void;
  122703. protected _getTargetPosition(): Vector3;
  122704. private _storedAlpha;
  122705. private _storedBeta;
  122706. private _storedRadius;
  122707. private _storedTarget;
  122708. private _storedTargetScreenOffset;
  122709. /**
  122710. * Stores the current state of the camera (alpha, beta, radius and target)
  122711. * @returns the camera itself
  122712. */
  122713. storeState(): Camera;
  122714. /**
  122715. * @hidden
  122716. * Restored camera state. You must call storeState() first
  122717. */
  122718. _restoreStateValues(): boolean;
  122719. /** @hidden */
  122720. _isSynchronizedViewMatrix(): boolean;
  122721. /**
  122722. * Attached controls to the current camera.
  122723. * @param element Defines the element the controls should be listened from
  122724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122725. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  122726. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  122727. */
  122728. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  122729. /**
  122730. * Detach the current controls from the camera.
  122731. * The camera will stop reacting to inputs.
  122732. * @param element Defines the element to stop listening the inputs from
  122733. */
  122734. detachControl(element: HTMLElement): void;
  122735. /** @hidden */
  122736. _checkInputs(): void;
  122737. protected _checkLimits(): void;
  122738. /**
  122739. * Rebuilds angles (alpha, beta) and radius from the give position and target
  122740. */
  122741. rebuildAnglesAndRadius(): void;
  122742. /**
  122743. * Use a position to define the current camera related information like alpha, beta and radius
  122744. * @param position Defines the position to set the camera at
  122745. */
  122746. setPosition(position: Vector3): void;
  122747. /**
  122748. * Defines the target the camera should look at.
  122749. * This will automatically adapt alpha beta and radius to fit within the new target.
  122750. * @param target Defines the new target as a Vector or a mesh
  122751. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  122752. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  122753. */
  122754. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  122755. /** @hidden */
  122756. _getViewMatrix(): Matrix;
  122757. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  122758. /**
  122759. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  122760. * @param meshes Defines the mesh to zoom on
  122761. * @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)
  122762. */
  122763. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  122764. /**
  122765. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  122766. * The target will be changed but the radius
  122767. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  122768. * @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)
  122769. */
  122770. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  122771. min: Vector3;
  122772. max: Vector3;
  122773. distance: number;
  122774. }, doNotUpdateMaxZ?: boolean): void;
  122775. /**
  122776. * @override
  122777. * Override Camera.createRigCamera
  122778. */
  122779. createRigCamera(name: string, cameraIndex: number): Camera;
  122780. /**
  122781. * @hidden
  122782. * @override
  122783. * Override Camera._updateRigCameras
  122784. */
  122785. _updateRigCameras(): void;
  122786. /**
  122787. * Destroy the camera and release the current resources hold by it.
  122788. */
  122789. dispose(): void;
  122790. /**
  122791. * Gets the current object class name.
  122792. * @return the class name
  122793. */
  122794. getClassName(): string;
  122795. }
  122796. }
  122797. declare module BABYLON {
  122798. /**
  122799. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  122800. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122801. */
  122802. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  122803. /**
  122804. * Gets the name of the behavior.
  122805. */
  122806. get name(): string;
  122807. private _zoomStopsAnimation;
  122808. private _idleRotationSpeed;
  122809. private _idleRotationWaitTime;
  122810. private _idleRotationSpinupTime;
  122811. /**
  122812. * Sets the flag that indicates if user zooming should stop animation.
  122813. */
  122814. set zoomStopsAnimation(flag: boolean);
  122815. /**
  122816. * Gets the flag that indicates if user zooming should stop animation.
  122817. */
  122818. get zoomStopsAnimation(): boolean;
  122819. /**
  122820. * Sets the default speed at which the camera rotates around the model.
  122821. */
  122822. set idleRotationSpeed(speed: number);
  122823. /**
  122824. * Gets the default speed at which the camera rotates around the model.
  122825. */
  122826. get idleRotationSpeed(): number;
  122827. /**
  122828. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  122829. */
  122830. set idleRotationWaitTime(time: number);
  122831. /**
  122832. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  122833. */
  122834. get idleRotationWaitTime(): number;
  122835. /**
  122836. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  122837. */
  122838. set idleRotationSpinupTime(time: number);
  122839. /**
  122840. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  122841. */
  122842. get idleRotationSpinupTime(): number;
  122843. /**
  122844. * Gets a value indicating if the camera is currently rotating because of this behavior
  122845. */
  122846. get rotationInProgress(): boolean;
  122847. private _onPrePointerObservableObserver;
  122848. private _onAfterCheckInputsObserver;
  122849. private _attachedCamera;
  122850. private _isPointerDown;
  122851. private _lastFrameTime;
  122852. private _lastInteractionTime;
  122853. private _cameraRotationSpeed;
  122854. /**
  122855. * Initializes the behavior.
  122856. */
  122857. init(): void;
  122858. /**
  122859. * Attaches the behavior to its arc rotate camera.
  122860. * @param camera Defines the camera to attach the behavior to
  122861. */
  122862. attach(camera: ArcRotateCamera): void;
  122863. /**
  122864. * Detaches the behavior from its current arc rotate camera.
  122865. */
  122866. detach(): void;
  122867. /**
  122868. * Returns true if user is scrolling.
  122869. * @return true if user is scrolling.
  122870. */
  122871. private _userIsZooming;
  122872. private _lastFrameRadius;
  122873. private _shouldAnimationStopForInteraction;
  122874. /**
  122875. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122876. */
  122877. private _applyUserInteraction;
  122878. private _userIsMoving;
  122879. }
  122880. }
  122881. declare module BABYLON {
  122882. /**
  122883. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  122884. */
  122885. export class AttachToBoxBehavior implements Behavior<Mesh> {
  122886. private ui;
  122887. /**
  122888. * The name of the behavior
  122889. */
  122890. name: string;
  122891. /**
  122892. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  122893. */
  122894. distanceAwayFromFace: number;
  122895. /**
  122896. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  122897. */
  122898. distanceAwayFromBottomOfFace: number;
  122899. private _faceVectors;
  122900. private _target;
  122901. private _scene;
  122902. private _onRenderObserver;
  122903. private _tmpMatrix;
  122904. private _tmpVector;
  122905. /**
  122906. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  122907. * @param ui The transform node that should be attched to the mesh
  122908. */
  122909. constructor(ui: TransformNode);
  122910. /**
  122911. * Initializes the behavior
  122912. */
  122913. init(): void;
  122914. private _closestFace;
  122915. private _zeroVector;
  122916. private _lookAtTmpMatrix;
  122917. private _lookAtToRef;
  122918. /**
  122919. * Attaches the AttachToBoxBehavior to the passed in mesh
  122920. * @param target The mesh that the specified node will be attached to
  122921. */
  122922. attach(target: Mesh): void;
  122923. /**
  122924. * Detaches the behavior from the mesh
  122925. */
  122926. detach(): void;
  122927. }
  122928. }
  122929. declare module BABYLON {
  122930. /**
  122931. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  122932. */
  122933. export class FadeInOutBehavior implements Behavior<Mesh> {
  122934. /**
  122935. * Time in milliseconds to delay before fading in (Default: 0)
  122936. */
  122937. delay: number;
  122938. /**
  122939. * Time in milliseconds for the mesh to fade in (Default: 300)
  122940. */
  122941. fadeInTime: number;
  122942. private _millisecondsPerFrame;
  122943. private _hovered;
  122944. private _hoverValue;
  122945. private _ownerNode;
  122946. /**
  122947. * Instatiates the FadeInOutBehavior
  122948. */
  122949. constructor();
  122950. /**
  122951. * The name of the behavior
  122952. */
  122953. get name(): string;
  122954. /**
  122955. * Initializes the behavior
  122956. */
  122957. init(): void;
  122958. /**
  122959. * Attaches the fade behavior on the passed in mesh
  122960. * @param ownerNode The mesh that will be faded in/out once attached
  122961. */
  122962. attach(ownerNode: Mesh): void;
  122963. /**
  122964. * Detaches the behavior from the mesh
  122965. */
  122966. detach(): void;
  122967. /**
  122968. * Triggers the mesh to begin fading in or out
  122969. * @param value if the object should fade in or out (true to fade in)
  122970. */
  122971. fadeIn(value: boolean): void;
  122972. private _update;
  122973. private _setAllVisibility;
  122974. }
  122975. }
  122976. declare module BABYLON {
  122977. /**
  122978. * Class containing a set of static utilities functions for managing Pivots
  122979. * @hidden
  122980. */
  122981. export class PivotTools {
  122982. private static _PivotCached;
  122983. private static _OldPivotPoint;
  122984. private static _PivotTranslation;
  122985. private static _PivotTmpVector;
  122986. /** @hidden */
  122987. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  122988. /** @hidden */
  122989. static _RestorePivotPoint(mesh: AbstractMesh): void;
  122990. }
  122991. }
  122992. declare module BABYLON {
  122993. /**
  122994. * Class containing static functions to help procedurally build meshes
  122995. */
  122996. export class PlaneBuilder {
  122997. /**
  122998. * Creates a plane mesh
  122999. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123000. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123001. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123005. * @param name defines the name of the mesh
  123006. * @param options defines the options used to create the mesh
  123007. * @param scene defines the hosting scene
  123008. * @returns the plane mesh
  123009. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123010. */
  123011. static CreatePlane(name: string, options: {
  123012. size?: number;
  123013. width?: number;
  123014. height?: number;
  123015. sideOrientation?: number;
  123016. frontUVs?: Vector4;
  123017. backUVs?: Vector4;
  123018. updatable?: boolean;
  123019. sourcePlane?: Plane;
  123020. }, scene?: Nullable<Scene>): Mesh;
  123021. }
  123022. }
  123023. declare module BABYLON {
  123024. /**
  123025. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  123026. */
  123027. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  123028. private static _AnyMouseID;
  123029. /**
  123030. * Abstract mesh the behavior is set on
  123031. */
  123032. attachedNode: AbstractMesh;
  123033. private _dragPlane;
  123034. private _scene;
  123035. private _pointerObserver;
  123036. private _beforeRenderObserver;
  123037. private static _planeScene;
  123038. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  123039. /**
  123040. * 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)
  123041. */
  123042. maxDragAngle: number;
  123043. /**
  123044. * @hidden
  123045. */
  123046. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  123047. /**
  123048. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123049. */
  123050. currentDraggingPointerID: number;
  123051. /**
  123052. * The last position where the pointer hit the drag plane in world space
  123053. */
  123054. lastDragPosition: Vector3;
  123055. /**
  123056. * If the behavior is currently in a dragging state
  123057. */
  123058. dragging: boolean;
  123059. /**
  123060. * 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)
  123061. */
  123062. dragDeltaRatio: number;
  123063. /**
  123064. * If the drag plane orientation should be updated during the dragging (Default: true)
  123065. */
  123066. updateDragPlane: boolean;
  123067. private _debugMode;
  123068. private _moving;
  123069. /**
  123070. * Fires each time the attached mesh is dragged with the pointer
  123071. * * delta between last drag position and current drag position in world space
  123072. * * dragDistance along the drag axis
  123073. * * dragPlaneNormal normal of the current drag plane used during the drag
  123074. * * dragPlanePoint in world space where the drag intersects the drag plane
  123075. */
  123076. onDragObservable: Observable<{
  123077. delta: Vector3;
  123078. dragPlanePoint: Vector3;
  123079. dragPlaneNormal: Vector3;
  123080. dragDistance: number;
  123081. pointerId: number;
  123082. }>;
  123083. /**
  123084. * Fires each time a drag begins (eg. mouse down on mesh)
  123085. */
  123086. onDragStartObservable: Observable<{
  123087. dragPlanePoint: Vector3;
  123088. pointerId: number;
  123089. }>;
  123090. /**
  123091. * Fires each time a drag ends (eg. mouse release after drag)
  123092. */
  123093. onDragEndObservable: Observable<{
  123094. dragPlanePoint: Vector3;
  123095. pointerId: number;
  123096. }>;
  123097. /**
  123098. * If the attached mesh should be moved when dragged
  123099. */
  123100. moveAttached: boolean;
  123101. /**
  123102. * If the drag behavior will react to drag events (Default: true)
  123103. */
  123104. enabled: boolean;
  123105. /**
  123106. * If pointer events should start and release the drag (Default: true)
  123107. */
  123108. startAndReleaseDragOnPointerEvents: boolean;
  123109. /**
  123110. * If camera controls should be detached during the drag
  123111. */
  123112. detachCameraControls: boolean;
  123113. /**
  123114. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  123115. */
  123116. useObjectOrientationForDragging: boolean;
  123117. private _options;
  123118. /**
  123119. * Gets the options used by the behavior
  123120. */
  123121. get options(): {
  123122. dragAxis?: Vector3;
  123123. dragPlaneNormal?: Vector3;
  123124. };
  123125. /**
  123126. * Sets the options used by the behavior
  123127. */
  123128. set options(options: {
  123129. dragAxis?: Vector3;
  123130. dragPlaneNormal?: Vector3;
  123131. });
  123132. /**
  123133. * Creates a pointer drag behavior that can be attached to a mesh
  123134. * @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)
  123135. */
  123136. constructor(options?: {
  123137. dragAxis?: Vector3;
  123138. dragPlaneNormal?: Vector3;
  123139. });
  123140. /**
  123141. * Predicate to determine if it is valid to move the object to a new position when it is moved
  123142. */
  123143. validateDrag: (targetPosition: Vector3) => boolean;
  123144. /**
  123145. * The name of the behavior
  123146. */
  123147. get name(): string;
  123148. /**
  123149. * Initializes the behavior
  123150. */
  123151. init(): void;
  123152. private _tmpVector;
  123153. private _alternatePickedPoint;
  123154. private _worldDragAxis;
  123155. private _targetPosition;
  123156. private _attachedElement;
  123157. /**
  123158. * Attaches the drag behavior the passed in mesh
  123159. * @param ownerNode The mesh that will be dragged around once attached
  123160. * @param predicate Predicate to use for pick filtering
  123161. */
  123162. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  123163. /**
  123164. * Force relase the drag action by code.
  123165. */
  123166. releaseDrag(): void;
  123167. private _startDragRay;
  123168. private _lastPointerRay;
  123169. /**
  123170. * Simulates the start of a pointer drag event on the behavior
  123171. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  123172. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  123173. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  123174. */
  123175. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  123176. private _startDrag;
  123177. private _dragDelta;
  123178. private _moveDrag;
  123179. private _pickWithRayOnDragPlane;
  123180. private _pointA;
  123181. private _pointC;
  123182. private _localAxis;
  123183. private _lookAt;
  123184. private _updateDragPlanePosition;
  123185. /**
  123186. * Detaches the behavior from the mesh
  123187. */
  123188. detach(): void;
  123189. }
  123190. }
  123191. declare module BABYLON {
  123192. /**
  123193. * A behavior that when attached to a mesh will allow the mesh to be scaled
  123194. */
  123195. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  123196. private _dragBehaviorA;
  123197. private _dragBehaviorB;
  123198. private _startDistance;
  123199. private _initialScale;
  123200. private _targetScale;
  123201. private _ownerNode;
  123202. private _sceneRenderObserver;
  123203. /**
  123204. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  123205. */
  123206. constructor();
  123207. /**
  123208. * The name of the behavior
  123209. */
  123210. get name(): string;
  123211. /**
  123212. * Initializes the behavior
  123213. */
  123214. init(): void;
  123215. private _getCurrentDistance;
  123216. /**
  123217. * Attaches the scale behavior the passed in mesh
  123218. * @param ownerNode The mesh that will be scaled around once attached
  123219. */
  123220. attach(ownerNode: Mesh): void;
  123221. /**
  123222. * Detaches the behavior from the mesh
  123223. */
  123224. detach(): void;
  123225. }
  123226. }
  123227. declare module BABYLON {
  123228. /**
  123229. * 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
  123230. */
  123231. export class SixDofDragBehavior implements Behavior<Mesh> {
  123232. private static _virtualScene;
  123233. private _ownerNode;
  123234. private _sceneRenderObserver;
  123235. private _scene;
  123236. private _targetPosition;
  123237. private _virtualOriginMesh;
  123238. private _virtualDragMesh;
  123239. private _pointerObserver;
  123240. private _moving;
  123241. private _startingOrientation;
  123242. private _attachedElement;
  123243. /**
  123244. * 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)
  123245. */
  123246. private zDragFactor;
  123247. /**
  123248. * If the object should rotate to face the drag origin
  123249. */
  123250. rotateDraggedObject: boolean;
  123251. /**
  123252. * If the behavior is currently in a dragging state
  123253. */
  123254. dragging: boolean;
  123255. /**
  123256. * 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)
  123257. */
  123258. dragDeltaRatio: number;
  123259. /**
  123260. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123261. */
  123262. currentDraggingPointerID: number;
  123263. /**
  123264. * If camera controls should be detached during the drag
  123265. */
  123266. detachCameraControls: boolean;
  123267. /**
  123268. * Fires each time a drag starts
  123269. */
  123270. onDragStartObservable: Observable<{}>;
  123271. /**
  123272. * Fires each time a drag ends (eg. mouse release after drag)
  123273. */
  123274. onDragEndObservable: Observable<{}>;
  123275. /**
  123276. * 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
  123277. */
  123278. constructor();
  123279. /**
  123280. * The name of the behavior
  123281. */
  123282. get name(): string;
  123283. /**
  123284. * Initializes the behavior
  123285. */
  123286. init(): void;
  123287. /**
  123288. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  123289. */
  123290. private get _pointerCamera();
  123291. /**
  123292. * Attaches the scale behavior the passed in mesh
  123293. * @param ownerNode The mesh that will be scaled around once attached
  123294. */
  123295. attach(ownerNode: Mesh): void;
  123296. /**
  123297. * Detaches the behavior from the mesh
  123298. */
  123299. detach(): void;
  123300. }
  123301. }
  123302. declare module BABYLON {
  123303. /**
  123304. * Class used to apply inverse kinematics to bones
  123305. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  123306. */
  123307. export class BoneIKController {
  123308. private static _tmpVecs;
  123309. private static _tmpQuat;
  123310. private static _tmpMats;
  123311. /**
  123312. * Gets or sets the target mesh
  123313. */
  123314. targetMesh: AbstractMesh;
  123315. /** Gets or sets the mesh used as pole */
  123316. poleTargetMesh: AbstractMesh;
  123317. /**
  123318. * Gets or sets the bone used as pole
  123319. */
  123320. poleTargetBone: Nullable<Bone>;
  123321. /**
  123322. * Gets or sets the target position
  123323. */
  123324. targetPosition: Vector3;
  123325. /**
  123326. * Gets or sets the pole target position
  123327. */
  123328. poleTargetPosition: Vector3;
  123329. /**
  123330. * Gets or sets the pole target local offset
  123331. */
  123332. poleTargetLocalOffset: Vector3;
  123333. /**
  123334. * Gets or sets the pole angle
  123335. */
  123336. poleAngle: number;
  123337. /**
  123338. * Gets or sets the mesh associated with the controller
  123339. */
  123340. mesh: AbstractMesh;
  123341. /**
  123342. * 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)
  123343. */
  123344. slerpAmount: number;
  123345. private _bone1Quat;
  123346. private _bone1Mat;
  123347. private _bone2Ang;
  123348. private _bone1;
  123349. private _bone2;
  123350. private _bone1Length;
  123351. private _bone2Length;
  123352. private _maxAngle;
  123353. private _maxReach;
  123354. private _rightHandedSystem;
  123355. private _bendAxis;
  123356. private _slerping;
  123357. private _adjustRoll;
  123358. /**
  123359. * Gets or sets maximum allowed angle
  123360. */
  123361. get maxAngle(): number;
  123362. set maxAngle(value: number);
  123363. /**
  123364. * Creates a new BoneIKController
  123365. * @param mesh defines the mesh to control
  123366. * @param bone defines the bone to control
  123367. * @param options defines options to set up the controller
  123368. */
  123369. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  123370. targetMesh?: AbstractMesh;
  123371. poleTargetMesh?: AbstractMesh;
  123372. poleTargetBone?: Bone;
  123373. poleTargetLocalOffset?: Vector3;
  123374. poleAngle?: number;
  123375. bendAxis?: Vector3;
  123376. maxAngle?: number;
  123377. slerpAmount?: number;
  123378. });
  123379. private _setMaxAngle;
  123380. /**
  123381. * Force the controller to update the bones
  123382. */
  123383. update(): void;
  123384. }
  123385. }
  123386. declare module BABYLON {
  123387. /**
  123388. * Class used to make a bone look toward a point in space
  123389. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  123390. */
  123391. export class BoneLookController {
  123392. private static _tmpVecs;
  123393. private static _tmpQuat;
  123394. private static _tmpMats;
  123395. /**
  123396. * The target Vector3 that the bone will look at
  123397. */
  123398. target: Vector3;
  123399. /**
  123400. * The mesh that the bone is attached to
  123401. */
  123402. mesh: AbstractMesh;
  123403. /**
  123404. * The bone that will be looking to the target
  123405. */
  123406. bone: Bone;
  123407. /**
  123408. * The up axis of the coordinate system that is used when the bone is rotated
  123409. */
  123410. upAxis: Vector3;
  123411. /**
  123412. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  123413. */
  123414. upAxisSpace: Space;
  123415. /**
  123416. * Used to make an adjustment to the yaw of the bone
  123417. */
  123418. adjustYaw: number;
  123419. /**
  123420. * Used to make an adjustment to the pitch of the bone
  123421. */
  123422. adjustPitch: number;
  123423. /**
  123424. * Used to make an adjustment to the roll of the bone
  123425. */
  123426. adjustRoll: number;
  123427. /**
  123428. * 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)
  123429. */
  123430. slerpAmount: number;
  123431. private _minYaw;
  123432. private _maxYaw;
  123433. private _minPitch;
  123434. private _maxPitch;
  123435. private _minYawSin;
  123436. private _minYawCos;
  123437. private _maxYawSin;
  123438. private _maxYawCos;
  123439. private _midYawConstraint;
  123440. private _minPitchTan;
  123441. private _maxPitchTan;
  123442. private _boneQuat;
  123443. private _slerping;
  123444. private _transformYawPitch;
  123445. private _transformYawPitchInv;
  123446. private _firstFrameSkipped;
  123447. private _yawRange;
  123448. private _fowardAxis;
  123449. /**
  123450. * Gets or sets the minimum yaw angle that the bone can look to
  123451. */
  123452. get minYaw(): number;
  123453. set minYaw(value: number);
  123454. /**
  123455. * Gets or sets the maximum yaw angle that the bone can look to
  123456. */
  123457. get maxYaw(): number;
  123458. set maxYaw(value: number);
  123459. /**
  123460. * Gets or sets the minimum pitch angle that the bone can look to
  123461. */
  123462. get minPitch(): number;
  123463. set minPitch(value: number);
  123464. /**
  123465. * Gets or sets the maximum pitch angle that the bone can look to
  123466. */
  123467. get maxPitch(): number;
  123468. set maxPitch(value: number);
  123469. /**
  123470. * Create a BoneLookController
  123471. * @param mesh the mesh that the bone belongs to
  123472. * @param bone the bone that will be looking to the target
  123473. * @param target the target Vector3 to look at
  123474. * @param options optional settings:
  123475. * * maxYaw: the maximum angle the bone will yaw to
  123476. * * minYaw: the minimum angle the bone will yaw to
  123477. * * maxPitch: the maximum angle the bone will pitch to
  123478. * * minPitch: the minimum angle the bone will yaw to
  123479. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  123480. * * upAxis: the up axis of the coordinate system
  123481. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  123482. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  123483. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  123484. * * adjustYaw: used to make an adjustment to the yaw of the bone
  123485. * * adjustPitch: used to make an adjustment to the pitch of the bone
  123486. * * adjustRoll: used to make an adjustment to the roll of the bone
  123487. **/
  123488. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  123489. maxYaw?: number;
  123490. minYaw?: number;
  123491. maxPitch?: number;
  123492. minPitch?: number;
  123493. slerpAmount?: number;
  123494. upAxis?: Vector3;
  123495. upAxisSpace?: Space;
  123496. yawAxis?: Vector3;
  123497. pitchAxis?: Vector3;
  123498. adjustYaw?: number;
  123499. adjustPitch?: number;
  123500. adjustRoll?: number;
  123501. });
  123502. /**
  123503. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  123504. */
  123505. update(): void;
  123506. private _getAngleDiff;
  123507. private _getAngleBetween;
  123508. private _isAngleBetween;
  123509. }
  123510. }
  123511. declare module BABYLON {
  123512. /**
  123513. * Manage the gamepad inputs to control an arc rotate camera.
  123514. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123515. */
  123516. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  123517. /**
  123518. * Defines the camera the input is attached to.
  123519. */
  123520. camera: ArcRotateCamera;
  123521. /**
  123522. * Defines the gamepad the input is gathering event from.
  123523. */
  123524. gamepad: Nullable<Gamepad>;
  123525. /**
  123526. * Defines the gamepad rotation sensiblity.
  123527. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123528. */
  123529. gamepadRotationSensibility: number;
  123530. /**
  123531. * Defines the gamepad move sensiblity.
  123532. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123533. */
  123534. gamepadMoveSensibility: number;
  123535. private _yAxisScale;
  123536. /**
  123537. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  123538. */
  123539. get invertYAxis(): boolean;
  123540. set invertYAxis(value: boolean);
  123541. private _onGamepadConnectedObserver;
  123542. private _onGamepadDisconnectedObserver;
  123543. /**
  123544. * Attach the input controls to a specific dom element to get the input from.
  123545. * @param element Defines the element the controls should be listened from
  123546. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123547. */
  123548. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123549. /**
  123550. * Detach the current controls from the specified dom element.
  123551. * @param element Defines the element to stop listening the inputs from
  123552. */
  123553. detachControl(element: Nullable<HTMLElement>): void;
  123554. /**
  123555. * Update the current camera state depending on the inputs that have been used this frame.
  123556. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123557. */
  123558. checkInputs(): void;
  123559. /**
  123560. * Gets the class name of the current intput.
  123561. * @returns the class name
  123562. */
  123563. getClassName(): string;
  123564. /**
  123565. * Get the friendly name associated with the input class.
  123566. * @returns the input friendly name
  123567. */
  123568. getSimpleName(): string;
  123569. }
  123570. }
  123571. declare module BABYLON {
  123572. interface ArcRotateCameraInputsManager {
  123573. /**
  123574. * Add orientation input support to the input manager.
  123575. * @returns the current input manager
  123576. */
  123577. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  123578. }
  123579. /**
  123580. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  123581. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123582. */
  123583. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  123584. /**
  123585. * Defines the camera the input is attached to.
  123586. */
  123587. camera: ArcRotateCamera;
  123588. /**
  123589. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  123590. */
  123591. alphaCorrection: number;
  123592. /**
  123593. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  123594. */
  123595. gammaCorrection: number;
  123596. private _alpha;
  123597. private _gamma;
  123598. private _dirty;
  123599. private _deviceOrientationHandler;
  123600. /**
  123601. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  123602. */
  123603. constructor();
  123604. /**
  123605. * Attach the input controls to a specific dom element to get the input from.
  123606. * @param element Defines the element the controls should be listened from
  123607. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123608. */
  123609. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123610. /** @hidden */
  123611. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  123612. /**
  123613. * Update the current camera state depending on the inputs that have been used this frame.
  123614. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123615. */
  123616. checkInputs(): void;
  123617. /**
  123618. * Detach the current controls from the specified dom element.
  123619. * @param element Defines the element to stop listening the inputs from
  123620. */
  123621. detachControl(element: Nullable<HTMLElement>): void;
  123622. /**
  123623. * Gets the class name of the current intput.
  123624. * @returns the class name
  123625. */
  123626. getClassName(): string;
  123627. /**
  123628. * Get the friendly name associated with the input class.
  123629. * @returns the input friendly name
  123630. */
  123631. getSimpleName(): string;
  123632. }
  123633. }
  123634. declare module BABYLON {
  123635. /**
  123636. * Listen to mouse events to control the camera.
  123637. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123638. */
  123639. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  123640. /**
  123641. * Defines the camera the input is attached to.
  123642. */
  123643. camera: FlyCamera;
  123644. /**
  123645. * Defines if touch is enabled. (Default is true.)
  123646. */
  123647. touchEnabled: boolean;
  123648. /**
  123649. * Defines the buttons associated with the input to handle camera rotation.
  123650. */
  123651. buttons: number[];
  123652. /**
  123653. * Assign buttons for Yaw control.
  123654. */
  123655. buttonsYaw: number[];
  123656. /**
  123657. * Assign buttons for Pitch control.
  123658. */
  123659. buttonsPitch: number[];
  123660. /**
  123661. * Assign buttons for Roll control.
  123662. */
  123663. buttonsRoll: number[];
  123664. /**
  123665. * Detect if any button is being pressed while mouse is moved.
  123666. * -1 = Mouse locked.
  123667. * 0 = Left button.
  123668. * 1 = Middle Button.
  123669. * 2 = Right Button.
  123670. */
  123671. activeButton: number;
  123672. /**
  123673. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  123674. * Higher values reduce its sensitivity.
  123675. */
  123676. angularSensibility: number;
  123677. private _mousemoveCallback;
  123678. private _observer;
  123679. private _rollObserver;
  123680. private previousPosition;
  123681. private noPreventDefault;
  123682. private element;
  123683. /**
  123684. * Listen to mouse events to control the camera.
  123685. * @param touchEnabled Define if touch is enabled. (Default is true.)
  123686. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123687. */
  123688. constructor(touchEnabled?: boolean);
  123689. /**
  123690. * Attach the mouse control to the HTML DOM element.
  123691. * @param element Defines the element that listens to the input events.
  123692. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  123693. */
  123694. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123695. /**
  123696. * Detach the current controls from the specified dom element.
  123697. * @param element Defines the element to stop listening the inputs from
  123698. */
  123699. detachControl(element: Nullable<HTMLElement>): void;
  123700. /**
  123701. * Gets the class name of the current input.
  123702. * @returns the class name.
  123703. */
  123704. getClassName(): string;
  123705. /**
  123706. * Get the friendly name associated with the input class.
  123707. * @returns the input's friendly name.
  123708. */
  123709. getSimpleName(): string;
  123710. private _pointerInput;
  123711. private _onMouseMove;
  123712. /**
  123713. * Rotate camera by mouse offset.
  123714. */
  123715. private rotateCamera;
  123716. }
  123717. }
  123718. declare module BABYLON {
  123719. /**
  123720. * Default Inputs manager for the FlyCamera.
  123721. * It groups all the default supported inputs for ease of use.
  123722. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123723. */
  123724. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  123725. /**
  123726. * Instantiates a new FlyCameraInputsManager.
  123727. * @param camera Defines the camera the inputs belong to.
  123728. */
  123729. constructor(camera: FlyCamera);
  123730. /**
  123731. * Add keyboard input support to the input manager.
  123732. * @returns the new FlyCameraKeyboardMoveInput().
  123733. */
  123734. addKeyboard(): FlyCameraInputsManager;
  123735. /**
  123736. * Add mouse input support to the input manager.
  123737. * @param touchEnabled Enable touch screen support.
  123738. * @returns the new FlyCameraMouseInput().
  123739. */
  123740. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  123741. }
  123742. }
  123743. declare module BABYLON {
  123744. /**
  123745. * This is a flying camera, designed for 3D movement and rotation in all directions,
  123746. * such as in a 3D Space Shooter or a Flight Simulator.
  123747. */
  123748. export class FlyCamera extends TargetCamera {
  123749. /**
  123750. * Define the collision ellipsoid of the camera.
  123751. * This is helpful for simulating a camera body, like a player's body.
  123752. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123753. */
  123754. ellipsoid: Vector3;
  123755. /**
  123756. * Define an offset for the position of the ellipsoid around the camera.
  123757. * This can be helpful if the camera is attached away from the player's body center,
  123758. * such as at its head.
  123759. */
  123760. ellipsoidOffset: Vector3;
  123761. /**
  123762. * Enable or disable collisions of the camera with the rest of the scene objects.
  123763. */
  123764. checkCollisions: boolean;
  123765. /**
  123766. * Enable or disable gravity on the camera.
  123767. */
  123768. applyGravity: boolean;
  123769. /**
  123770. * Define the current direction the camera is moving to.
  123771. */
  123772. cameraDirection: Vector3;
  123773. /**
  123774. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  123775. * This overrides and empties cameraRotation.
  123776. */
  123777. rotationQuaternion: Quaternion;
  123778. /**
  123779. * Track Roll to maintain the wanted Rolling when looking around.
  123780. */
  123781. _trackRoll: number;
  123782. /**
  123783. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  123784. */
  123785. rollCorrect: number;
  123786. /**
  123787. * Mimic a banked turn, Rolling the camera when Yawing.
  123788. * It's recommended to use rollCorrect = 10 for faster banking correction.
  123789. */
  123790. bankedTurn: boolean;
  123791. /**
  123792. * Limit in radians for how much Roll banking will add. (Default: 90°)
  123793. */
  123794. bankedTurnLimit: number;
  123795. /**
  123796. * Value of 0 disables the banked Roll.
  123797. * Value of 1 is equal to the Yaw angle in radians.
  123798. */
  123799. bankedTurnMultiplier: number;
  123800. /**
  123801. * The inputs manager loads all the input sources, such as keyboard and mouse.
  123802. */
  123803. inputs: FlyCameraInputsManager;
  123804. /**
  123805. * Gets the input sensibility for mouse input.
  123806. * Higher values reduce sensitivity.
  123807. */
  123808. get angularSensibility(): number;
  123809. /**
  123810. * Sets the input sensibility for a mouse input.
  123811. * Higher values reduce sensitivity.
  123812. */
  123813. set angularSensibility(value: number);
  123814. /**
  123815. * Get the keys for camera movement forward.
  123816. */
  123817. get keysForward(): number[];
  123818. /**
  123819. * Set the keys for camera movement forward.
  123820. */
  123821. set keysForward(value: number[]);
  123822. /**
  123823. * Get the keys for camera movement backward.
  123824. */
  123825. get keysBackward(): number[];
  123826. set keysBackward(value: number[]);
  123827. /**
  123828. * Get the keys for camera movement up.
  123829. */
  123830. get keysUp(): number[];
  123831. /**
  123832. * Set the keys for camera movement up.
  123833. */
  123834. set keysUp(value: number[]);
  123835. /**
  123836. * Get the keys for camera movement down.
  123837. */
  123838. get keysDown(): number[];
  123839. /**
  123840. * Set the keys for camera movement down.
  123841. */
  123842. set keysDown(value: number[]);
  123843. /**
  123844. * Get the keys for camera movement left.
  123845. */
  123846. get keysLeft(): number[];
  123847. /**
  123848. * Set the keys for camera movement left.
  123849. */
  123850. set keysLeft(value: number[]);
  123851. /**
  123852. * Set the keys for camera movement right.
  123853. */
  123854. get keysRight(): number[];
  123855. /**
  123856. * Set the keys for camera movement right.
  123857. */
  123858. set keysRight(value: number[]);
  123859. /**
  123860. * Event raised when the camera collides with a mesh in the scene.
  123861. */
  123862. onCollide: (collidedMesh: AbstractMesh) => void;
  123863. private _collider;
  123864. private _needMoveForGravity;
  123865. private _oldPosition;
  123866. private _diffPosition;
  123867. private _newPosition;
  123868. /** @hidden */
  123869. _localDirection: Vector3;
  123870. /** @hidden */
  123871. _transformedDirection: Vector3;
  123872. /**
  123873. * Instantiates a FlyCamera.
  123874. * This is a flying camera, designed for 3D movement and rotation in all directions,
  123875. * such as in a 3D Space Shooter or a Flight Simulator.
  123876. * @param name Define the name of the camera in the scene.
  123877. * @param position Define the starting position of the camera in the scene.
  123878. * @param scene Define the scene the camera belongs to.
  123879. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  123880. */
  123881. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123882. /**
  123883. * Attach a control to the HTML DOM element.
  123884. * @param element Defines the element that listens to the input events.
  123885. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  123886. */
  123887. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123888. /**
  123889. * Detach a control from the HTML DOM element.
  123890. * The camera will stop reacting to that input.
  123891. * @param element Defines the element that listens to the input events.
  123892. */
  123893. detachControl(element: HTMLElement): void;
  123894. private _collisionMask;
  123895. /**
  123896. * Get the mask that the camera ignores in collision events.
  123897. */
  123898. get collisionMask(): number;
  123899. /**
  123900. * Set the mask that the camera ignores in collision events.
  123901. */
  123902. set collisionMask(mask: number);
  123903. /** @hidden */
  123904. _collideWithWorld(displacement: Vector3): void;
  123905. /** @hidden */
  123906. private _onCollisionPositionChange;
  123907. /** @hidden */
  123908. _checkInputs(): void;
  123909. /** @hidden */
  123910. _decideIfNeedsToMove(): boolean;
  123911. /** @hidden */
  123912. _updatePosition(): void;
  123913. /**
  123914. * Restore the Roll to its target value at the rate specified.
  123915. * @param rate - Higher means slower restoring.
  123916. * @hidden
  123917. */
  123918. restoreRoll(rate: number): void;
  123919. /**
  123920. * Destroy the camera and release the current resources held by it.
  123921. */
  123922. dispose(): void;
  123923. /**
  123924. * Get the current object class name.
  123925. * @returns the class name.
  123926. */
  123927. getClassName(): string;
  123928. }
  123929. }
  123930. declare module BABYLON {
  123931. /**
  123932. * Listen to keyboard events to control the camera.
  123933. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123934. */
  123935. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  123936. /**
  123937. * Defines the camera the input is attached to.
  123938. */
  123939. camera: FlyCamera;
  123940. /**
  123941. * The list of keyboard keys used to control the forward move of the camera.
  123942. */
  123943. keysForward: number[];
  123944. /**
  123945. * The list of keyboard keys used to control the backward move of the camera.
  123946. */
  123947. keysBackward: number[];
  123948. /**
  123949. * The list of keyboard keys used to control the forward move of the camera.
  123950. */
  123951. keysUp: number[];
  123952. /**
  123953. * The list of keyboard keys used to control the backward move of the camera.
  123954. */
  123955. keysDown: number[];
  123956. /**
  123957. * The list of keyboard keys used to control the right strafe move of the camera.
  123958. */
  123959. keysRight: number[];
  123960. /**
  123961. * The list of keyboard keys used to control the left strafe move of the camera.
  123962. */
  123963. keysLeft: number[];
  123964. private _keys;
  123965. private _onCanvasBlurObserver;
  123966. private _onKeyboardObserver;
  123967. private _engine;
  123968. private _scene;
  123969. /**
  123970. * Attach the input controls to a specific dom element to get the input from.
  123971. * @param element Defines the element the controls should be listened from
  123972. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123973. */
  123974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123975. /**
  123976. * Detach the current controls from the specified dom element.
  123977. * @param element Defines the element to stop listening the inputs from
  123978. */
  123979. detachControl(element: Nullable<HTMLElement>): void;
  123980. /**
  123981. * Gets the class name of the current intput.
  123982. * @returns the class name
  123983. */
  123984. getClassName(): string;
  123985. /** @hidden */
  123986. _onLostFocus(e: FocusEvent): void;
  123987. /**
  123988. * Get the friendly name associated with the input class.
  123989. * @returns the input friendly name
  123990. */
  123991. getSimpleName(): string;
  123992. /**
  123993. * Update the current camera state depending on the inputs that have been used this frame.
  123994. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123995. */
  123996. checkInputs(): void;
  123997. }
  123998. }
  123999. declare module BABYLON {
  124000. /**
  124001. * Manage the mouse wheel inputs to control a follow camera.
  124002. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124003. */
  124004. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  124005. /**
  124006. * Defines the camera the input is attached to.
  124007. */
  124008. camera: FollowCamera;
  124009. /**
  124010. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  124011. */
  124012. axisControlRadius: boolean;
  124013. /**
  124014. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  124015. */
  124016. axisControlHeight: boolean;
  124017. /**
  124018. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  124019. */
  124020. axisControlRotation: boolean;
  124021. /**
  124022. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  124023. * relation to mouseWheel events.
  124024. */
  124025. wheelPrecision: number;
  124026. /**
  124027. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  124028. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  124029. */
  124030. wheelDeltaPercentage: number;
  124031. private _wheel;
  124032. private _observer;
  124033. /**
  124034. * Attach the input controls to a specific dom element to get the input from.
  124035. * @param element Defines the element the controls should be listened from
  124036. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124037. */
  124038. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124039. /**
  124040. * Detach the current controls from the specified dom element.
  124041. * @param element Defines the element to stop listening the inputs from
  124042. */
  124043. detachControl(element: Nullable<HTMLElement>): void;
  124044. /**
  124045. * Gets the class name of the current intput.
  124046. * @returns the class name
  124047. */
  124048. getClassName(): string;
  124049. /**
  124050. * Get the friendly name associated with the input class.
  124051. * @returns the input friendly name
  124052. */
  124053. getSimpleName(): string;
  124054. }
  124055. }
  124056. declare module BABYLON {
  124057. /**
  124058. * Manage the pointers inputs to control an follow camera.
  124059. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124060. */
  124061. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  124062. /**
  124063. * Defines the camera the input is attached to.
  124064. */
  124065. camera: FollowCamera;
  124066. /**
  124067. * Gets the class name of the current input.
  124068. * @returns the class name
  124069. */
  124070. getClassName(): string;
  124071. /**
  124072. * Defines the pointer angular sensibility along the X axis or how fast is
  124073. * the camera rotating.
  124074. * A negative number will reverse the axis direction.
  124075. */
  124076. angularSensibilityX: number;
  124077. /**
  124078. * Defines the pointer angular sensibility along the Y axis or how fast is
  124079. * the camera rotating.
  124080. * A negative number will reverse the axis direction.
  124081. */
  124082. angularSensibilityY: number;
  124083. /**
  124084. * Defines the pointer pinch precision or how fast is the camera zooming.
  124085. * A negative number will reverse the axis direction.
  124086. */
  124087. pinchPrecision: number;
  124088. /**
  124089. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  124090. * from 0.
  124091. * It defines the percentage of current camera.radius to use as delta when
  124092. * pinch zoom is used.
  124093. */
  124094. pinchDeltaPercentage: number;
  124095. /**
  124096. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  124097. */
  124098. axisXControlRadius: boolean;
  124099. /**
  124100. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  124101. */
  124102. axisXControlHeight: boolean;
  124103. /**
  124104. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  124105. */
  124106. axisXControlRotation: boolean;
  124107. /**
  124108. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  124109. */
  124110. axisYControlRadius: boolean;
  124111. /**
  124112. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  124113. */
  124114. axisYControlHeight: boolean;
  124115. /**
  124116. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  124117. */
  124118. axisYControlRotation: boolean;
  124119. /**
  124120. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  124121. */
  124122. axisPinchControlRadius: boolean;
  124123. /**
  124124. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  124125. */
  124126. axisPinchControlHeight: boolean;
  124127. /**
  124128. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  124129. */
  124130. axisPinchControlRotation: boolean;
  124131. /**
  124132. * Log error messages if basic misconfiguration has occurred.
  124133. */
  124134. warningEnable: boolean;
  124135. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  124136. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  124137. private _warningCounter;
  124138. private _warning;
  124139. }
  124140. }
  124141. declare module BABYLON {
  124142. /**
  124143. * Default Inputs manager for the FollowCamera.
  124144. * It groups all the default supported inputs for ease of use.
  124145. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124146. */
  124147. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  124148. /**
  124149. * Instantiates a new FollowCameraInputsManager.
  124150. * @param camera Defines the camera the inputs belong to
  124151. */
  124152. constructor(camera: FollowCamera);
  124153. /**
  124154. * Add keyboard input support to the input manager.
  124155. * @returns the current input manager
  124156. */
  124157. addKeyboard(): FollowCameraInputsManager;
  124158. /**
  124159. * Add mouse wheel input support to the input manager.
  124160. * @returns the current input manager
  124161. */
  124162. addMouseWheel(): FollowCameraInputsManager;
  124163. /**
  124164. * Add pointers input support to the input manager.
  124165. * @returns the current input manager
  124166. */
  124167. addPointers(): FollowCameraInputsManager;
  124168. /**
  124169. * Add orientation input support to the input manager.
  124170. * @returns the current input manager
  124171. */
  124172. addVRDeviceOrientation(): FollowCameraInputsManager;
  124173. }
  124174. }
  124175. declare module BABYLON {
  124176. /**
  124177. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  124178. * an arc rotate version arcFollowCamera are available.
  124179. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124180. */
  124181. export class FollowCamera extends TargetCamera {
  124182. /**
  124183. * Distance the follow camera should follow an object at
  124184. */
  124185. radius: number;
  124186. /**
  124187. * Minimum allowed distance of the camera to the axis of rotation
  124188. * (The camera can not get closer).
  124189. * This can help limiting how the Camera is able to move in the scene.
  124190. */
  124191. lowerRadiusLimit: Nullable<number>;
  124192. /**
  124193. * Maximum allowed distance of the camera to the axis of rotation
  124194. * (The camera can not get further).
  124195. * This can help limiting how the Camera is able to move in the scene.
  124196. */
  124197. upperRadiusLimit: Nullable<number>;
  124198. /**
  124199. * Define a rotation offset between the camera and the object it follows
  124200. */
  124201. rotationOffset: number;
  124202. /**
  124203. * Minimum allowed angle to camera position relative to target object.
  124204. * This can help limiting how the Camera is able to move in the scene.
  124205. */
  124206. lowerRotationOffsetLimit: Nullable<number>;
  124207. /**
  124208. * Maximum allowed angle to camera position relative to target object.
  124209. * This can help limiting how the Camera is able to move in the scene.
  124210. */
  124211. upperRotationOffsetLimit: Nullable<number>;
  124212. /**
  124213. * Define a height offset between the camera and the object it follows.
  124214. * It can help following an object from the top (like a car chaing a plane)
  124215. */
  124216. heightOffset: number;
  124217. /**
  124218. * Minimum allowed height of camera position relative to target object.
  124219. * This can help limiting how the Camera is able to move in the scene.
  124220. */
  124221. lowerHeightOffsetLimit: Nullable<number>;
  124222. /**
  124223. * Maximum allowed height of camera position relative to target object.
  124224. * This can help limiting how the Camera is able to move in the scene.
  124225. */
  124226. upperHeightOffsetLimit: Nullable<number>;
  124227. /**
  124228. * Define how fast the camera can accelerate to follow it s target.
  124229. */
  124230. cameraAcceleration: number;
  124231. /**
  124232. * Define the speed limit of the camera following an object.
  124233. */
  124234. maxCameraSpeed: number;
  124235. /**
  124236. * Define the target of the camera.
  124237. */
  124238. lockedTarget: Nullable<AbstractMesh>;
  124239. /**
  124240. * Defines the input associated with the camera.
  124241. */
  124242. inputs: FollowCameraInputsManager;
  124243. /**
  124244. * Instantiates the follow camera.
  124245. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124246. * @param name Define the name of the camera in the scene
  124247. * @param position Define the position of the camera
  124248. * @param scene Define the scene the camera belong to
  124249. * @param lockedTarget Define the target of the camera
  124250. */
  124251. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  124252. private _follow;
  124253. /**
  124254. * Attached controls to the current camera.
  124255. * @param element Defines the element the controls should be listened from
  124256. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124257. */
  124258. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124259. /**
  124260. * Detach the current controls from the camera.
  124261. * The camera will stop reacting to inputs.
  124262. * @param element Defines the element to stop listening the inputs from
  124263. */
  124264. detachControl(element: HTMLElement): void;
  124265. /** @hidden */
  124266. _checkInputs(): void;
  124267. private _checkLimits;
  124268. /**
  124269. * Gets the camera class name.
  124270. * @returns the class name
  124271. */
  124272. getClassName(): string;
  124273. }
  124274. /**
  124275. * Arc Rotate version of the follow camera.
  124276. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  124277. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124278. */
  124279. export class ArcFollowCamera extends TargetCamera {
  124280. /** The longitudinal angle of the camera */
  124281. alpha: number;
  124282. /** The latitudinal angle of the camera */
  124283. beta: number;
  124284. /** The radius of the camera from its target */
  124285. radius: number;
  124286. private _cartesianCoordinates;
  124287. /** Define the camera target (the mesh it should follow) */
  124288. private _meshTarget;
  124289. /**
  124290. * Instantiates a new ArcFollowCamera
  124291. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124292. * @param name Define the name of the camera
  124293. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  124294. * @param beta Define the rotation angle of the camera around the elevation axis
  124295. * @param radius Define the radius of the camera from its target point
  124296. * @param target Define the target of the camera
  124297. * @param scene Define the scene the camera belongs to
  124298. */
  124299. constructor(name: string,
  124300. /** The longitudinal angle of the camera */
  124301. alpha: number,
  124302. /** The latitudinal angle of the camera */
  124303. beta: number,
  124304. /** The radius of the camera from its target */
  124305. radius: number,
  124306. /** Define the camera target (the mesh it should follow) */
  124307. target: Nullable<AbstractMesh>, scene: Scene);
  124308. private _follow;
  124309. /** @hidden */
  124310. _checkInputs(): void;
  124311. /**
  124312. * Returns the class name of the object.
  124313. * It is mostly used internally for serialization purposes.
  124314. */
  124315. getClassName(): string;
  124316. }
  124317. }
  124318. declare module BABYLON {
  124319. /**
  124320. * Manage the keyboard inputs to control the movement of a follow camera.
  124321. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124322. */
  124323. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  124324. /**
  124325. * Defines the camera the input is attached to.
  124326. */
  124327. camera: FollowCamera;
  124328. /**
  124329. * Defines the list of key codes associated with the up action (increase heightOffset)
  124330. */
  124331. keysHeightOffsetIncr: number[];
  124332. /**
  124333. * Defines the list of key codes associated with the down action (decrease heightOffset)
  124334. */
  124335. keysHeightOffsetDecr: number[];
  124336. /**
  124337. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  124338. */
  124339. keysHeightOffsetModifierAlt: boolean;
  124340. /**
  124341. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  124342. */
  124343. keysHeightOffsetModifierCtrl: boolean;
  124344. /**
  124345. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  124346. */
  124347. keysHeightOffsetModifierShift: boolean;
  124348. /**
  124349. * Defines the list of key codes associated with the left action (increase rotationOffset)
  124350. */
  124351. keysRotationOffsetIncr: number[];
  124352. /**
  124353. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  124354. */
  124355. keysRotationOffsetDecr: number[];
  124356. /**
  124357. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  124358. */
  124359. keysRotationOffsetModifierAlt: boolean;
  124360. /**
  124361. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  124362. */
  124363. keysRotationOffsetModifierCtrl: boolean;
  124364. /**
  124365. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  124366. */
  124367. keysRotationOffsetModifierShift: boolean;
  124368. /**
  124369. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  124370. */
  124371. keysRadiusIncr: number[];
  124372. /**
  124373. * Defines the list of key codes associated with the zoom-out action (increase radius)
  124374. */
  124375. keysRadiusDecr: number[];
  124376. /**
  124377. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  124378. */
  124379. keysRadiusModifierAlt: boolean;
  124380. /**
  124381. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  124382. */
  124383. keysRadiusModifierCtrl: boolean;
  124384. /**
  124385. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  124386. */
  124387. keysRadiusModifierShift: boolean;
  124388. /**
  124389. * Defines the rate of change of heightOffset.
  124390. */
  124391. heightSensibility: number;
  124392. /**
  124393. * Defines the rate of change of rotationOffset.
  124394. */
  124395. rotationSensibility: number;
  124396. /**
  124397. * Defines the rate of change of radius.
  124398. */
  124399. radiusSensibility: number;
  124400. private _keys;
  124401. private _ctrlPressed;
  124402. private _altPressed;
  124403. private _shiftPressed;
  124404. private _onCanvasBlurObserver;
  124405. private _onKeyboardObserver;
  124406. private _engine;
  124407. private _scene;
  124408. /**
  124409. * Attach the input controls to a specific dom element to get the input from.
  124410. * @param element Defines the element the controls should be listened from
  124411. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124412. */
  124413. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124414. /**
  124415. * Detach the current controls from the specified dom element.
  124416. * @param element Defines the element to stop listening the inputs from
  124417. */
  124418. detachControl(element: Nullable<HTMLElement>): void;
  124419. /**
  124420. * Update the current camera state depending on the inputs that have been used this frame.
  124421. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124422. */
  124423. checkInputs(): void;
  124424. /**
  124425. * Gets the class name of the current input.
  124426. * @returns the class name
  124427. */
  124428. getClassName(): string;
  124429. /**
  124430. * Get the friendly name associated with the input class.
  124431. * @returns the input friendly name
  124432. */
  124433. getSimpleName(): string;
  124434. /**
  124435. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124436. * allow modification of the heightOffset value.
  124437. */
  124438. private _modifierHeightOffset;
  124439. /**
  124440. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124441. * allow modification of the rotationOffset value.
  124442. */
  124443. private _modifierRotationOffset;
  124444. /**
  124445. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124446. * allow modification of the radius value.
  124447. */
  124448. private _modifierRadius;
  124449. }
  124450. }
  124451. declare module BABYLON {
  124452. interface FreeCameraInputsManager {
  124453. /**
  124454. * @hidden
  124455. */
  124456. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  124457. /**
  124458. * Add orientation input support to the input manager.
  124459. * @returns the current input manager
  124460. */
  124461. addDeviceOrientation(): FreeCameraInputsManager;
  124462. }
  124463. /**
  124464. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  124465. * Screen rotation is taken into account.
  124466. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124467. */
  124468. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  124469. private _camera;
  124470. private _screenOrientationAngle;
  124471. private _constantTranform;
  124472. private _screenQuaternion;
  124473. private _alpha;
  124474. private _beta;
  124475. private _gamma;
  124476. /**
  124477. * Can be used to detect if a device orientation sensor is available on a device
  124478. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  124479. * @returns a promise that will resolve on orientation change
  124480. */
  124481. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  124482. /**
  124483. * @hidden
  124484. */
  124485. _onDeviceOrientationChangedObservable: Observable<void>;
  124486. /**
  124487. * Instantiates a new input
  124488. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124489. */
  124490. constructor();
  124491. /**
  124492. * Define the camera controlled by the input.
  124493. */
  124494. get camera(): FreeCamera;
  124495. set camera(camera: FreeCamera);
  124496. /**
  124497. * Attach the input controls to a specific dom element to get the input from.
  124498. * @param element Defines the element the controls should be listened from
  124499. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124500. */
  124501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124502. private _orientationChanged;
  124503. private _deviceOrientation;
  124504. /**
  124505. * Detach the current controls from the specified dom element.
  124506. * @param element Defines the element to stop listening the inputs from
  124507. */
  124508. detachControl(element: Nullable<HTMLElement>): void;
  124509. /**
  124510. * Update the current camera state depending on the inputs that have been used this frame.
  124511. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124512. */
  124513. checkInputs(): void;
  124514. /**
  124515. * Gets the class name of the current intput.
  124516. * @returns the class name
  124517. */
  124518. getClassName(): string;
  124519. /**
  124520. * Get the friendly name associated with the input class.
  124521. * @returns the input friendly name
  124522. */
  124523. getSimpleName(): string;
  124524. }
  124525. }
  124526. declare module BABYLON {
  124527. /**
  124528. * Manage the gamepad inputs to control a free camera.
  124529. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124530. */
  124531. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  124532. /**
  124533. * Define the camera the input is attached to.
  124534. */
  124535. camera: FreeCamera;
  124536. /**
  124537. * Define the Gamepad controlling the input
  124538. */
  124539. gamepad: Nullable<Gamepad>;
  124540. /**
  124541. * Defines the gamepad rotation sensiblity.
  124542. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124543. */
  124544. gamepadAngularSensibility: number;
  124545. /**
  124546. * Defines the gamepad move sensiblity.
  124547. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124548. */
  124549. gamepadMoveSensibility: number;
  124550. private _yAxisScale;
  124551. /**
  124552. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124553. */
  124554. get invertYAxis(): boolean;
  124555. set invertYAxis(value: boolean);
  124556. private _onGamepadConnectedObserver;
  124557. private _onGamepadDisconnectedObserver;
  124558. private _cameraTransform;
  124559. private _deltaTransform;
  124560. private _vector3;
  124561. private _vector2;
  124562. /**
  124563. * Attach the input controls to a specific dom element to get the input from.
  124564. * @param element Defines the element the controls should be listened from
  124565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124566. */
  124567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124568. /**
  124569. * Detach the current controls from the specified dom element.
  124570. * @param element Defines the element to stop listening the inputs from
  124571. */
  124572. detachControl(element: Nullable<HTMLElement>): void;
  124573. /**
  124574. * Update the current camera state depending on the inputs that have been used this frame.
  124575. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124576. */
  124577. checkInputs(): void;
  124578. /**
  124579. * Gets the class name of the current intput.
  124580. * @returns the class name
  124581. */
  124582. getClassName(): string;
  124583. /**
  124584. * Get the friendly name associated with the input class.
  124585. * @returns the input friendly name
  124586. */
  124587. getSimpleName(): string;
  124588. }
  124589. }
  124590. declare module BABYLON {
  124591. /**
  124592. * Defines the potential axis of a Joystick
  124593. */
  124594. export enum JoystickAxis {
  124595. /** X axis */
  124596. X = 0,
  124597. /** Y axis */
  124598. Y = 1,
  124599. /** Z axis */
  124600. Z = 2
  124601. }
  124602. /**
  124603. * Represents the different customization options available
  124604. * for VirtualJoystick
  124605. */
  124606. interface VirtualJoystickCustomizations {
  124607. /**
  124608. * Size of the joystick's puck
  124609. */
  124610. puckSize: number;
  124611. /**
  124612. * Size of the joystick's container
  124613. */
  124614. containerSize: number;
  124615. /**
  124616. * Color of the joystick && puck
  124617. */
  124618. color: string;
  124619. /**
  124620. * Image URL for the joystick's puck
  124621. */
  124622. puckImage?: string;
  124623. /**
  124624. * Image URL for the joystick's container
  124625. */
  124626. containerImage?: string;
  124627. /**
  124628. * Defines the unmoving position of the joystick container
  124629. */
  124630. position?: {
  124631. x: number;
  124632. y: number;
  124633. };
  124634. /**
  124635. * Defines whether or not the joystick container is always visible
  124636. */
  124637. alwaysVisible: boolean;
  124638. /**
  124639. * Defines whether or not to limit the movement of the puck to the joystick's container
  124640. */
  124641. limitToContainer: boolean;
  124642. }
  124643. /**
  124644. * Class used to define virtual joystick (used in touch mode)
  124645. */
  124646. export class VirtualJoystick {
  124647. /**
  124648. * Gets or sets a boolean indicating that left and right values must be inverted
  124649. */
  124650. reverseLeftRight: boolean;
  124651. /**
  124652. * Gets or sets a boolean indicating that up and down values must be inverted
  124653. */
  124654. reverseUpDown: boolean;
  124655. /**
  124656. * Gets the offset value for the position (ie. the change of the position value)
  124657. */
  124658. deltaPosition: Vector3;
  124659. /**
  124660. * Gets a boolean indicating if the virtual joystick was pressed
  124661. */
  124662. pressed: boolean;
  124663. /**
  124664. * Canvas the virtual joystick will render onto, default z-index of this is 5
  124665. */
  124666. static Canvas: Nullable<HTMLCanvasElement>;
  124667. /**
  124668. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  124669. */
  124670. limitToContainer: boolean;
  124671. private static _globalJoystickIndex;
  124672. private static _alwaysVisibleSticks;
  124673. private static vjCanvasContext;
  124674. private static vjCanvasWidth;
  124675. private static vjCanvasHeight;
  124676. private static halfWidth;
  124677. private static _GetDefaultOptions;
  124678. private _action;
  124679. private _axisTargetedByLeftAndRight;
  124680. private _axisTargetedByUpAndDown;
  124681. private _joystickSensibility;
  124682. private _inversedSensibility;
  124683. private _joystickPointerID;
  124684. private _joystickColor;
  124685. private _joystickPointerPos;
  124686. private _joystickPreviousPointerPos;
  124687. private _joystickPointerStartPos;
  124688. private _deltaJoystickVector;
  124689. private _leftJoystick;
  124690. private _touches;
  124691. private _joystickPosition;
  124692. private _alwaysVisible;
  124693. private _puckImage;
  124694. private _containerImage;
  124695. private _joystickPuckSize;
  124696. private _joystickContainerSize;
  124697. private _clearPuckSize;
  124698. private _clearContainerSize;
  124699. private _clearPuckSizeOffset;
  124700. private _clearContainerSizeOffset;
  124701. private _onPointerDownHandlerRef;
  124702. private _onPointerMoveHandlerRef;
  124703. private _onPointerUpHandlerRef;
  124704. private _onResize;
  124705. /**
  124706. * Creates a new virtual joystick
  124707. * @param leftJoystick defines that the joystick is for left hand (false by default)
  124708. * @param customizations Defines the options we want to customize the VirtualJoystick
  124709. */
  124710. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  124711. /**
  124712. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  124713. * @param newJoystickSensibility defines the new sensibility
  124714. */
  124715. setJoystickSensibility(newJoystickSensibility: number): void;
  124716. private _onPointerDown;
  124717. private _onPointerMove;
  124718. private _onPointerUp;
  124719. /**
  124720. * Change the color of the virtual joystick
  124721. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  124722. */
  124723. setJoystickColor(newColor: string): void;
  124724. /**
  124725. * Size of the joystick's container
  124726. */
  124727. set containerSize(newSize: number);
  124728. get containerSize(): number;
  124729. /**
  124730. * Size of the joystick's puck
  124731. */
  124732. set puckSize(newSize: number);
  124733. get puckSize(): number;
  124734. /**
  124735. * Clears the set position of the joystick
  124736. */
  124737. clearPosition(): void;
  124738. /**
  124739. * Defines whether or not the joystick container is always visible
  124740. */
  124741. set alwaysVisible(value: boolean);
  124742. get alwaysVisible(): boolean;
  124743. /**
  124744. * Sets the constant position of the Joystick container
  124745. * @param x X axis coordinate
  124746. * @param y Y axis coordinate
  124747. */
  124748. setPosition(x: number, y: number): void;
  124749. /**
  124750. * Defines a callback to call when the joystick is touched
  124751. * @param action defines the callback
  124752. */
  124753. setActionOnTouch(action: () => any): void;
  124754. /**
  124755. * Defines which axis you'd like to control for left & right
  124756. * @param axis defines the axis to use
  124757. */
  124758. setAxisForLeftRight(axis: JoystickAxis): void;
  124759. /**
  124760. * Defines which axis you'd like to control for up & down
  124761. * @param axis defines the axis to use
  124762. */
  124763. setAxisForUpDown(axis: JoystickAxis): void;
  124764. /**
  124765. * Clears the canvas from the previous puck / container draw
  124766. */
  124767. private _clearPreviousDraw;
  124768. /**
  124769. * Loads `urlPath` to be used for the container's image
  124770. * @param urlPath defines the urlPath of an image to use
  124771. */
  124772. setContainerImage(urlPath: string): void;
  124773. /**
  124774. * Loads `urlPath` to be used for the puck's image
  124775. * @param urlPath defines the urlPath of an image to use
  124776. */
  124777. setPuckImage(urlPath: string): void;
  124778. /**
  124779. * Draws the Virtual Joystick's container
  124780. */
  124781. private _drawContainer;
  124782. /**
  124783. * Draws the Virtual Joystick's puck
  124784. */
  124785. private _drawPuck;
  124786. private _drawVirtualJoystick;
  124787. /**
  124788. * Release internal HTML canvas
  124789. */
  124790. releaseCanvas(): void;
  124791. }
  124792. }
  124793. declare module BABYLON {
  124794. interface FreeCameraInputsManager {
  124795. /**
  124796. * Add virtual joystick input support to the input manager.
  124797. * @returns the current input manager
  124798. */
  124799. addVirtualJoystick(): FreeCameraInputsManager;
  124800. }
  124801. /**
  124802. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  124803. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124804. */
  124805. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  124806. /**
  124807. * Defines the camera the input is attached to.
  124808. */
  124809. camera: FreeCamera;
  124810. private _leftjoystick;
  124811. private _rightjoystick;
  124812. /**
  124813. * Gets the left stick of the virtual joystick.
  124814. * @returns The virtual Joystick
  124815. */
  124816. getLeftJoystick(): VirtualJoystick;
  124817. /**
  124818. * Gets the right stick of the virtual joystick.
  124819. * @returns The virtual Joystick
  124820. */
  124821. getRightJoystick(): VirtualJoystick;
  124822. /**
  124823. * Update the current camera state depending on the inputs that have been used this frame.
  124824. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124825. */
  124826. checkInputs(): void;
  124827. /**
  124828. * Attach the input controls to a specific dom element to get the input from.
  124829. * @param element Defines the element the controls should be listened from
  124830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124831. */
  124832. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124833. /**
  124834. * Detach the current controls from the specified dom element.
  124835. * @param element Defines the element to stop listening the inputs from
  124836. */
  124837. detachControl(element: Nullable<HTMLElement>): void;
  124838. /**
  124839. * Gets the class name of the current intput.
  124840. * @returns the class name
  124841. */
  124842. getClassName(): string;
  124843. /**
  124844. * Get the friendly name associated with the input class.
  124845. * @returns the input friendly name
  124846. */
  124847. getSimpleName(): string;
  124848. }
  124849. }
  124850. declare module BABYLON {
  124851. /**
  124852. * This represents a FPS type of camera controlled by touch.
  124853. * This is like a universal camera minus the Gamepad controls.
  124854. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124855. */
  124856. export class TouchCamera extends FreeCamera {
  124857. /**
  124858. * Defines the touch sensibility for rotation.
  124859. * The higher the faster.
  124860. */
  124861. get touchAngularSensibility(): number;
  124862. set touchAngularSensibility(value: number);
  124863. /**
  124864. * Defines the touch sensibility for move.
  124865. * The higher the faster.
  124866. */
  124867. get touchMoveSensibility(): number;
  124868. set touchMoveSensibility(value: number);
  124869. /**
  124870. * Instantiates a new touch camera.
  124871. * This represents a FPS type of camera controlled by touch.
  124872. * This is like a universal camera minus the Gamepad controls.
  124873. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124874. * @param name Define the name of the camera in the scene
  124875. * @param position Define the start position of the camera in the scene
  124876. * @param scene Define the scene the camera belongs to
  124877. */
  124878. constructor(name: string, position: Vector3, scene: Scene);
  124879. /**
  124880. * Gets the current object class name.
  124881. * @return the class name
  124882. */
  124883. getClassName(): string;
  124884. /** @hidden */
  124885. _setupInputs(): void;
  124886. }
  124887. }
  124888. declare module BABYLON {
  124889. /**
  124890. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  124891. * being tilted forward or back and left or right.
  124892. */
  124893. export class DeviceOrientationCamera extends FreeCamera {
  124894. private _initialQuaternion;
  124895. private _quaternionCache;
  124896. private _tmpDragQuaternion;
  124897. private _disablePointerInputWhenUsingDeviceOrientation;
  124898. /**
  124899. * Creates a new device orientation camera
  124900. * @param name The name of the camera
  124901. * @param position The start position camera
  124902. * @param scene The scene the camera belongs to
  124903. */
  124904. constructor(name: string, position: Vector3, scene: Scene);
  124905. /**
  124906. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  124907. */
  124908. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  124909. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  124910. private _dragFactor;
  124911. /**
  124912. * Enabled turning on the y axis when the orientation sensor is active
  124913. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  124914. */
  124915. enableHorizontalDragging(dragFactor?: number): void;
  124916. /**
  124917. * Gets the current instance class name ("DeviceOrientationCamera").
  124918. * This helps avoiding instanceof at run time.
  124919. * @returns the class name
  124920. */
  124921. getClassName(): string;
  124922. /**
  124923. * @hidden
  124924. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  124925. */
  124926. _checkInputs(): void;
  124927. /**
  124928. * Reset the camera to its default orientation on the specified axis only.
  124929. * @param axis The axis to reset
  124930. */
  124931. resetToCurrentRotation(axis?: Axis): void;
  124932. }
  124933. }
  124934. declare module BABYLON {
  124935. /**
  124936. * Defines supported buttons for XBox360 compatible gamepads
  124937. */
  124938. export enum Xbox360Button {
  124939. /** A */
  124940. A = 0,
  124941. /** B */
  124942. B = 1,
  124943. /** X */
  124944. X = 2,
  124945. /** Y */
  124946. Y = 3,
  124947. /** Left button */
  124948. LB = 4,
  124949. /** Right button */
  124950. RB = 5,
  124951. /** Back */
  124952. Back = 8,
  124953. /** Start */
  124954. Start = 9,
  124955. /** Left stick */
  124956. LeftStick = 10,
  124957. /** Right stick */
  124958. RightStick = 11
  124959. }
  124960. /** Defines values for XBox360 DPad */
  124961. export enum Xbox360Dpad {
  124962. /** Up */
  124963. Up = 12,
  124964. /** Down */
  124965. Down = 13,
  124966. /** Left */
  124967. Left = 14,
  124968. /** Right */
  124969. Right = 15
  124970. }
  124971. /**
  124972. * Defines a XBox360 gamepad
  124973. */
  124974. export class Xbox360Pad extends Gamepad {
  124975. private _leftTrigger;
  124976. private _rightTrigger;
  124977. private _onlefttriggerchanged;
  124978. private _onrighttriggerchanged;
  124979. private _onbuttondown;
  124980. private _onbuttonup;
  124981. private _ondpaddown;
  124982. private _ondpadup;
  124983. /** Observable raised when a button is pressed */
  124984. onButtonDownObservable: Observable<Xbox360Button>;
  124985. /** Observable raised when a button is released */
  124986. onButtonUpObservable: Observable<Xbox360Button>;
  124987. /** Observable raised when a pad is pressed */
  124988. onPadDownObservable: Observable<Xbox360Dpad>;
  124989. /** Observable raised when a pad is released */
  124990. onPadUpObservable: Observable<Xbox360Dpad>;
  124991. private _buttonA;
  124992. private _buttonB;
  124993. private _buttonX;
  124994. private _buttonY;
  124995. private _buttonBack;
  124996. private _buttonStart;
  124997. private _buttonLB;
  124998. private _buttonRB;
  124999. private _buttonLeftStick;
  125000. private _buttonRightStick;
  125001. private _dPadUp;
  125002. private _dPadDown;
  125003. private _dPadLeft;
  125004. private _dPadRight;
  125005. private _isXboxOnePad;
  125006. /**
  125007. * Creates a new XBox360 gamepad object
  125008. * @param id defines the id of this gamepad
  125009. * @param index defines its index
  125010. * @param gamepad defines the internal HTML gamepad object
  125011. * @param xboxOne defines if it is a XBox One gamepad
  125012. */
  125013. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  125014. /**
  125015. * Defines the callback to call when left trigger is pressed
  125016. * @param callback defines the callback to use
  125017. */
  125018. onlefttriggerchanged(callback: (value: number) => void): void;
  125019. /**
  125020. * Defines the callback to call when right trigger is pressed
  125021. * @param callback defines the callback to use
  125022. */
  125023. onrighttriggerchanged(callback: (value: number) => void): void;
  125024. /**
  125025. * Gets the left trigger value
  125026. */
  125027. get leftTrigger(): number;
  125028. /**
  125029. * Sets the left trigger value
  125030. */
  125031. set leftTrigger(newValue: number);
  125032. /**
  125033. * Gets the right trigger value
  125034. */
  125035. get rightTrigger(): number;
  125036. /**
  125037. * Sets the right trigger value
  125038. */
  125039. set rightTrigger(newValue: number);
  125040. /**
  125041. * Defines the callback to call when a button is pressed
  125042. * @param callback defines the callback to use
  125043. */
  125044. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  125045. /**
  125046. * Defines the callback to call when a button is released
  125047. * @param callback defines the callback to use
  125048. */
  125049. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  125050. /**
  125051. * Defines the callback to call when a pad is pressed
  125052. * @param callback defines the callback to use
  125053. */
  125054. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  125055. /**
  125056. * Defines the callback to call when a pad is released
  125057. * @param callback defines the callback to use
  125058. */
  125059. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  125060. private _setButtonValue;
  125061. private _setDPadValue;
  125062. /**
  125063. * Gets the value of the `A` button
  125064. */
  125065. get buttonA(): number;
  125066. /**
  125067. * Sets the value of the `A` button
  125068. */
  125069. set buttonA(value: number);
  125070. /**
  125071. * Gets the value of the `B` button
  125072. */
  125073. get buttonB(): number;
  125074. /**
  125075. * Sets the value of the `B` button
  125076. */
  125077. set buttonB(value: number);
  125078. /**
  125079. * Gets the value of the `X` button
  125080. */
  125081. get buttonX(): number;
  125082. /**
  125083. * Sets the value of the `X` button
  125084. */
  125085. set buttonX(value: number);
  125086. /**
  125087. * Gets the value of the `Y` button
  125088. */
  125089. get buttonY(): number;
  125090. /**
  125091. * Sets the value of the `Y` button
  125092. */
  125093. set buttonY(value: number);
  125094. /**
  125095. * Gets the value of the `Start` button
  125096. */
  125097. get buttonStart(): number;
  125098. /**
  125099. * Sets the value of the `Start` button
  125100. */
  125101. set buttonStart(value: number);
  125102. /**
  125103. * Gets the value of the `Back` button
  125104. */
  125105. get buttonBack(): number;
  125106. /**
  125107. * Sets the value of the `Back` button
  125108. */
  125109. set buttonBack(value: number);
  125110. /**
  125111. * Gets the value of the `Left` button
  125112. */
  125113. get buttonLB(): number;
  125114. /**
  125115. * Sets the value of the `Left` button
  125116. */
  125117. set buttonLB(value: number);
  125118. /**
  125119. * Gets the value of the `Right` button
  125120. */
  125121. get buttonRB(): number;
  125122. /**
  125123. * Sets the value of the `Right` button
  125124. */
  125125. set buttonRB(value: number);
  125126. /**
  125127. * Gets the value of the Left joystick
  125128. */
  125129. get buttonLeftStick(): number;
  125130. /**
  125131. * Sets the value of the Left joystick
  125132. */
  125133. set buttonLeftStick(value: number);
  125134. /**
  125135. * Gets the value of the Right joystick
  125136. */
  125137. get buttonRightStick(): number;
  125138. /**
  125139. * Sets the value of the Right joystick
  125140. */
  125141. set buttonRightStick(value: number);
  125142. /**
  125143. * Gets the value of D-pad up
  125144. */
  125145. get dPadUp(): number;
  125146. /**
  125147. * Sets the value of D-pad up
  125148. */
  125149. set dPadUp(value: number);
  125150. /**
  125151. * Gets the value of D-pad down
  125152. */
  125153. get dPadDown(): number;
  125154. /**
  125155. * Sets the value of D-pad down
  125156. */
  125157. set dPadDown(value: number);
  125158. /**
  125159. * Gets the value of D-pad left
  125160. */
  125161. get dPadLeft(): number;
  125162. /**
  125163. * Sets the value of D-pad left
  125164. */
  125165. set dPadLeft(value: number);
  125166. /**
  125167. * Gets the value of D-pad right
  125168. */
  125169. get dPadRight(): number;
  125170. /**
  125171. * Sets the value of D-pad right
  125172. */
  125173. set dPadRight(value: number);
  125174. /**
  125175. * Force the gamepad to synchronize with device values
  125176. */
  125177. update(): void;
  125178. /**
  125179. * Disposes the gamepad
  125180. */
  125181. dispose(): void;
  125182. }
  125183. }
  125184. declare module BABYLON {
  125185. /**
  125186. * Defines supported buttons for DualShock compatible gamepads
  125187. */
  125188. export enum DualShockButton {
  125189. /** Cross */
  125190. Cross = 0,
  125191. /** Circle */
  125192. Circle = 1,
  125193. /** Square */
  125194. Square = 2,
  125195. /** Triangle */
  125196. Triangle = 3,
  125197. /** L1 */
  125198. L1 = 4,
  125199. /** R1 */
  125200. R1 = 5,
  125201. /** Share */
  125202. Share = 8,
  125203. /** Options */
  125204. Options = 9,
  125205. /** Left stick */
  125206. LeftStick = 10,
  125207. /** Right stick */
  125208. RightStick = 11
  125209. }
  125210. /** Defines values for DualShock DPad */
  125211. export enum DualShockDpad {
  125212. /** Up */
  125213. Up = 12,
  125214. /** Down */
  125215. Down = 13,
  125216. /** Left */
  125217. Left = 14,
  125218. /** Right */
  125219. Right = 15
  125220. }
  125221. /**
  125222. * Defines a DualShock gamepad
  125223. */
  125224. export class DualShockPad extends Gamepad {
  125225. private _leftTrigger;
  125226. private _rightTrigger;
  125227. private _onlefttriggerchanged;
  125228. private _onrighttriggerchanged;
  125229. private _onbuttondown;
  125230. private _onbuttonup;
  125231. private _ondpaddown;
  125232. private _ondpadup;
  125233. /** Observable raised when a button is pressed */
  125234. onButtonDownObservable: Observable<DualShockButton>;
  125235. /** Observable raised when a button is released */
  125236. onButtonUpObservable: Observable<DualShockButton>;
  125237. /** Observable raised when a pad is pressed */
  125238. onPadDownObservable: Observable<DualShockDpad>;
  125239. /** Observable raised when a pad is released */
  125240. onPadUpObservable: Observable<DualShockDpad>;
  125241. private _buttonCross;
  125242. private _buttonCircle;
  125243. private _buttonSquare;
  125244. private _buttonTriangle;
  125245. private _buttonShare;
  125246. private _buttonOptions;
  125247. private _buttonL1;
  125248. private _buttonR1;
  125249. private _buttonLeftStick;
  125250. private _buttonRightStick;
  125251. private _dPadUp;
  125252. private _dPadDown;
  125253. private _dPadLeft;
  125254. private _dPadRight;
  125255. /**
  125256. * Creates a new DualShock gamepad object
  125257. * @param id defines the id of this gamepad
  125258. * @param index defines its index
  125259. * @param gamepad defines the internal HTML gamepad object
  125260. */
  125261. constructor(id: string, index: number, gamepad: any);
  125262. /**
  125263. * Defines the callback to call when left trigger is pressed
  125264. * @param callback defines the callback to use
  125265. */
  125266. onlefttriggerchanged(callback: (value: number) => void): void;
  125267. /**
  125268. * Defines the callback to call when right trigger is pressed
  125269. * @param callback defines the callback to use
  125270. */
  125271. onrighttriggerchanged(callback: (value: number) => void): void;
  125272. /**
  125273. * Gets the left trigger value
  125274. */
  125275. get leftTrigger(): number;
  125276. /**
  125277. * Sets the left trigger value
  125278. */
  125279. set leftTrigger(newValue: number);
  125280. /**
  125281. * Gets the right trigger value
  125282. */
  125283. get rightTrigger(): number;
  125284. /**
  125285. * Sets the right trigger value
  125286. */
  125287. set rightTrigger(newValue: number);
  125288. /**
  125289. * Defines the callback to call when a button is pressed
  125290. * @param callback defines the callback to use
  125291. */
  125292. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  125293. /**
  125294. * Defines the callback to call when a button is released
  125295. * @param callback defines the callback to use
  125296. */
  125297. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  125298. /**
  125299. * Defines the callback to call when a pad is pressed
  125300. * @param callback defines the callback to use
  125301. */
  125302. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  125303. /**
  125304. * Defines the callback to call when a pad is released
  125305. * @param callback defines the callback to use
  125306. */
  125307. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  125308. private _setButtonValue;
  125309. private _setDPadValue;
  125310. /**
  125311. * Gets the value of the `Cross` button
  125312. */
  125313. get buttonCross(): number;
  125314. /**
  125315. * Sets the value of the `Cross` button
  125316. */
  125317. set buttonCross(value: number);
  125318. /**
  125319. * Gets the value of the `Circle` button
  125320. */
  125321. get buttonCircle(): number;
  125322. /**
  125323. * Sets the value of the `Circle` button
  125324. */
  125325. set buttonCircle(value: number);
  125326. /**
  125327. * Gets the value of the `Square` button
  125328. */
  125329. get buttonSquare(): number;
  125330. /**
  125331. * Sets the value of the `Square` button
  125332. */
  125333. set buttonSquare(value: number);
  125334. /**
  125335. * Gets the value of the `Triangle` button
  125336. */
  125337. get buttonTriangle(): number;
  125338. /**
  125339. * Sets the value of the `Triangle` button
  125340. */
  125341. set buttonTriangle(value: number);
  125342. /**
  125343. * Gets the value of the `Options` button
  125344. */
  125345. get buttonOptions(): number;
  125346. /**
  125347. * Sets the value of the `Options` button
  125348. */
  125349. set buttonOptions(value: number);
  125350. /**
  125351. * Gets the value of the `Share` button
  125352. */
  125353. get buttonShare(): number;
  125354. /**
  125355. * Sets the value of the `Share` button
  125356. */
  125357. set buttonShare(value: number);
  125358. /**
  125359. * Gets the value of the `L1` button
  125360. */
  125361. get buttonL1(): number;
  125362. /**
  125363. * Sets the value of the `L1` button
  125364. */
  125365. set buttonL1(value: number);
  125366. /**
  125367. * Gets the value of the `R1` button
  125368. */
  125369. get buttonR1(): number;
  125370. /**
  125371. * Sets the value of the `R1` button
  125372. */
  125373. set buttonR1(value: number);
  125374. /**
  125375. * Gets the value of the Left joystick
  125376. */
  125377. get buttonLeftStick(): number;
  125378. /**
  125379. * Sets the value of the Left joystick
  125380. */
  125381. set buttonLeftStick(value: number);
  125382. /**
  125383. * Gets the value of the Right joystick
  125384. */
  125385. get buttonRightStick(): number;
  125386. /**
  125387. * Sets the value of the Right joystick
  125388. */
  125389. set buttonRightStick(value: number);
  125390. /**
  125391. * Gets the value of D-pad up
  125392. */
  125393. get dPadUp(): number;
  125394. /**
  125395. * Sets the value of D-pad up
  125396. */
  125397. set dPadUp(value: number);
  125398. /**
  125399. * Gets the value of D-pad down
  125400. */
  125401. get dPadDown(): number;
  125402. /**
  125403. * Sets the value of D-pad down
  125404. */
  125405. set dPadDown(value: number);
  125406. /**
  125407. * Gets the value of D-pad left
  125408. */
  125409. get dPadLeft(): number;
  125410. /**
  125411. * Sets the value of D-pad left
  125412. */
  125413. set dPadLeft(value: number);
  125414. /**
  125415. * Gets the value of D-pad right
  125416. */
  125417. get dPadRight(): number;
  125418. /**
  125419. * Sets the value of D-pad right
  125420. */
  125421. set dPadRight(value: number);
  125422. /**
  125423. * Force the gamepad to synchronize with device values
  125424. */
  125425. update(): void;
  125426. /**
  125427. * Disposes the gamepad
  125428. */
  125429. dispose(): void;
  125430. }
  125431. }
  125432. declare module BABYLON {
  125433. /**
  125434. * Manager for handling gamepads
  125435. */
  125436. export class GamepadManager {
  125437. private _scene?;
  125438. private _babylonGamepads;
  125439. private _oneGamepadConnected;
  125440. /** @hidden */
  125441. _isMonitoring: boolean;
  125442. private _gamepadEventSupported;
  125443. private _gamepadSupport?;
  125444. /**
  125445. * observable to be triggered when the gamepad controller has been connected
  125446. */
  125447. onGamepadConnectedObservable: Observable<Gamepad>;
  125448. /**
  125449. * observable to be triggered when the gamepad controller has been disconnected
  125450. */
  125451. onGamepadDisconnectedObservable: Observable<Gamepad>;
  125452. private _onGamepadConnectedEvent;
  125453. private _onGamepadDisconnectedEvent;
  125454. /**
  125455. * Initializes the gamepad manager
  125456. * @param _scene BabylonJS scene
  125457. */
  125458. constructor(_scene?: Scene | undefined);
  125459. /**
  125460. * The gamepads in the game pad manager
  125461. */
  125462. get gamepads(): Gamepad[];
  125463. /**
  125464. * Get the gamepad controllers based on type
  125465. * @param type The type of gamepad controller
  125466. * @returns Nullable gamepad
  125467. */
  125468. getGamepadByType(type?: number): Nullable<Gamepad>;
  125469. /**
  125470. * Disposes the gamepad manager
  125471. */
  125472. dispose(): void;
  125473. private _addNewGamepad;
  125474. private _startMonitoringGamepads;
  125475. private _stopMonitoringGamepads;
  125476. /** @hidden */
  125477. _checkGamepadsStatus(): void;
  125478. private _updateGamepadObjects;
  125479. }
  125480. }
  125481. declare module BABYLON {
  125482. interface Scene {
  125483. /** @hidden */
  125484. _gamepadManager: Nullable<GamepadManager>;
  125485. /**
  125486. * Gets the gamepad manager associated with the scene
  125487. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  125488. */
  125489. gamepadManager: GamepadManager;
  125490. }
  125491. /**
  125492. * Interface representing a free camera inputs manager
  125493. */
  125494. interface FreeCameraInputsManager {
  125495. /**
  125496. * Adds gamepad input support to the FreeCameraInputsManager.
  125497. * @returns the FreeCameraInputsManager
  125498. */
  125499. addGamepad(): FreeCameraInputsManager;
  125500. }
  125501. /**
  125502. * Interface representing an arc rotate camera inputs manager
  125503. */
  125504. interface ArcRotateCameraInputsManager {
  125505. /**
  125506. * Adds gamepad input support to the ArcRotateCamera InputManager.
  125507. * @returns the camera inputs manager
  125508. */
  125509. addGamepad(): ArcRotateCameraInputsManager;
  125510. }
  125511. /**
  125512. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  125513. */
  125514. export class GamepadSystemSceneComponent implements ISceneComponent {
  125515. /**
  125516. * The component name helpfull to identify the component in the list of scene components.
  125517. */
  125518. readonly name: string;
  125519. /**
  125520. * The scene the component belongs to.
  125521. */
  125522. scene: Scene;
  125523. /**
  125524. * Creates a new instance of the component for the given scene
  125525. * @param scene Defines the scene to register the component in
  125526. */
  125527. constructor(scene: Scene);
  125528. /**
  125529. * Registers the component in a given scene
  125530. */
  125531. register(): void;
  125532. /**
  125533. * Rebuilds the elements related to this component in case of
  125534. * context lost for instance.
  125535. */
  125536. rebuild(): void;
  125537. /**
  125538. * Disposes the component and the associated ressources
  125539. */
  125540. dispose(): void;
  125541. private _beforeCameraUpdate;
  125542. }
  125543. }
  125544. declare module BABYLON {
  125545. /**
  125546. * 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,
  125547. * which still works and will still be found in many Playgrounds.
  125548. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125549. */
  125550. export class UniversalCamera extends TouchCamera {
  125551. /**
  125552. * Defines the gamepad rotation sensiblity.
  125553. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125554. */
  125555. get gamepadAngularSensibility(): number;
  125556. set gamepadAngularSensibility(value: number);
  125557. /**
  125558. * Defines the gamepad move sensiblity.
  125559. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125560. */
  125561. get gamepadMoveSensibility(): number;
  125562. set gamepadMoveSensibility(value: number);
  125563. /**
  125564. * 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,
  125565. * which still works and will still be found in many Playgrounds.
  125566. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125567. * @param name Define the name of the camera in the scene
  125568. * @param position Define the start position of the camera in the scene
  125569. * @param scene Define the scene the camera belongs to
  125570. */
  125571. constructor(name: string, position: Vector3, scene: Scene);
  125572. /**
  125573. * Gets the current object class name.
  125574. * @return the class name
  125575. */
  125576. getClassName(): string;
  125577. }
  125578. }
  125579. declare module BABYLON {
  125580. /**
  125581. * This represents a FPS type of camera. This is only here for back compat purpose.
  125582. * Please use the UniversalCamera instead as both are identical.
  125583. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125584. */
  125585. export class GamepadCamera extends UniversalCamera {
  125586. /**
  125587. * Instantiates a new Gamepad Camera
  125588. * This represents a FPS type of camera. This is only here for back compat purpose.
  125589. * Please use the UniversalCamera instead as both are identical.
  125590. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125591. * @param name Define the name of the camera in the scene
  125592. * @param position Define the start position of the camera in the scene
  125593. * @param scene Define the scene the camera belongs to
  125594. */
  125595. constructor(name: string, position: Vector3, scene: Scene);
  125596. /**
  125597. * Gets the current object class name.
  125598. * @return the class name
  125599. */
  125600. getClassName(): string;
  125601. }
  125602. }
  125603. declare module BABYLON {
  125604. /** @hidden */
  125605. export var passPixelShader: {
  125606. name: string;
  125607. shader: string;
  125608. };
  125609. }
  125610. declare module BABYLON {
  125611. /** @hidden */
  125612. export var passCubePixelShader: {
  125613. name: string;
  125614. shader: string;
  125615. };
  125616. }
  125617. declare module BABYLON {
  125618. /**
  125619. * PassPostProcess which produces an output the same as it's input
  125620. */
  125621. export class PassPostProcess extends PostProcess {
  125622. /**
  125623. * Gets a string identifying the name of the class
  125624. * @returns "PassPostProcess" string
  125625. */
  125626. getClassName(): string;
  125627. /**
  125628. * Creates the PassPostProcess
  125629. * @param name The name of the effect.
  125630. * @param options The required width/height ratio to downsize to before computing the render pass.
  125631. * @param camera The camera to apply the render pass to.
  125632. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125633. * @param engine The engine which the post process will be applied. (default: current engine)
  125634. * @param reusable If the post process can be reused on the same frame. (default: false)
  125635. * @param textureType The type of texture to be used when performing the post processing.
  125636. * @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)
  125637. */
  125638. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125639. /** @hidden */
  125640. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  125641. }
  125642. /**
  125643. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  125644. */
  125645. export class PassCubePostProcess extends PostProcess {
  125646. private _face;
  125647. /**
  125648. * Gets or sets the cube face to display.
  125649. * * 0 is +X
  125650. * * 1 is -X
  125651. * * 2 is +Y
  125652. * * 3 is -Y
  125653. * * 4 is +Z
  125654. * * 5 is -Z
  125655. */
  125656. get face(): number;
  125657. set face(value: number);
  125658. /**
  125659. * Gets a string identifying the name of the class
  125660. * @returns "PassCubePostProcess" string
  125661. */
  125662. getClassName(): string;
  125663. /**
  125664. * Creates the PassCubePostProcess
  125665. * @param name The name of the effect.
  125666. * @param options The required width/height ratio to downsize to before computing the render pass.
  125667. * @param camera The camera to apply the render pass to.
  125668. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125669. * @param engine The engine which the post process will be applied. (default: current engine)
  125670. * @param reusable If the post process can be reused on the same frame. (default: false)
  125671. * @param textureType The type of texture to be used when performing the post processing.
  125672. * @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)
  125673. */
  125674. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125675. /** @hidden */
  125676. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  125677. }
  125678. }
  125679. declare module BABYLON {
  125680. /** @hidden */
  125681. export var anaglyphPixelShader: {
  125682. name: string;
  125683. shader: string;
  125684. };
  125685. }
  125686. declare module BABYLON {
  125687. /**
  125688. * Postprocess used to generate anaglyphic rendering
  125689. */
  125690. export class AnaglyphPostProcess extends PostProcess {
  125691. private _passedProcess;
  125692. /**
  125693. * Gets a string identifying the name of the class
  125694. * @returns "AnaglyphPostProcess" string
  125695. */
  125696. getClassName(): string;
  125697. /**
  125698. * Creates a new AnaglyphPostProcess
  125699. * @param name defines postprocess name
  125700. * @param options defines creation options or target ratio scale
  125701. * @param rigCameras defines cameras using this postprocess
  125702. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  125703. * @param engine defines hosting engine
  125704. * @param reusable defines if the postprocess will be reused multiple times per frame
  125705. */
  125706. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  125707. }
  125708. }
  125709. declare module BABYLON {
  125710. /**
  125711. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  125712. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125713. */
  125714. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  125715. /**
  125716. * Creates a new AnaglyphArcRotateCamera
  125717. * @param name defines camera name
  125718. * @param alpha defines alpha angle (in radians)
  125719. * @param beta defines beta angle (in radians)
  125720. * @param radius defines radius
  125721. * @param target defines camera target
  125722. * @param interaxialDistance defines distance between each color axis
  125723. * @param scene defines the hosting scene
  125724. */
  125725. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  125726. /**
  125727. * Gets camera class name
  125728. * @returns AnaglyphArcRotateCamera
  125729. */
  125730. getClassName(): string;
  125731. }
  125732. }
  125733. declare module BABYLON {
  125734. /**
  125735. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  125736. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125737. */
  125738. export class AnaglyphFreeCamera extends FreeCamera {
  125739. /**
  125740. * Creates a new AnaglyphFreeCamera
  125741. * @param name defines camera name
  125742. * @param position defines initial position
  125743. * @param interaxialDistance defines distance between each color axis
  125744. * @param scene defines the hosting scene
  125745. */
  125746. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125747. /**
  125748. * Gets camera class name
  125749. * @returns AnaglyphFreeCamera
  125750. */
  125751. getClassName(): string;
  125752. }
  125753. }
  125754. declare module BABYLON {
  125755. /**
  125756. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  125757. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125758. */
  125759. export class AnaglyphGamepadCamera extends GamepadCamera {
  125760. /**
  125761. * Creates a new AnaglyphGamepadCamera
  125762. * @param name defines camera name
  125763. * @param position defines initial position
  125764. * @param interaxialDistance defines distance between each color axis
  125765. * @param scene defines the hosting scene
  125766. */
  125767. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125768. /**
  125769. * Gets camera class name
  125770. * @returns AnaglyphGamepadCamera
  125771. */
  125772. getClassName(): string;
  125773. }
  125774. }
  125775. declare module BABYLON {
  125776. /**
  125777. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  125778. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125779. */
  125780. export class AnaglyphUniversalCamera extends UniversalCamera {
  125781. /**
  125782. * Creates a new AnaglyphUniversalCamera
  125783. * @param name defines camera name
  125784. * @param position defines initial position
  125785. * @param interaxialDistance defines distance between each color axis
  125786. * @param scene defines the hosting scene
  125787. */
  125788. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125789. /**
  125790. * Gets camera class name
  125791. * @returns AnaglyphUniversalCamera
  125792. */
  125793. getClassName(): string;
  125794. }
  125795. }
  125796. declare module BABYLON {
  125797. /**
  125798. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  125799. * @see https://doc.babylonjs.com/features/cameras
  125800. */
  125801. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  125802. /**
  125803. * Creates a new StereoscopicArcRotateCamera
  125804. * @param name defines camera name
  125805. * @param alpha defines alpha angle (in radians)
  125806. * @param beta defines beta angle (in radians)
  125807. * @param radius defines radius
  125808. * @param target defines camera target
  125809. * @param interaxialDistance defines distance between each color axis
  125810. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125811. * @param scene defines the hosting scene
  125812. */
  125813. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125814. /**
  125815. * Gets camera class name
  125816. * @returns StereoscopicArcRotateCamera
  125817. */
  125818. getClassName(): string;
  125819. }
  125820. }
  125821. declare module BABYLON {
  125822. /**
  125823. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  125824. * @see https://doc.babylonjs.com/features/cameras
  125825. */
  125826. export class StereoscopicFreeCamera extends FreeCamera {
  125827. /**
  125828. * Creates a new StereoscopicFreeCamera
  125829. * @param name defines camera name
  125830. * @param position defines initial position
  125831. * @param interaxialDistance defines distance between each color axis
  125832. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125833. * @param scene defines the hosting scene
  125834. */
  125835. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125836. /**
  125837. * Gets camera class name
  125838. * @returns StereoscopicFreeCamera
  125839. */
  125840. getClassName(): string;
  125841. }
  125842. }
  125843. declare module BABYLON {
  125844. /**
  125845. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  125846. * @see https://doc.babylonjs.com/features/cameras
  125847. */
  125848. export class StereoscopicGamepadCamera extends GamepadCamera {
  125849. /**
  125850. * Creates a new StereoscopicGamepadCamera
  125851. * @param name defines camera name
  125852. * @param position defines initial position
  125853. * @param interaxialDistance defines distance between each color axis
  125854. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125855. * @param scene defines the hosting scene
  125856. */
  125857. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125858. /**
  125859. * Gets camera class name
  125860. * @returns StereoscopicGamepadCamera
  125861. */
  125862. getClassName(): string;
  125863. }
  125864. }
  125865. declare module BABYLON {
  125866. /**
  125867. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  125868. * @see https://doc.babylonjs.com/features/cameras
  125869. */
  125870. export class StereoscopicUniversalCamera extends UniversalCamera {
  125871. /**
  125872. * Creates a new StereoscopicUniversalCamera
  125873. * @param name defines camera name
  125874. * @param position defines initial position
  125875. * @param interaxialDistance defines distance between each color axis
  125876. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125877. * @param scene defines the hosting scene
  125878. */
  125879. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125880. /**
  125881. * Gets camera class name
  125882. * @returns StereoscopicUniversalCamera
  125883. */
  125884. getClassName(): string;
  125885. }
  125886. }
  125887. declare module BABYLON {
  125888. /**
  125889. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  125890. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  125891. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  125892. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  125893. */
  125894. export class VirtualJoysticksCamera extends FreeCamera {
  125895. /**
  125896. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  125897. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  125898. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  125899. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  125900. * @param name Define the name of the camera in the scene
  125901. * @param position Define the start position of the camera in the scene
  125902. * @param scene Define the scene the camera belongs to
  125903. */
  125904. constructor(name: string, position: Vector3, scene: Scene);
  125905. /**
  125906. * Gets the current object class name.
  125907. * @return the class name
  125908. */
  125909. getClassName(): string;
  125910. }
  125911. }
  125912. declare module BABYLON {
  125913. /**
  125914. * This represents all the required metrics to create a VR camera.
  125915. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  125916. */
  125917. export class VRCameraMetrics {
  125918. /**
  125919. * Define the horizontal resolution off the screen.
  125920. */
  125921. hResolution: number;
  125922. /**
  125923. * Define the vertical resolution off the screen.
  125924. */
  125925. vResolution: number;
  125926. /**
  125927. * Define the horizontal screen size.
  125928. */
  125929. hScreenSize: number;
  125930. /**
  125931. * Define the vertical screen size.
  125932. */
  125933. vScreenSize: number;
  125934. /**
  125935. * Define the vertical screen center position.
  125936. */
  125937. vScreenCenter: number;
  125938. /**
  125939. * Define the distance of the eyes to the screen.
  125940. */
  125941. eyeToScreenDistance: number;
  125942. /**
  125943. * Define the distance between both lenses
  125944. */
  125945. lensSeparationDistance: number;
  125946. /**
  125947. * Define the distance between both viewer's eyes.
  125948. */
  125949. interpupillaryDistance: number;
  125950. /**
  125951. * Define the distortion factor of the VR postprocess.
  125952. * Please, touch with care.
  125953. */
  125954. distortionK: number[];
  125955. /**
  125956. * Define the chromatic aberration correction factors for the VR post process.
  125957. */
  125958. chromaAbCorrection: number[];
  125959. /**
  125960. * Define the scale factor of the post process.
  125961. * The smaller the better but the slower.
  125962. */
  125963. postProcessScaleFactor: number;
  125964. /**
  125965. * Define an offset for the lens center.
  125966. */
  125967. lensCenterOffset: number;
  125968. /**
  125969. * Define if the current vr camera should compensate the distortion of the lense or not.
  125970. */
  125971. compensateDistortion: boolean;
  125972. /**
  125973. * Defines if multiview should be enabled when rendering (Default: false)
  125974. */
  125975. multiviewEnabled: boolean;
  125976. /**
  125977. * Gets the rendering aspect ratio based on the provided resolutions.
  125978. */
  125979. get aspectRatio(): number;
  125980. /**
  125981. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  125982. */
  125983. get aspectRatioFov(): number;
  125984. /**
  125985. * @hidden
  125986. */
  125987. get leftHMatrix(): Matrix;
  125988. /**
  125989. * @hidden
  125990. */
  125991. get rightHMatrix(): Matrix;
  125992. /**
  125993. * @hidden
  125994. */
  125995. get leftPreViewMatrix(): Matrix;
  125996. /**
  125997. * @hidden
  125998. */
  125999. get rightPreViewMatrix(): Matrix;
  126000. /**
  126001. * Get the default VRMetrics based on the most generic setup.
  126002. * @returns the default vr metrics
  126003. */
  126004. static GetDefault(): VRCameraMetrics;
  126005. }
  126006. }
  126007. declare module BABYLON {
  126008. /** @hidden */
  126009. export var vrDistortionCorrectionPixelShader: {
  126010. name: string;
  126011. shader: string;
  126012. };
  126013. }
  126014. declare module BABYLON {
  126015. /**
  126016. * VRDistortionCorrectionPostProcess used for mobile VR
  126017. */
  126018. export class VRDistortionCorrectionPostProcess extends PostProcess {
  126019. private _isRightEye;
  126020. private _distortionFactors;
  126021. private _postProcessScaleFactor;
  126022. private _lensCenterOffset;
  126023. private _scaleIn;
  126024. private _scaleFactor;
  126025. private _lensCenter;
  126026. /**
  126027. * Gets a string identifying the name of the class
  126028. * @returns "VRDistortionCorrectionPostProcess" string
  126029. */
  126030. getClassName(): string;
  126031. /**
  126032. * Initializes the VRDistortionCorrectionPostProcess
  126033. * @param name The name of the effect.
  126034. * @param camera The camera to apply the render pass to.
  126035. * @param isRightEye If this is for the right eye distortion
  126036. * @param vrMetrics All the required metrics for the VR camera
  126037. */
  126038. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  126039. }
  126040. }
  126041. declare module BABYLON {
  126042. /**
  126043. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  126044. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126045. */
  126046. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  126047. /**
  126048. * Creates a new VRDeviceOrientationArcRotateCamera
  126049. * @param name defines camera name
  126050. * @param alpha defines the camera rotation along the logitudinal axis
  126051. * @param beta defines the camera rotation along the latitudinal axis
  126052. * @param radius defines the camera distance from its target
  126053. * @param target defines the camera target
  126054. * @param scene defines the scene the camera belongs to
  126055. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126056. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126057. */
  126058. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126059. /**
  126060. * Gets camera class name
  126061. * @returns VRDeviceOrientationArcRotateCamera
  126062. */
  126063. getClassName(): string;
  126064. }
  126065. }
  126066. declare module BABYLON {
  126067. /**
  126068. * Camera used to simulate VR rendering (based on FreeCamera)
  126069. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126070. */
  126071. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  126072. /**
  126073. * Creates a new VRDeviceOrientationFreeCamera
  126074. * @param name defines camera name
  126075. * @param position defines the start position of the camera
  126076. * @param scene defines the scene the camera belongs to
  126077. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126078. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126079. */
  126080. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126081. /**
  126082. * Gets camera class name
  126083. * @returns VRDeviceOrientationFreeCamera
  126084. */
  126085. getClassName(): string;
  126086. }
  126087. }
  126088. declare module BABYLON {
  126089. /**
  126090. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  126091. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126092. */
  126093. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  126094. /**
  126095. * Creates a new VRDeviceOrientationGamepadCamera
  126096. * @param name defines camera name
  126097. * @param position defines the start position of the camera
  126098. * @param scene defines the scene the camera belongs to
  126099. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126100. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126101. */
  126102. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126103. /**
  126104. * Gets camera class name
  126105. * @returns VRDeviceOrientationGamepadCamera
  126106. */
  126107. getClassName(): string;
  126108. }
  126109. }
  126110. declare module BABYLON {
  126111. /**
  126112. * A class extending Texture allowing drawing on a texture
  126113. * @see https://doc.babylonjs.com/how_to/dynamictexture
  126114. */
  126115. export class DynamicTexture extends Texture {
  126116. private _generateMipMaps;
  126117. private _canvas;
  126118. private _context;
  126119. /**
  126120. * Creates a DynamicTexture
  126121. * @param name defines the name of the texture
  126122. * @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
  126123. * @param scene defines the scene where you want the texture
  126124. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  126125. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126126. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  126127. */
  126128. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  126129. /**
  126130. * Get the current class name of the texture useful for serialization or dynamic coding.
  126131. * @returns "DynamicTexture"
  126132. */
  126133. getClassName(): string;
  126134. /**
  126135. * Gets the current state of canRescale
  126136. */
  126137. get canRescale(): boolean;
  126138. private _recreate;
  126139. /**
  126140. * Scales the texture
  126141. * @param ratio the scale factor to apply to both width and height
  126142. */
  126143. scale(ratio: number): void;
  126144. /**
  126145. * Resizes the texture
  126146. * @param width the new width
  126147. * @param height the new height
  126148. */
  126149. scaleTo(width: number, height: number): void;
  126150. /**
  126151. * Gets the context of the canvas used by the texture
  126152. * @returns the canvas context of the dynamic texture
  126153. */
  126154. getContext(): CanvasRenderingContext2D;
  126155. /**
  126156. * Clears the texture
  126157. */
  126158. clear(): void;
  126159. /**
  126160. * Updates the texture
  126161. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126162. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  126163. */
  126164. update(invertY?: boolean, premulAlpha?: boolean): void;
  126165. /**
  126166. * Draws text onto the texture
  126167. * @param text defines the text to be drawn
  126168. * @param x defines the placement of the text from the left
  126169. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  126170. * @param font defines the font to be used with font-style, font-size, font-name
  126171. * @param color defines the color used for the text
  126172. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  126173. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126174. * @param update defines whether texture is immediately update (default is true)
  126175. */
  126176. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  126177. /**
  126178. * Clones the texture
  126179. * @returns the clone of the texture.
  126180. */
  126181. clone(): DynamicTexture;
  126182. /**
  126183. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  126184. * @returns a serialized dynamic texture object
  126185. */
  126186. serialize(): any;
  126187. private _IsCanvasElement;
  126188. /** @hidden */
  126189. _rebuild(): void;
  126190. }
  126191. }
  126192. declare module BABYLON {
  126193. /**
  126194. * Class containing static functions to help procedurally build meshes
  126195. */
  126196. export class GroundBuilder {
  126197. /**
  126198. * Creates a ground mesh
  126199. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  126200. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  126201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126202. * @param name defines the name of the mesh
  126203. * @param options defines the options used to create the mesh
  126204. * @param scene defines the hosting scene
  126205. * @returns the ground mesh
  126206. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  126207. */
  126208. static CreateGround(name: string, options: {
  126209. width?: number;
  126210. height?: number;
  126211. subdivisions?: number;
  126212. subdivisionsX?: number;
  126213. subdivisionsY?: number;
  126214. updatable?: boolean;
  126215. }, scene: any): Mesh;
  126216. /**
  126217. * Creates a tiled ground mesh
  126218. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  126219. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  126220. * * 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
  126221. * * 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
  126222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126223. * @param name defines the name of the mesh
  126224. * @param options defines the options used to create the mesh
  126225. * @param scene defines the hosting scene
  126226. * @returns the tiled ground mesh
  126227. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  126228. */
  126229. static CreateTiledGround(name: string, options: {
  126230. xmin: number;
  126231. zmin: number;
  126232. xmax: number;
  126233. zmax: number;
  126234. subdivisions?: {
  126235. w: number;
  126236. h: number;
  126237. };
  126238. precision?: {
  126239. w: number;
  126240. h: number;
  126241. };
  126242. updatable?: boolean;
  126243. }, scene?: Nullable<Scene>): Mesh;
  126244. /**
  126245. * Creates a ground mesh from a height map
  126246. * * The parameter `url` sets the URL of the height map image resource.
  126247. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  126248. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  126249. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  126250. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  126251. * * 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.
  126252. * * 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).
  126253. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  126254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126255. * @param name defines the name of the mesh
  126256. * @param url defines the url to the height map
  126257. * @param options defines the options used to create the mesh
  126258. * @param scene defines the hosting scene
  126259. * @returns the ground mesh
  126260. * @see https://doc.babylonjs.com/babylon101/height_map
  126261. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  126262. */
  126263. static CreateGroundFromHeightMap(name: string, url: string, options: {
  126264. width?: number;
  126265. height?: number;
  126266. subdivisions?: number;
  126267. minHeight?: number;
  126268. maxHeight?: number;
  126269. colorFilter?: Color3;
  126270. alphaFilter?: number;
  126271. updatable?: boolean;
  126272. onReady?: (mesh: GroundMesh) => void;
  126273. }, scene?: Nullable<Scene>): GroundMesh;
  126274. }
  126275. }
  126276. declare module BABYLON {
  126277. /**
  126278. * Class containing static functions to help procedurally build meshes
  126279. */
  126280. export class TorusBuilder {
  126281. /**
  126282. * Creates a torus mesh
  126283. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  126284. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  126285. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  126286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126289. * @param name defines the name of the mesh
  126290. * @param options defines the options used to create the mesh
  126291. * @param scene defines the hosting scene
  126292. * @returns the torus mesh
  126293. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  126294. */
  126295. static CreateTorus(name: string, options: {
  126296. diameter?: number;
  126297. thickness?: number;
  126298. tessellation?: number;
  126299. updatable?: boolean;
  126300. sideOrientation?: number;
  126301. frontUVs?: Vector4;
  126302. backUVs?: Vector4;
  126303. }, scene: any): Mesh;
  126304. }
  126305. }
  126306. declare module BABYLON {
  126307. /**
  126308. * Class containing static functions to help procedurally build meshes
  126309. */
  126310. export class CylinderBuilder {
  126311. /**
  126312. * Creates a cylinder or a cone mesh
  126313. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  126314. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  126315. * * 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.
  126316. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  126317. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  126318. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  126319. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  126320. * * 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).
  126321. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  126322. * * 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).
  126323. * * 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
  126324. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  126325. * * 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
  126326. * * 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.
  126327. * * If `enclose` is false, a ring surface is one element.
  126328. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  126329. * * 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
  126330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126333. * @param name defines the name of the mesh
  126334. * @param options defines the options used to create the mesh
  126335. * @param scene defines the hosting scene
  126336. * @returns the cylinder mesh
  126337. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  126338. */
  126339. static CreateCylinder(name: string, options: {
  126340. height?: number;
  126341. diameterTop?: number;
  126342. diameterBottom?: number;
  126343. diameter?: number;
  126344. tessellation?: number;
  126345. subdivisions?: number;
  126346. arc?: number;
  126347. faceColors?: Color4[];
  126348. faceUV?: Vector4[];
  126349. updatable?: boolean;
  126350. hasRings?: boolean;
  126351. enclose?: boolean;
  126352. cap?: number;
  126353. sideOrientation?: number;
  126354. frontUVs?: Vector4;
  126355. backUVs?: Vector4;
  126356. }, scene: any): Mesh;
  126357. }
  126358. }
  126359. declare module BABYLON {
  126360. /**
  126361. * States of the webXR experience
  126362. */
  126363. export enum WebXRState {
  126364. /**
  126365. * Transitioning to being in XR mode
  126366. */
  126367. ENTERING_XR = 0,
  126368. /**
  126369. * Transitioning to non XR mode
  126370. */
  126371. EXITING_XR = 1,
  126372. /**
  126373. * In XR mode and presenting
  126374. */
  126375. IN_XR = 2,
  126376. /**
  126377. * Not entered XR mode
  126378. */
  126379. NOT_IN_XR = 3
  126380. }
  126381. /**
  126382. * Abstraction of the XR render target
  126383. */
  126384. export interface WebXRRenderTarget extends IDisposable {
  126385. /**
  126386. * xrpresent context of the canvas which can be used to display/mirror xr content
  126387. */
  126388. canvasContext: WebGLRenderingContext;
  126389. /**
  126390. * xr layer for the canvas
  126391. */
  126392. xrLayer: Nullable<XRWebGLLayer>;
  126393. /**
  126394. * Initializes the xr layer for the session
  126395. * @param xrSession xr session
  126396. * @returns a promise that will resolve once the XR Layer has been created
  126397. */
  126398. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  126399. }
  126400. }
  126401. declare module BABYLON {
  126402. /**
  126403. * COnfiguration object for WebXR output canvas
  126404. */
  126405. export class WebXRManagedOutputCanvasOptions {
  126406. /**
  126407. * An optional canvas in case you wish to create it yourself and provide it here.
  126408. * If not provided, a new canvas will be created
  126409. */
  126410. canvasElement?: HTMLCanvasElement;
  126411. /**
  126412. * Options for this XR Layer output
  126413. */
  126414. canvasOptions?: XRWebGLLayerOptions;
  126415. /**
  126416. * CSS styling for a newly created canvas (if not provided)
  126417. */
  126418. newCanvasCssStyle?: string;
  126419. /**
  126420. * Get the default values of the configuration object
  126421. * @param engine defines the engine to use (can be null)
  126422. * @returns default values of this configuration object
  126423. */
  126424. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  126425. }
  126426. /**
  126427. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  126428. */
  126429. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  126430. private _options;
  126431. private _canvas;
  126432. private _engine;
  126433. private _originalCanvasSize;
  126434. /**
  126435. * Rendering context of the canvas which can be used to display/mirror xr content
  126436. */
  126437. canvasContext: WebGLRenderingContext;
  126438. /**
  126439. * xr layer for the canvas
  126440. */
  126441. xrLayer: Nullable<XRWebGLLayer>;
  126442. /**
  126443. * Obseervers registered here will be triggered when the xr layer was initialized
  126444. */
  126445. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  126446. /**
  126447. * Initializes the canvas to be added/removed upon entering/exiting xr
  126448. * @param _xrSessionManager The XR Session manager
  126449. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  126450. */
  126451. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  126452. /**
  126453. * Disposes of the object
  126454. */
  126455. dispose(): void;
  126456. /**
  126457. * Initializes the xr layer for the session
  126458. * @param xrSession xr session
  126459. * @returns a promise that will resolve once the XR Layer has been created
  126460. */
  126461. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  126462. private _addCanvas;
  126463. private _removeCanvas;
  126464. private _setCanvasSize;
  126465. private _setManagedOutputCanvas;
  126466. }
  126467. }
  126468. declare module BABYLON {
  126469. /**
  126470. * Manages an XRSession to work with Babylon's engine
  126471. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  126472. */
  126473. export class WebXRSessionManager implements IDisposable {
  126474. /** The scene which the session should be created for */
  126475. scene: Scene;
  126476. private _referenceSpace;
  126477. private _rttProvider;
  126478. private _sessionEnded;
  126479. private _xrNavigator;
  126480. private baseLayer;
  126481. /**
  126482. * The base reference space from which the session started. good if you want to reset your
  126483. * reference space
  126484. */
  126485. baseReferenceSpace: XRReferenceSpace;
  126486. /**
  126487. * Current XR frame
  126488. */
  126489. currentFrame: Nullable<XRFrame>;
  126490. /** WebXR timestamp updated every frame */
  126491. currentTimestamp: number;
  126492. /**
  126493. * Used just in case of a failure to initialize an immersive session.
  126494. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  126495. */
  126496. defaultHeightCompensation: number;
  126497. /**
  126498. * Fires every time a new xrFrame arrives which can be used to update the camera
  126499. */
  126500. onXRFrameObservable: Observable<XRFrame>;
  126501. /**
  126502. * Fires when the reference space changed
  126503. */
  126504. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  126505. /**
  126506. * Fires when the xr session is ended either by the device or manually done
  126507. */
  126508. onXRSessionEnded: Observable<any>;
  126509. /**
  126510. * Fires when the xr session is ended either by the device or manually done
  126511. */
  126512. onXRSessionInit: Observable<XRSession>;
  126513. /**
  126514. * Underlying xr session
  126515. */
  126516. session: XRSession;
  126517. /**
  126518. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  126519. * or get the offset the player is currently at.
  126520. */
  126521. viewerReferenceSpace: XRReferenceSpace;
  126522. /**
  126523. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  126524. * @param scene The scene which the session should be created for
  126525. */
  126526. constructor(
  126527. /** The scene which the session should be created for */
  126528. scene: Scene);
  126529. /**
  126530. * The current reference space used in this session. This reference space can constantly change!
  126531. * It is mainly used to offset the camera's position.
  126532. */
  126533. get referenceSpace(): XRReferenceSpace;
  126534. /**
  126535. * Set a new reference space and triggers the observable
  126536. */
  126537. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  126538. /**
  126539. * Disposes of the session manager
  126540. */
  126541. dispose(): void;
  126542. /**
  126543. * Stops the xrSession and restores the render loop
  126544. * @returns Promise which resolves after it exits XR
  126545. */
  126546. exitXRAsync(): Promise<void>;
  126547. /**
  126548. * Gets the correct render target texture to be rendered this frame for this eye
  126549. * @param eye the eye for which to get the render target
  126550. * @returns the render target for the specified eye
  126551. */
  126552. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  126553. /**
  126554. * Creates a WebXRRenderTarget object for the XR session
  126555. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  126556. * @param options optional options to provide when creating a new render target
  126557. * @returns a WebXR render target to which the session can render
  126558. */
  126559. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  126560. /**
  126561. * Initializes the manager
  126562. * After initialization enterXR can be called to start an XR session
  126563. * @returns Promise which resolves after it is initialized
  126564. */
  126565. initializeAsync(): Promise<void>;
  126566. /**
  126567. * Initializes an xr session
  126568. * @param xrSessionMode mode to initialize
  126569. * @param xrSessionInit defines optional and required values to pass to the session builder
  126570. * @returns a promise which will resolve once the session has been initialized
  126571. */
  126572. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  126573. /**
  126574. * Checks if a session would be supported for the creation options specified
  126575. * @param sessionMode session mode to check if supported eg. immersive-vr
  126576. * @returns A Promise that resolves to true if supported and false if not
  126577. */
  126578. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  126579. /**
  126580. * Resets the reference space to the one started the session
  126581. */
  126582. resetReferenceSpace(): void;
  126583. /**
  126584. * Starts rendering to the xr layer
  126585. */
  126586. runXRRenderLoop(): void;
  126587. /**
  126588. * Sets the reference space on the xr session
  126589. * @param referenceSpaceType space to set
  126590. * @returns a promise that will resolve once the reference space has been set
  126591. */
  126592. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  126593. /**
  126594. * Updates the render state of the session
  126595. * @param state state to set
  126596. * @returns a promise that resolves once the render state has been updated
  126597. */
  126598. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  126599. /**
  126600. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  126601. * @param sessionMode defines the session to test
  126602. * @returns a promise with boolean as final value
  126603. */
  126604. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  126605. private _createRenderTargetTexture;
  126606. }
  126607. }
  126608. declare module BABYLON {
  126609. /**
  126610. * WebXR Camera which holds the views for the xrSession
  126611. * @see https://doc.babylonjs.com/how_to/webxr_camera
  126612. */
  126613. export class WebXRCamera extends FreeCamera {
  126614. private _xrSessionManager;
  126615. private _firstFrame;
  126616. private _referenceQuaternion;
  126617. private _referencedPosition;
  126618. private _xrInvPositionCache;
  126619. private _xrInvQuaternionCache;
  126620. /**
  126621. * Observable raised before camera teleportation
  126622. */
  126623. onBeforeCameraTeleport: Observable<Vector3>;
  126624. /**
  126625. * Observable raised after camera teleportation
  126626. */
  126627. onAfterCameraTeleport: Observable<Vector3>;
  126628. /**
  126629. * Should position compensation execute on first frame.
  126630. * This is used when copying the position from a native (non XR) camera
  126631. */
  126632. compensateOnFirstFrame: boolean;
  126633. /**
  126634. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  126635. * @param name the name of the camera
  126636. * @param scene the scene to add the camera to
  126637. * @param _xrSessionManager a constructed xr session manager
  126638. */
  126639. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  126640. /**
  126641. * Return the user's height, unrelated to the current ground.
  126642. * This will be the y position of this camera, when ground level is 0.
  126643. */
  126644. get realWorldHeight(): number;
  126645. /** @hidden */
  126646. _updateForDualEyeDebugging(): void;
  126647. /**
  126648. * Sets this camera's transformation based on a non-vr camera
  126649. * @param otherCamera the non-vr camera to copy the transformation from
  126650. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  126651. */
  126652. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  126653. /**
  126654. * Gets the current instance class name ("WebXRCamera").
  126655. * @returns the class name
  126656. */
  126657. getClassName(): string;
  126658. private _rotate180;
  126659. private _updateFromXRSession;
  126660. private _updateNumberOfRigCameras;
  126661. private _updateReferenceSpace;
  126662. private _updateReferenceSpaceOffset;
  126663. }
  126664. }
  126665. declare module BABYLON {
  126666. /**
  126667. * Defining the interface required for a (webxr) feature
  126668. */
  126669. export interface IWebXRFeature extends IDisposable {
  126670. /**
  126671. * Is this feature attached
  126672. */
  126673. attached: boolean;
  126674. /**
  126675. * Should auto-attach be disabled?
  126676. */
  126677. disableAutoAttach: boolean;
  126678. /**
  126679. * Attach the feature to the session
  126680. * Will usually be called by the features manager
  126681. *
  126682. * @param force should attachment be forced (even when already attached)
  126683. * @returns true if successful.
  126684. */
  126685. attach(force?: boolean): boolean;
  126686. /**
  126687. * Detach the feature from the session
  126688. * Will usually be called by the features manager
  126689. *
  126690. * @returns true if successful.
  126691. */
  126692. detach(): boolean;
  126693. /**
  126694. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  126695. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  126696. *
  126697. * @returns whether or not the feature is compatible in this environment
  126698. */
  126699. isCompatible(): boolean;
  126700. /**
  126701. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  126702. */
  126703. xrNativeFeatureName?: string;
  126704. /**
  126705. * A list of (Babylon WebXR) features this feature depends on
  126706. */
  126707. dependsOn?: string[];
  126708. }
  126709. /**
  126710. * A list of the currently available features without referencing them
  126711. */
  126712. export class WebXRFeatureName {
  126713. /**
  126714. * The name of the anchor system feature
  126715. */
  126716. static readonly ANCHOR_SYSTEM: string;
  126717. /**
  126718. * The name of the background remover feature
  126719. */
  126720. static readonly BACKGROUND_REMOVER: string;
  126721. /**
  126722. * The name of the hit test feature
  126723. */
  126724. static readonly HIT_TEST: string;
  126725. /**
  126726. * physics impostors for xr controllers feature
  126727. */
  126728. static readonly PHYSICS_CONTROLLERS: string;
  126729. /**
  126730. * The name of the plane detection feature
  126731. */
  126732. static readonly PLANE_DETECTION: string;
  126733. /**
  126734. * The name of the pointer selection feature
  126735. */
  126736. static readonly POINTER_SELECTION: string;
  126737. /**
  126738. * The name of the teleportation feature
  126739. */
  126740. static readonly TELEPORTATION: string;
  126741. /**
  126742. * The name of the feature points feature.
  126743. */
  126744. static readonly FEATURE_POINTS: string;
  126745. /**
  126746. * The name of the hand tracking feature.
  126747. */
  126748. static readonly HAND_TRACKING: string;
  126749. }
  126750. /**
  126751. * Defining the constructor of a feature. Used to register the modules.
  126752. */
  126753. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  126754. /**
  126755. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  126756. * It is mainly used in AR sessions.
  126757. *
  126758. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  126759. */
  126760. export class WebXRFeaturesManager implements IDisposable {
  126761. private _xrSessionManager;
  126762. private static readonly _AvailableFeatures;
  126763. private _features;
  126764. /**
  126765. * constructs a new features manages.
  126766. *
  126767. * @param _xrSessionManager an instance of WebXRSessionManager
  126768. */
  126769. constructor(_xrSessionManager: WebXRSessionManager);
  126770. /**
  126771. * Used to register a module. After calling this function a developer can use this feature in the scene.
  126772. * Mainly used internally.
  126773. *
  126774. * @param featureName the name of the feature to register
  126775. * @param constructorFunction the function used to construct the module
  126776. * @param version the (babylon) version of the module
  126777. * @param stable is that a stable version of this module
  126778. */
  126779. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  126780. /**
  126781. * Returns a constructor of a specific feature.
  126782. *
  126783. * @param featureName the name of the feature to construct
  126784. * @param version the version of the feature to load
  126785. * @param xrSessionManager the xrSessionManager. Used to construct the module
  126786. * @param options optional options provided to the module.
  126787. * @returns a function that, when called, will return a new instance of this feature
  126788. */
  126789. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  126790. /**
  126791. * Can be used to return the list of features currently registered
  126792. *
  126793. * @returns an Array of available features
  126794. */
  126795. static GetAvailableFeatures(): string[];
  126796. /**
  126797. * Gets the versions available for a specific feature
  126798. * @param featureName the name of the feature
  126799. * @returns an array with the available versions
  126800. */
  126801. static GetAvailableVersions(featureName: string): string[];
  126802. /**
  126803. * Return the latest unstable version of this feature
  126804. * @param featureName the name of the feature to search
  126805. * @returns the version number. if not found will return -1
  126806. */
  126807. static GetLatestVersionOfFeature(featureName: string): number;
  126808. /**
  126809. * Return the latest stable version of this feature
  126810. * @param featureName the name of the feature to search
  126811. * @returns the version number. if not found will return -1
  126812. */
  126813. static GetStableVersionOfFeature(featureName: string): number;
  126814. /**
  126815. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  126816. * Can be used during a session to start a feature
  126817. * @param featureName the name of feature to attach
  126818. */
  126819. attachFeature(featureName: string): void;
  126820. /**
  126821. * Can be used inside a session or when the session ends to detach a specific feature
  126822. * @param featureName the name of the feature to detach
  126823. */
  126824. detachFeature(featureName: string): void;
  126825. /**
  126826. * Used to disable an already-enabled feature
  126827. * The feature will be disposed and will be recreated once enabled.
  126828. * @param featureName the feature to disable
  126829. * @returns true if disable was successful
  126830. */
  126831. disableFeature(featureName: string | {
  126832. Name: string;
  126833. }): boolean;
  126834. /**
  126835. * dispose this features manager
  126836. */
  126837. dispose(): void;
  126838. /**
  126839. * 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.
  126840. * 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.
  126841. *
  126842. * @param featureName the name of the feature to load or the class of the feature
  126843. * @param version optional version to load. if not provided the latest version will be enabled
  126844. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  126845. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  126846. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  126847. * @returns a new constructed feature or throws an error if feature not found.
  126848. */
  126849. enableFeature(featureName: string | {
  126850. Name: string;
  126851. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  126852. /**
  126853. * get the implementation of an enabled feature.
  126854. * @param featureName the name of the feature to load
  126855. * @returns the feature class, if found
  126856. */
  126857. getEnabledFeature(featureName: string): IWebXRFeature;
  126858. /**
  126859. * Get the list of enabled features
  126860. * @returns an array of enabled features
  126861. */
  126862. getEnabledFeatures(): string[];
  126863. /**
  126864. * This function will exten the session creation configuration object with enabled features.
  126865. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  126866. * according to the defined "required" variable, provided during enableFeature call
  126867. * @param xrSessionInit the xr Session init object to extend
  126868. *
  126869. * @returns an extended XRSessionInit object
  126870. */
  126871. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  126872. }
  126873. }
  126874. declare module BABYLON {
  126875. /**
  126876. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  126877. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  126878. */
  126879. export class WebXRExperienceHelper implements IDisposable {
  126880. private scene;
  126881. private _nonVRCamera;
  126882. private _originalSceneAutoClear;
  126883. private _supported;
  126884. /**
  126885. * Camera used to render xr content
  126886. */
  126887. camera: WebXRCamera;
  126888. /** A features manager for this xr session */
  126889. featuresManager: WebXRFeaturesManager;
  126890. /**
  126891. * Observers registered here will be triggered after the camera's initial transformation is set
  126892. * This can be used to set a different ground level or an extra rotation.
  126893. *
  126894. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  126895. * to the position set after this observable is done executing.
  126896. */
  126897. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  126898. /**
  126899. * Fires when the state of the experience helper has changed
  126900. */
  126901. onStateChangedObservable: Observable<WebXRState>;
  126902. /** Session manager used to keep track of xr session */
  126903. sessionManager: WebXRSessionManager;
  126904. /**
  126905. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  126906. */
  126907. state: WebXRState;
  126908. /**
  126909. * Creates a WebXRExperienceHelper
  126910. * @param scene The scene the helper should be created in
  126911. */
  126912. private constructor();
  126913. /**
  126914. * Creates the experience helper
  126915. * @param scene the scene to attach the experience helper to
  126916. * @returns a promise for the experience helper
  126917. */
  126918. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  126919. /**
  126920. * Disposes of the experience helper
  126921. */
  126922. dispose(): void;
  126923. /**
  126924. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  126925. * @param sessionMode options for the XR session
  126926. * @param referenceSpaceType frame of reference of the XR session
  126927. * @param renderTarget the output canvas that will be used to enter XR mode
  126928. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  126929. * @returns promise that resolves after xr mode has entered
  126930. */
  126931. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  126932. /**
  126933. * Exits XR mode and returns the scene to its original state
  126934. * @returns promise that resolves after xr mode has exited
  126935. */
  126936. exitXRAsync(): Promise<void>;
  126937. private _nonXRToXRCamera;
  126938. private _setState;
  126939. }
  126940. }
  126941. declare module BABYLON {
  126942. /**
  126943. * X-Y values for axes in WebXR
  126944. */
  126945. export interface IWebXRMotionControllerAxesValue {
  126946. /**
  126947. * The value of the x axis
  126948. */
  126949. x: number;
  126950. /**
  126951. * The value of the y-axis
  126952. */
  126953. y: number;
  126954. }
  126955. /**
  126956. * changed / previous values for the values of this component
  126957. */
  126958. export interface IWebXRMotionControllerComponentChangesValues<T> {
  126959. /**
  126960. * current (this frame) value
  126961. */
  126962. current: T;
  126963. /**
  126964. * previous (last change) value
  126965. */
  126966. previous: T;
  126967. }
  126968. /**
  126969. * Represents changes in the component between current frame and last values recorded
  126970. */
  126971. export interface IWebXRMotionControllerComponentChanges {
  126972. /**
  126973. * will be populated with previous and current values if axes changed
  126974. */
  126975. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  126976. /**
  126977. * will be populated with previous and current values if pressed changed
  126978. */
  126979. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  126980. /**
  126981. * will be populated with previous and current values if touched changed
  126982. */
  126983. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  126984. /**
  126985. * will be populated with previous and current values if value changed
  126986. */
  126987. value?: IWebXRMotionControllerComponentChangesValues<number>;
  126988. }
  126989. /**
  126990. * This class represents a single component (for example button or thumbstick) of a motion controller
  126991. */
  126992. export class WebXRControllerComponent implements IDisposable {
  126993. /**
  126994. * the id of this component
  126995. */
  126996. id: string;
  126997. /**
  126998. * the type of the component
  126999. */
  127000. type: MotionControllerComponentType;
  127001. private _buttonIndex;
  127002. private _axesIndices;
  127003. private _axes;
  127004. private _changes;
  127005. private _currentValue;
  127006. private _hasChanges;
  127007. private _pressed;
  127008. private _touched;
  127009. /**
  127010. * button component type
  127011. */
  127012. static BUTTON_TYPE: MotionControllerComponentType;
  127013. /**
  127014. * squeeze component type
  127015. */
  127016. static SQUEEZE_TYPE: MotionControllerComponentType;
  127017. /**
  127018. * Thumbstick component type
  127019. */
  127020. static THUMBSTICK_TYPE: MotionControllerComponentType;
  127021. /**
  127022. * Touchpad component type
  127023. */
  127024. static TOUCHPAD_TYPE: MotionControllerComponentType;
  127025. /**
  127026. * trigger component type
  127027. */
  127028. static TRIGGER_TYPE: MotionControllerComponentType;
  127029. /**
  127030. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  127031. * the axes data changes
  127032. */
  127033. onAxisValueChangedObservable: Observable<{
  127034. x: number;
  127035. y: number;
  127036. }>;
  127037. /**
  127038. * Observers registered here will be triggered when the state of a button changes
  127039. * State change is either pressed / touched / value
  127040. */
  127041. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  127042. /**
  127043. * Creates a new component for a motion controller.
  127044. * It is created by the motion controller itself
  127045. *
  127046. * @param id the id of this component
  127047. * @param type the type of the component
  127048. * @param _buttonIndex index in the buttons array of the gamepad
  127049. * @param _axesIndices indices of the values in the axes array of the gamepad
  127050. */
  127051. constructor(
  127052. /**
  127053. * the id of this component
  127054. */
  127055. id: string,
  127056. /**
  127057. * the type of the component
  127058. */
  127059. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  127060. /**
  127061. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  127062. */
  127063. get axes(): IWebXRMotionControllerAxesValue;
  127064. /**
  127065. * Get the changes. Elements will be populated only if they changed with their previous and current value
  127066. */
  127067. get changes(): IWebXRMotionControllerComponentChanges;
  127068. /**
  127069. * Return whether or not the component changed the last frame
  127070. */
  127071. get hasChanges(): boolean;
  127072. /**
  127073. * is the button currently pressed
  127074. */
  127075. get pressed(): boolean;
  127076. /**
  127077. * is the button currently touched
  127078. */
  127079. get touched(): boolean;
  127080. /**
  127081. * Get the current value of this component
  127082. */
  127083. get value(): number;
  127084. /**
  127085. * Dispose this component
  127086. */
  127087. dispose(): void;
  127088. /**
  127089. * Are there axes correlating to this component
  127090. * @return true is axes data is available
  127091. */
  127092. isAxes(): boolean;
  127093. /**
  127094. * Is this component a button (hence - pressable)
  127095. * @returns true if can be pressed
  127096. */
  127097. isButton(): boolean;
  127098. /**
  127099. * update this component using the gamepad object it is in. Called on every frame
  127100. * @param nativeController the native gamepad controller object
  127101. */
  127102. update(nativeController: IMinimalMotionControllerObject): void;
  127103. }
  127104. }
  127105. declare module BABYLON {
  127106. /**
  127107. * Interface used to represent data loading progression
  127108. */
  127109. export interface ISceneLoaderProgressEvent {
  127110. /**
  127111. * Defines if data length to load can be evaluated
  127112. */
  127113. readonly lengthComputable: boolean;
  127114. /**
  127115. * Defines the loaded data length
  127116. */
  127117. readonly loaded: number;
  127118. /**
  127119. * Defines the data length to load
  127120. */
  127121. readonly total: number;
  127122. }
  127123. /**
  127124. * Interface used by SceneLoader plugins to define supported file extensions
  127125. */
  127126. export interface ISceneLoaderPluginExtensions {
  127127. /**
  127128. * Defines the list of supported extensions
  127129. */
  127130. [extension: string]: {
  127131. isBinary: boolean;
  127132. };
  127133. }
  127134. /**
  127135. * Interface used by SceneLoader plugin factory
  127136. */
  127137. export interface ISceneLoaderPluginFactory {
  127138. /**
  127139. * Defines the name of the factory
  127140. */
  127141. name: string;
  127142. /**
  127143. * Function called to create a new plugin
  127144. * @return the new plugin
  127145. */
  127146. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  127147. /**
  127148. * The callback that returns true if the data can be directly loaded.
  127149. * @param data string containing the file data
  127150. * @returns if the data can be loaded directly
  127151. */
  127152. canDirectLoad?(data: string): boolean;
  127153. }
  127154. /**
  127155. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  127156. */
  127157. export interface ISceneLoaderPluginBase {
  127158. /**
  127159. * The friendly name of this plugin.
  127160. */
  127161. name: string;
  127162. /**
  127163. * The file extensions supported by this plugin.
  127164. */
  127165. extensions: string | ISceneLoaderPluginExtensions;
  127166. /**
  127167. * The callback called when loading from a url.
  127168. * @param scene scene loading this url
  127169. * @param url url to load
  127170. * @param onSuccess callback called when the file successfully loads
  127171. * @param onProgress callback called while file is loading (if the server supports this mode)
  127172. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  127173. * @param onError callback called when the file fails to load
  127174. * @returns a file request object
  127175. */
  127176. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  127177. /**
  127178. * The callback called when loading from a file object.
  127179. * @param scene scene loading this file
  127180. * @param file defines the file to load
  127181. * @param onSuccess defines the callback to call when data is loaded
  127182. * @param onProgress defines the callback to call during loading process
  127183. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  127184. * @param onError defines the callback to call when an error occurs
  127185. * @returns a file request object
  127186. */
  127187. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  127188. /**
  127189. * The callback that returns true if the data can be directly loaded.
  127190. * @param data string containing the file data
  127191. * @returns if the data can be loaded directly
  127192. */
  127193. canDirectLoad?(data: string): boolean;
  127194. /**
  127195. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  127196. * @param scene scene loading this data
  127197. * @param data string containing the data
  127198. * @returns data to pass to the plugin
  127199. */
  127200. directLoad?(scene: Scene, data: string): any;
  127201. /**
  127202. * The callback that allows custom handling of the root url based on the response url.
  127203. * @param rootUrl the original root url
  127204. * @param responseURL the response url if available
  127205. * @returns the new root url
  127206. */
  127207. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  127208. }
  127209. /**
  127210. * Interface used to define a SceneLoader plugin
  127211. */
  127212. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  127213. /**
  127214. * Import meshes into a scene.
  127215. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127216. * @param scene The scene to import into
  127217. * @param data The data to import
  127218. * @param rootUrl The root url for scene and resources
  127219. * @param meshes The meshes array to import into
  127220. * @param particleSystems The particle systems array to import into
  127221. * @param skeletons The skeletons array to import into
  127222. * @param onError The callback when import fails
  127223. * @returns True if successful or false otherwise
  127224. */
  127225. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  127226. /**
  127227. * Load into a scene.
  127228. * @param scene The scene to load into
  127229. * @param data The data to import
  127230. * @param rootUrl The root url for scene and resources
  127231. * @param onError The callback when import fails
  127232. * @returns True if successful or false otherwise
  127233. */
  127234. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  127235. /**
  127236. * Load into an asset container.
  127237. * @param scene The scene to load into
  127238. * @param data The data to import
  127239. * @param rootUrl The root url for scene and resources
  127240. * @param onError The callback when import fails
  127241. * @returns The loaded asset container
  127242. */
  127243. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  127244. }
  127245. /**
  127246. * Interface used to define an async SceneLoader plugin
  127247. */
  127248. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  127249. /**
  127250. * Import meshes into a scene.
  127251. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127252. * @param scene The scene to import into
  127253. * @param data The data to import
  127254. * @param rootUrl The root url for scene and resources
  127255. * @param onProgress The callback when the load progresses
  127256. * @param fileName Defines the name of the file to load
  127257. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  127258. */
  127259. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  127260. meshes: AbstractMesh[];
  127261. particleSystems: IParticleSystem[];
  127262. skeletons: Skeleton[];
  127263. animationGroups: AnimationGroup[];
  127264. }>;
  127265. /**
  127266. * Load into a scene.
  127267. * @param scene The scene to load into
  127268. * @param data The data to import
  127269. * @param rootUrl The root url for scene and resources
  127270. * @param onProgress The callback when the load progresses
  127271. * @param fileName Defines the name of the file to load
  127272. * @returns Nothing
  127273. */
  127274. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  127275. /**
  127276. * Load into an asset container.
  127277. * @param scene The scene to load into
  127278. * @param data The data to import
  127279. * @param rootUrl The root url for scene and resources
  127280. * @param onProgress The callback when the load progresses
  127281. * @param fileName Defines the name of the file to load
  127282. * @returns The loaded asset container
  127283. */
  127284. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  127285. }
  127286. /**
  127287. * Mode that determines how to handle old animation groups before loading new ones.
  127288. */
  127289. export enum SceneLoaderAnimationGroupLoadingMode {
  127290. /**
  127291. * Reset all old animations to initial state then dispose them.
  127292. */
  127293. Clean = 0,
  127294. /**
  127295. * Stop all old animations.
  127296. */
  127297. Stop = 1,
  127298. /**
  127299. * Restart old animations from first frame.
  127300. */
  127301. Sync = 2,
  127302. /**
  127303. * Old animations remains untouched.
  127304. */
  127305. NoSync = 3
  127306. }
  127307. /**
  127308. * Defines a plugin registered by the SceneLoader
  127309. */
  127310. interface IRegisteredPlugin {
  127311. /**
  127312. * Defines the plugin to use
  127313. */
  127314. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  127315. /**
  127316. * Defines if the plugin supports binary data
  127317. */
  127318. isBinary: boolean;
  127319. }
  127320. /**
  127321. * Class used to load scene from various file formats using registered plugins
  127322. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  127323. */
  127324. export class SceneLoader {
  127325. /**
  127326. * No logging while loading
  127327. */
  127328. static readonly NO_LOGGING: number;
  127329. /**
  127330. * Minimal logging while loading
  127331. */
  127332. static readonly MINIMAL_LOGGING: number;
  127333. /**
  127334. * Summary logging while loading
  127335. */
  127336. static readonly SUMMARY_LOGGING: number;
  127337. /**
  127338. * Detailled logging while loading
  127339. */
  127340. static readonly DETAILED_LOGGING: number;
  127341. /**
  127342. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  127343. */
  127344. static get ForceFullSceneLoadingForIncremental(): boolean;
  127345. static set ForceFullSceneLoadingForIncremental(value: boolean);
  127346. /**
  127347. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  127348. */
  127349. static get ShowLoadingScreen(): boolean;
  127350. static set ShowLoadingScreen(value: boolean);
  127351. /**
  127352. * Defines the current logging level (while loading the scene)
  127353. * @ignorenaming
  127354. */
  127355. static get loggingLevel(): number;
  127356. static set loggingLevel(value: number);
  127357. /**
  127358. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  127359. */
  127360. static get CleanBoneMatrixWeights(): boolean;
  127361. static set CleanBoneMatrixWeights(value: boolean);
  127362. /**
  127363. * Event raised when a plugin is used to load a scene
  127364. */
  127365. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  127366. private static _registeredPlugins;
  127367. private static _showingLoadingScreen;
  127368. /**
  127369. * Gets the default plugin (used to load Babylon files)
  127370. * @returns the .babylon plugin
  127371. */
  127372. static GetDefaultPlugin(): IRegisteredPlugin;
  127373. private static _GetPluginForExtension;
  127374. private static _GetPluginForDirectLoad;
  127375. private static _GetPluginForFilename;
  127376. private static _GetDirectLoad;
  127377. private static _LoadData;
  127378. private static _GetFileInfo;
  127379. /**
  127380. * Gets a plugin that can load the given extension
  127381. * @param extension defines the extension to load
  127382. * @returns a plugin or null if none works
  127383. */
  127384. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  127385. /**
  127386. * Gets a boolean indicating that the given extension can be loaded
  127387. * @param extension defines the extension to load
  127388. * @returns true if the extension is supported
  127389. */
  127390. static IsPluginForExtensionAvailable(extension: string): boolean;
  127391. /**
  127392. * Adds a new plugin to the list of registered plugins
  127393. * @param plugin defines the plugin to add
  127394. */
  127395. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  127396. /**
  127397. * Import meshes into a scene
  127398. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127399. * @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)
  127400. * @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)
  127401. * @param scene the instance of BABYLON.Scene to append to
  127402. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  127403. * @param onProgress a callback with a progress event for each file being loaded
  127404. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127405. * @param pluginExtension the extension used to determine the plugin
  127406. * @returns The loaded plugin
  127407. */
  127408. 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>;
  127409. /**
  127410. * Import meshes into a scene
  127411. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127412. * @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)
  127413. * @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)
  127414. * @param scene the instance of BABYLON.Scene to append to
  127415. * @param onProgress a callback with a progress event for each file being loaded
  127416. * @param pluginExtension the extension used to determine the plugin
  127417. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  127418. */
  127419. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  127420. meshes: AbstractMesh[];
  127421. particleSystems: IParticleSystem[];
  127422. skeletons: Skeleton[];
  127423. animationGroups: AnimationGroup[];
  127424. }>;
  127425. /**
  127426. * Load a scene
  127427. * @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)
  127428. * @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)
  127429. * @param engine is the instance of BABYLON.Engine to use to create the scene
  127430. * @param onSuccess a callback with the scene when import succeeds
  127431. * @param onProgress a callback with a progress event for each file being loaded
  127432. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127433. * @param pluginExtension the extension used to determine the plugin
  127434. * @returns The loaded plugin
  127435. */
  127436. 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>;
  127437. /**
  127438. * Load a scene
  127439. * @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)
  127440. * @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)
  127441. * @param engine is the instance of BABYLON.Engine to use to create the scene
  127442. * @param onProgress a callback with a progress event for each file being loaded
  127443. * @param pluginExtension the extension used to determine the plugin
  127444. * @returns The loaded scene
  127445. */
  127446. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  127447. /**
  127448. * Append a scene
  127449. * @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)
  127450. * @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)
  127451. * @param scene is the instance of BABYLON.Scene to append to
  127452. * @param onSuccess a callback with the scene when import succeeds
  127453. * @param onProgress a callback with a progress event for each file being loaded
  127454. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127455. * @param pluginExtension the extension used to determine the plugin
  127456. * @returns The loaded plugin
  127457. */
  127458. 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>;
  127459. /**
  127460. * Append a scene
  127461. * @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)
  127462. * @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)
  127463. * @param scene is the instance of BABYLON.Scene to append to
  127464. * @param onProgress a callback with a progress event for each file being loaded
  127465. * @param pluginExtension the extension used to determine the plugin
  127466. * @returns The given scene
  127467. */
  127468. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  127469. /**
  127470. * Load a scene into an asset container
  127471. * @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)
  127472. * @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)
  127473. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127474. * @param onSuccess a callback with the scene when import succeeds
  127475. * @param onProgress a callback with a progress event for each file being loaded
  127476. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127477. * @param pluginExtension the extension used to determine the plugin
  127478. * @returns The loaded plugin
  127479. */
  127480. 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>;
  127481. /**
  127482. * Load a scene into an asset container
  127483. * @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)
  127484. * @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)
  127485. * @param scene is the instance of Scene to append to
  127486. * @param onProgress a callback with a progress event for each file being loaded
  127487. * @param pluginExtension the extension used to determine the plugin
  127488. * @returns The loaded asset container
  127489. */
  127490. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  127491. /**
  127492. * Import animations from a file into a scene
  127493. * @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)
  127494. * @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)
  127495. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127496. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  127497. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  127498. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  127499. * @param onSuccess a callback with the scene when import succeeds
  127500. * @param onProgress a callback with a progress event for each file being loaded
  127501. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127502. * @param pluginExtension the extension used to determine the plugin
  127503. */
  127504. 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;
  127505. /**
  127506. * Import animations from a file into a scene
  127507. * @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)
  127508. * @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)
  127509. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127510. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  127511. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  127512. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  127513. * @param onSuccess a callback with the scene when import succeeds
  127514. * @param onProgress a callback with a progress event for each file being loaded
  127515. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127516. * @param pluginExtension the extension used to determine the plugin
  127517. * @returns the updated scene with imported animations
  127518. */
  127519. 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>;
  127520. }
  127521. }
  127522. declare module BABYLON {
  127523. /**
  127524. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  127525. */
  127526. export type MotionControllerHandedness = "none" | "left" | "right";
  127527. /**
  127528. * The type of components available in motion controllers.
  127529. * This is not the name of the component.
  127530. */
  127531. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  127532. /**
  127533. * The state of a controller component
  127534. */
  127535. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  127536. /**
  127537. * The schema of motion controller layout.
  127538. * No object will be initialized using this interface
  127539. * This is used just to define the profile.
  127540. */
  127541. export interface IMotionControllerLayout {
  127542. /**
  127543. * Path to load the assets. Usually relative to the base path
  127544. */
  127545. assetPath: string;
  127546. /**
  127547. * Available components (unsorted)
  127548. */
  127549. components: {
  127550. /**
  127551. * A map of component Ids
  127552. */
  127553. [componentId: string]: {
  127554. /**
  127555. * The type of input the component outputs
  127556. */
  127557. type: MotionControllerComponentType;
  127558. /**
  127559. * The indices of this component in the gamepad object
  127560. */
  127561. gamepadIndices: {
  127562. /**
  127563. * Index of button
  127564. */
  127565. button?: number;
  127566. /**
  127567. * If available, index of x-axis
  127568. */
  127569. xAxis?: number;
  127570. /**
  127571. * If available, index of y-axis
  127572. */
  127573. yAxis?: number;
  127574. };
  127575. /**
  127576. * The mesh's root node name
  127577. */
  127578. rootNodeName: string;
  127579. /**
  127580. * Animation definitions for this model
  127581. */
  127582. visualResponses: {
  127583. [stateKey: string]: {
  127584. /**
  127585. * What property will be animated
  127586. */
  127587. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  127588. /**
  127589. * What states influence this visual response
  127590. */
  127591. states: MotionControllerComponentStateType[];
  127592. /**
  127593. * Type of animation - movement or visibility
  127594. */
  127595. valueNodeProperty: "transform" | "visibility";
  127596. /**
  127597. * Base node name to move. Its position will be calculated according to the min and max nodes
  127598. */
  127599. valueNodeName?: string;
  127600. /**
  127601. * Minimum movement node
  127602. */
  127603. minNodeName?: string;
  127604. /**
  127605. * Max movement node
  127606. */
  127607. maxNodeName?: string;
  127608. };
  127609. };
  127610. /**
  127611. * If touch enabled, what is the name of node to display user feedback
  127612. */
  127613. touchPointNodeName?: string;
  127614. };
  127615. };
  127616. /**
  127617. * Is it xr standard mapping or not
  127618. */
  127619. gamepadMapping: "" | "xr-standard";
  127620. /**
  127621. * Base root node of this entire model
  127622. */
  127623. rootNodeName: string;
  127624. /**
  127625. * Defines the main button component id
  127626. */
  127627. selectComponentId: string;
  127628. }
  127629. /**
  127630. * A definition for the layout map in the input profile
  127631. */
  127632. export interface IMotionControllerLayoutMap {
  127633. /**
  127634. * Layouts with handedness type as a key
  127635. */
  127636. [handedness: string]: IMotionControllerLayout;
  127637. }
  127638. /**
  127639. * The XR Input profile schema
  127640. * Profiles can be found here:
  127641. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  127642. */
  127643. export interface IMotionControllerProfile {
  127644. /**
  127645. * fallback profiles for this profileId
  127646. */
  127647. fallbackProfileIds: string[];
  127648. /**
  127649. * The layout map, with handedness as key
  127650. */
  127651. layouts: IMotionControllerLayoutMap;
  127652. /**
  127653. * The id of this profile
  127654. * correlates to the profile(s) in the xrInput.profiles array
  127655. */
  127656. profileId: string;
  127657. }
  127658. /**
  127659. * A helper-interface for the 3 meshes needed for controller button animation
  127660. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  127661. */
  127662. export interface IMotionControllerButtonMeshMap {
  127663. /**
  127664. * the mesh that defines the pressed value mesh position.
  127665. * This is used to find the max-position of this button
  127666. */
  127667. pressedMesh: AbstractMesh;
  127668. /**
  127669. * the mesh that defines the unpressed value mesh position.
  127670. * This is used to find the min (or initial) position of this button
  127671. */
  127672. unpressedMesh: AbstractMesh;
  127673. /**
  127674. * The mesh that will be changed when value changes
  127675. */
  127676. valueMesh: AbstractMesh;
  127677. }
  127678. /**
  127679. * A helper-interface for the 3 meshes needed for controller axis animation.
  127680. * This will be expanded when touchpad animations are fully supported
  127681. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  127682. */
  127683. export interface IMotionControllerMeshMap {
  127684. /**
  127685. * the mesh that defines the maximum value mesh position.
  127686. */
  127687. maxMesh?: AbstractMesh;
  127688. /**
  127689. * the mesh that defines the minimum value mesh position.
  127690. */
  127691. minMesh?: AbstractMesh;
  127692. /**
  127693. * The mesh that will be changed when axis value changes
  127694. */
  127695. valueMesh?: AbstractMesh;
  127696. }
  127697. /**
  127698. * The elements needed for change-detection of the gamepad objects in motion controllers
  127699. */
  127700. export interface IMinimalMotionControllerObject {
  127701. /**
  127702. * Available axes of this controller
  127703. */
  127704. axes: number[];
  127705. /**
  127706. * An array of available buttons
  127707. */
  127708. buttons: Array<{
  127709. /**
  127710. * Value of the button/trigger
  127711. */
  127712. value: number;
  127713. /**
  127714. * If the button/trigger is currently touched
  127715. */
  127716. touched: boolean;
  127717. /**
  127718. * If the button/trigger is currently pressed
  127719. */
  127720. pressed: boolean;
  127721. }>;
  127722. /**
  127723. * EXPERIMENTAL haptic support.
  127724. */
  127725. hapticActuators?: Array<{
  127726. pulse: (value: number, duration: number) => Promise<boolean>;
  127727. }>;
  127728. }
  127729. /**
  127730. * An Abstract Motion controller
  127731. * This class receives an xrInput and a profile layout and uses those to initialize the components
  127732. * Each component has an observable to check for changes in value and state
  127733. */
  127734. export abstract class WebXRAbstractMotionController implements IDisposable {
  127735. protected scene: Scene;
  127736. protected layout: IMotionControllerLayout;
  127737. /**
  127738. * The gamepad object correlating to this controller
  127739. */
  127740. gamepadObject: IMinimalMotionControllerObject;
  127741. /**
  127742. * handedness (left/right/none) of this controller
  127743. */
  127744. handedness: MotionControllerHandedness;
  127745. private _initComponent;
  127746. private _modelReady;
  127747. /**
  127748. * A map of components (WebXRControllerComponent) in this motion controller
  127749. * Components have a ComponentType and can also have both button and axis definitions
  127750. */
  127751. readonly components: {
  127752. [id: string]: WebXRControllerComponent;
  127753. };
  127754. /**
  127755. * Disable the model's animation. Can be set at any time.
  127756. */
  127757. disableAnimation: boolean;
  127758. /**
  127759. * Observers registered here will be triggered when the model of this controller is done loading
  127760. */
  127761. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  127762. /**
  127763. * The profile id of this motion controller
  127764. */
  127765. abstract profileId: string;
  127766. /**
  127767. * The root mesh of the model. It is null if the model was not yet initialized
  127768. */
  127769. rootMesh: Nullable<AbstractMesh>;
  127770. /**
  127771. * constructs a new abstract motion controller
  127772. * @param scene the scene to which the model of the controller will be added
  127773. * @param layout The profile layout to load
  127774. * @param gamepadObject The gamepad object correlating to this controller
  127775. * @param handedness handedness (left/right/none) of this controller
  127776. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  127777. */
  127778. constructor(scene: Scene, layout: IMotionControllerLayout,
  127779. /**
  127780. * The gamepad object correlating to this controller
  127781. */
  127782. gamepadObject: IMinimalMotionControllerObject,
  127783. /**
  127784. * handedness (left/right/none) of this controller
  127785. */
  127786. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  127787. /**
  127788. * Dispose this controller, the model mesh and all its components
  127789. */
  127790. dispose(): void;
  127791. /**
  127792. * Returns all components of specific type
  127793. * @param type the type to search for
  127794. * @return an array of components with this type
  127795. */
  127796. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  127797. /**
  127798. * get a component based an its component id as defined in layout.components
  127799. * @param id the id of the component
  127800. * @returns the component correlates to the id or undefined if not found
  127801. */
  127802. getComponent(id: string): WebXRControllerComponent;
  127803. /**
  127804. * Get the list of components available in this motion controller
  127805. * @returns an array of strings correlating to available components
  127806. */
  127807. getComponentIds(): string[];
  127808. /**
  127809. * Get the first component of specific type
  127810. * @param type type of component to find
  127811. * @return a controller component or null if not found
  127812. */
  127813. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  127814. /**
  127815. * Get the main (Select) component of this controller as defined in the layout
  127816. * @returns the main component of this controller
  127817. */
  127818. getMainComponent(): WebXRControllerComponent;
  127819. /**
  127820. * Loads the model correlating to this controller
  127821. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  127822. * @returns A promise fulfilled with the result of the model loading
  127823. */
  127824. loadModel(): Promise<boolean>;
  127825. /**
  127826. * Update this model using the current XRFrame
  127827. * @param xrFrame the current xr frame to use and update the model
  127828. */
  127829. updateFromXRFrame(xrFrame: XRFrame): void;
  127830. /**
  127831. * Backwards compatibility due to a deeply-integrated typo
  127832. */
  127833. get handness(): XREye;
  127834. /**
  127835. * Pulse (vibrate) this controller
  127836. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  127837. * Consecutive calls to this function will cancel the last pulse call
  127838. *
  127839. * @param value the strength of the pulse in 0.0...1.0 range
  127840. * @param duration Duration of the pulse in milliseconds
  127841. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  127842. * @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
  127843. */
  127844. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  127845. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  127846. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  127847. /**
  127848. * Moves the axis on the controller mesh based on its current state
  127849. * @param axis the index of the axis
  127850. * @param axisValue the value of the axis which determines the meshes new position
  127851. * @hidden
  127852. */
  127853. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  127854. /**
  127855. * Update the model itself with the current frame data
  127856. * @param xrFrame the frame to use for updating the model mesh
  127857. */
  127858. protected updateModel(xrFrame: XRFrame): void;
  127859. /**
  127860. * Get the filename and path for this controller's model
  127861. * @returns a map of filename and path
  127862. */
  127863. protected abstract _getFilenameAndPath(): {
  127864. filename: string;
  127865. path: string;
  127866. };
  127867. /**
  127868. * This function is called before the mesh is loaded. It checks for loading constraints.
  127869. * For example, this function can check if the GLB loader is available
  127870. * If this function returns false, the generic controller will be loaded instead
  127871. * @returns Is the client ready to load the mesh
  127872. */
  127873. protected abstract _getModelLoadingConstraints(): boolean;
  127874. /**
  127875. * This function will be called after the model was successfully loaded and can be used
  127876. * for mesh transformations before it is available for the user
  127877. * @param meshes the loaded meshes
  127878. */
  127879. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  127880. /**
  127881. * Set the root mesh for this controller. Important for the WebXR controller class
  127882. * @param meshes the loaded meshes
  127883. */
  127884. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  127885. /**
  127886. * A function executed each frame that updates the mesh (if needed)
  127887. * @param xrFrame the current xrFrame
  127888. */
  127889. protected abstract _updateModel(xrFrame: XRFrame): void;
  127890. private _getGenericFilenameAndPath;
  127891. private _getGenericParentMesh;
  127892. }
  127893. }
  127894. declare module BABYLON {
  127895. /**
  127896. * A generic trigger-only motion controller for WebXR
  127897. */
  127898. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  127899. /**
  127900. * Static version of the profile id of this controller
  127901. */
  127902. static ProfileId: string;
  127903. profileId: string;
  127904. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  127905. protected _getFilenameAndPath(): {
  127906. filename: string;
  127907. path: string;
  127908. };
  127909. protected _getModelLoadingConstraints(): boolean;
  127910. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  127911. protected _setRootMesh(meshes: AbstractMesh[]): void;
  127912. protected _updateModel(): void;
  127913. }
  127914. }
  127915. declare module BABYLON {
  127916. /**
  127917. * Class containing static functions to help procedurally build meshes
  127918. */
  127919. export class SphereBuilder {
  127920. /**
  127921. * Creates a sphere mesh
  127922. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  127923. * * 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`)
  127924. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  127925. * * 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
  127926. * * 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)
  127927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127930. * @param name defines the name of the mesh
  127931. * @param options defines the options used to create the mesh
  127932. * @param scene defines the hosting scene
  127933. * @returns the sphere mesh
  127934. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  127935. */
  127936. static CreateSphere(name: string, options: {
  127937. segments?: number;
  127938. diameter?: number;
  127939. diameterX?: number;
  127940. diameterY?: number;
  127941. diameterZ?: number;
  127942. arc?: number;
  127943. slice?: number;
  127944. sideOrientation?: number;
  127945. frontUVs?: Vector4;
  127946. backUVs?: Vector4;
  127947. updatable?: boolean;
  127948. }, scene?: Nullable<Scene>): Mesh;
  127949. }
  127950. }
  127951. declare module BABYLON {
  127952. /**
  127953. * A profiled motion controller has its profile loaded from an online repository.
  127954. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  127955. */
  127956. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  127957. private _repositoryUrl;
  127958. private _buttonMeshMapping;
  127959. private _touchDots;
  127960. /**
  127961. * The profile ID of this controller. Will be populated when the controller initializes.
  127962. */
  127963. profileId: string;
  127964. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  127965. dispose(): void;
  127966. protected _getFilenameAndPath(): {
  127967. filename: string;
  127968. path: string;
  127969. };
  127970. protected _getModelLoadingConstraints(): boolean;
  127971. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  127972. protected _setRootMesh(meshes: AbstractMesh[]): void;
  127973. protected _updateModel(_xrFrame: XRFrame): void;
  127974. }
  127975. }
  127976. declare module BABYLON {
  127977. /**
  127978. * A construction function type to create a new controller based on an xrInput object
  127979. */
  127980. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  127981. /**
  127982. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  127983. *
  127984. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  127985. * it should be replaced with auto-loaded controllers.
  127986. *
  127987. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  127988. */
  127989. export class WebXRMotionControllerManager {
  127990. private static _AvailableControllers;
  127991. private static _Fallbacks;
  127992. private static _ProfileLoadingPromises;
  127993. private static _ProfilesList;
  127994. /**
  127995. * The base URL of the online controller repository. Can be changed at any time.
  127996. */
  127997. static BaseRepositoryUrl: string;
  127998. /**
  127999. * Which repository gets priority - local or online
  128000. */
  128001. static PrioritizeOnlineRepository: boolean;
  128002. /**
  128003. * Use the online repository, or use only locally-defined controllers
  128004. */
  128005. static UseOnlineRepository: boolean;
  128006. /**
  128007. * Clear the cache used for profile loading and reload when requested again
  128008. */
  128009. static ClearProfilesCache(): void;
  128010. /**
  128011. * Register the default fallbacks.
  128012. * This function is called automatically when this file is imported.
  128013. */
  128014. static DefaultFallbacks(): void;
  128015. /**
  128016. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  128017. * @param profileId the profile to which a fallback needs to be found
  128018. * @return an array with corresponding fallback profiles
  128019. */
  128020. static FindFallbackWithProfileId(profileId: string): string[];
  128021. /**
  128022. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  128023. * The order of search:
  128024. *
  128025. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  128026. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  128027. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  128028. * 4) return the generic trigger controller if none were found
  128029. *
  128030. * @param xrInput the xrInput to which a new controller is initialized
  128031. * @param scene the scene to which the model will be added
  128032. * @param forceProfile force a certain profile for this controller
  128033. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  128034. */
  128035. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  128036. /**
  128037. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  128038. *
  128039. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  128040. *
  128041. * @param type the profile type to register
  128042. * @param constructFunction the function to be called when loading this profile
  128043. */
  128044. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  128045. /**
  128046. * Register a fallback to a specific profile.
  128047. * @param profileId the profileId that will receive the fallbacks
  128048. * @param fallbacks A list of fallback profiles
  128049. */
  128050. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  128051. /**
  128052. * Will update the list of profiles available in the repository
  128053. * @return a promise that resolves to a map of profiles available online
  128054. */
  128055. static UpdateProfilesList(): Promise<{
  128056. [profile: string]: string;
  128057. }>;
  128058. private static _LoadProfileFromRepository;
  128059. private static _LoadProfilesFromAvailableControllers;
  128060. }
  128061. }
  128062. declare module BABYLON {
  128063. /**
  128064. * Configuration options for the WebXR controller creation
  128065. */
  128066. export interface IWebXRControllerOptions {
  128067. /**
  128068. * Should the controller mesh be animated when a user interacts with it
  128069. * The pressed buttons / thumbstick and touchpad animations will be disabled
  128070. */
  128071. disableMotionControllerAnimation?: boolean;
  128072. /**
  128073. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  128074. */
  128075. doNotLoadControllerMesh?: boolean;
  128076. /**
  128077. * Force a specific controller type for this controller.
  128078. * This can be used when creating your own profile or when testing different controllers
  128079. */
  128080. forceControllerProfile?: string;
  128081. /**
  128082. * Defines a rendering group ID for meshes that will be loaded.
  128083. * This is for the default controllers only.
  128084. */
  128085. renderingGroupId?: number;
  128086. }
  128087. /**
  128088. * Represents an XR controller
  128089. */
  128090. export class WebXRInputSource {
  128091. private _scene;
  128092. /** The underlying input source for the controller */
  128093. inputSource: XRInputSource;
  128094. private _options;
  128095. private _tmpVector;
  128096. private _uniqueId;
  128097. private _disposed;
  128098. /**
  128099. * 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
  128100. */
  128101. grip?: AbstractMesh;
  128102. /**
  128103. * If available, this is the gamepad object related to this controller.
  128104. * Using this object it is possible to get click events and trackpad changes of the
  128105. * webxr controller that is currently being used.
  128106. */
  128107. motionController?: WebXRAbstractMotionController;
  128108. /**
  128109. * Event that fires when the controller is removed/disposed.
  128110. * The object provided as event data is this controller, after associated assets were disposed.
  128111. * uniqueId is still available.
  128112. */
  128113. onDisposeObservable: Observable<WebXRInputSource>;
  128114. /**
  128115. * Will be triggered when the mesh associated with the motion controller is done loading.
  128116. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  128117. * A shortened version of controller -> motion controller -> on mesh loaded.
  128118. */
  128119. onMeshLoadedObservable: Observable<AbstractMesh>;
  128120. /**
  128121. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  128122. */
  128123. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  128124. /**
  128125. * Pointer which can be used to select objects or attach a visible laser to
  128126. */
  128127. pointer: AbstractMesh;
  128128. /**
  128129. * Creates the input source object
  128130. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  128131. * @param _scene the scene which the controller should be associated to
  128132. * @param inputSource the underlying input source for the controller
  128133. * @param _options options for this controller creation
  128134. */
  128135. constructor(_scene: Scene,
  128136. /** The underlying input source for the controller */
  128137. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  128138. /**
  128139. * Get this controllers unique id
  128140. */
  128141. get uniqueId(): string;
  128142. /**
  128143. * Disposes of the object
  128144. */
  128145. dispose(): void;
  128146. /**
  128147. * Gets a world space ray coming from the pointer or grip
  128148. * @param result the resulting ray
  128149. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  128150. */
  128151. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  128152. /**
  128153. * Updates the controller pose based on the given XRFrame
  128154. * @param xrFrame xr frame to update the pose with
  128155. * @param referenceSpace reference space to use
  128156. */
  128157. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  128158. }
  128159. }
  128160. declare module BABYLON {
  128161. /**
  128162. * The schema for initialization options of the XR Input class
  128163. */
  128164. export interface IWebXRInputOptions {
  128165. /**
  128166. * If set to true no model will be automatically loaded
  128167. */
  128168. doNotLoadControllerMeshes?: boolean;
  128169. /**
  128170. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  128171. * If not found, the xr input profile data will be used.
  128172. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  128173. */
  128174. forceInputProfile?: string;
  128175. /**
  128176. * Do not send a request to the controller repository to load the profile.
  128177. *
  128178. * Instead, use the controllers available in babylon itself.
  128179. */
  128180. disableOnlineControllerRepository?: boolean;
  128181. /**
  128182. * A custom URL for the controllers repository
  128183. */
  128184. customControllersRepositoryURL?: string;
  128185. /**
  128186. * Should the controller model's components not move according to the user input
  128187. */
  128188. disableControllerAnimation?: boolean;
  128189. /**
  128190. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  128191. */
  128192. controllerOptions?: IWebXRControllerOptions;
  128193. }
  128194. /**
  128195. * XR input used to track XR inputs such as controllers/rays
  128196. */
  128197. export class WebXRInput implements IDisposable {
  128198. /**
  128199. * the xr session manager for this session
  128200. */
  128201. xrSessionManager: WebXRSessionManager;
  128202. /**
  128203. * the WebXR camera for this session. Mainly used for teleportation
  128204. */
  128205. xrCamera: WebXRCamera;
  128206. private readonly options;
  128207. /**
  128208. * XR controllers being tracked
  128209. */
  128210. controllers: Array<WebXRInputSource>;
  128211. private _frameObserver;
  128212. private _sessionEndedObserver;
  128213. private _sessionInitObserver;
  128214. /**
  128215. * Event when a controller has been connected/added
  128216. */
  128217. onControllerAddedObservable: Observable<WebXRInputSource>;
  128218. /**
  128219. * Event when a controller has been removed/disconnected
  128220. */
  128221. onControllerRemovedObservable: Observable<WebXRInputSource>;
  128222. /**
  128223. * Initializes the WebXRInput
  128224. * @param xrSessionManager the xr session manager for this session
  128225. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  128226. * @param options = initialization options for this xr input
  128227. */
  128228. constructor(
  128229. /**
  128230. * the xr session manager for this session
  128231. */
  128232. xrSessionManager: WebXRSessionManager,
  128233. /**
  128234. * the WebXR camera for this session. Mainly used for teleportation
  128235. */
  128236. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  128237. private _onInputSourcesChange;
  128238. private _addAndRemoveControllers;
  128239. /**
  128240. * Disposes of the object
  128241. */
  128242. dispose(): void;
  128243. }
  128244. }
  128245. declare module BABYLON {
  128246. /**
  128247. * This is the base class for all WebXR features.
  128248. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  128249. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  128250. */
  128251. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  128252. protected _xrSessionManager: WebXRSessionManager;
  128253. private _attached;
  128254. private _removeOnDetach;
  128255. /**
  128256. * Should auto-attach be disabled?
  128257. */
  128258. disableAutoAttach: boolean;
  128259. /**
  128260. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  128261. */
  128262. xrNativeFeatureName: string;
  128263. /**
  128264. * Construct a new (abstract) WebXR feature
  128265. * @param _xrSessionManager the xr session manager for this feature
  128266. */
  128267. constructor(_xrSessionManager: WebXRSessionManager);
  128268. /**
  128269. * Is this feature attached
  128270. */
  128271. get attached(): boolean;
  128272. /**
  128273. * attach this feature
  128274. *
  128275. * @param force should attachment be forced (even when already attached)
  128276. * @returns true if successful, false is failed or already attached
  128277. */
  128278. attach(force?: boolean): boolean;
  128279. /**
  128280. * detach this feature.
  128281. *
  128282. * @returns true if successful, false if failed or already detached
  128283. */
  128284. detach(): boolean;
  128285. /**
  128286. * Dispose this feature and all of the resources attached
  128287. */
  128288. dispose(): void;
  128289. /**
  128290. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  128291. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  128292. *
  128293. * @returns whether or not the feature is compatible in this environment
  128294. */
  128295. isCompatible(): boolean;
  128296. /**
  128297. * This is used to register callbacks that will automatically be removed when detach is called.
  128298. * @param observable the observable to which the observer will be attached
  128299. * @param callback the callback to register
  128300. */
  128301. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  128302. /**
  128303. * Code in this function will be executed on each xrFrame received from the browser.
  128304. * This function will not execute after the feature is detached.
  128305. * @param _xrFrame the current frame
  128306. */
  128307. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  128308. }
  128309. }
  128310. declare module BABYLON {
  128311. /**
  128312. * Renders a layer on top of an existing scene
  128313. */
  128314. export class UtilityLayerRenderer implements IDisposable {
  128315. /** the original scene that will be rendered on top of */
  128316. originalScene: Scene;
  128317. private _pointerCaptures;
  128318. private _lastPointerEvents;
  128319. private static _DefaultUtilityLayer;
  128320. private static _DefaultKeepDepthUtilityLayer;
  128321. private _sharedGizmoLight;
  128322. private _renderCamera;
  128323. /**
  128324. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  128325. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  128326. * @returns the camera that is used when rendering the utility layer
  128327. */
  128328. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  128329. /**
  128330. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  128331. * @param cam the camera that should be used when rendering the utility layer
  128332. */
  128333. setRenderCamera(cam: Nullable<Camera>): void;
  128334. /**
  128335. * @hidden
  128336. * Light which used by gizmos to get light shading
  128337. */
  128338. _getSharedGizmoLight(): HemisphericLight;
  128339. /**
  128340. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  128341. */
  128342. pickUtilitySceneFirst: boolean;
  128343. /**
  128344. * 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)
  128345. */
  128346. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  128347. /**
  128348. * 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)
  128349. */
  128350. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  128351. /**
  128352. * The scene that is rendered on top of the original scene
  128353. */
  128354. utilityLayerScene: Scene;
  128355. /**
  128356. * If the utility layer should automatically be rendered on top of existing scene
  128357. */
  128358. shouldRender: boolean;
  128359. /**
  128360. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  128361. */
  128362. onlyCheckPointerDownEvents: boolean;
  128363. /**
  128364. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  128365. */
  128366. processAllEvents: boolean;
  128367. /**
  128368. * Observable raised when the pointer move from the utility layer scene to the main scene
  128369. */
  128370. onPointerOutObservable: Observable<number>;
  128371. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  128372. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  128373. private _afterRenderObserver;
  128374. private _sceneDisposeObserver;
  128375. private _originalPointerObserver;
  128376. /**
  128377. * Instantiates a UtilityLayerRenderer
  128378. * @param originalScene the original scene that will be rendered on top of
  128379. * @param handleEvents boolean indicating if the utility layer should handle events
  128380. */
  128381. constructor(
  128382. /** the original scene that will be rendered on top of */
  128383. originalScene: Scene, handleEvents?: boolean);
  128384. private _notifyObservers;
  128385. /**
  128386. * Renders the utility layers scene on top of the original scene
  128387. */
  128388. render(): void;
  128389. /**
  128390. * Disposes of the renderer
  128391. */
  128392. dispose(): void;
  128393. private _updateCamera;
  128394. }
  128395. }
  128396. declare module BABYLON {
  128397. /**
  128398. * Options interface for the pointer selection module
  128399. */
  128400. export interface IWebXRControllerPointerSelectionOptions {
  128401. /**
  128402. * if provided, this scene will be used to render meshes.
  128403. */
  128404. customUtilityLayerScene?: Scene;
  128405. /**
  128406. * 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)
  128407. * If not disabled, the last picked point will be used to execute a pointer up event
  128408. * If disabled, pointer up event will be triggered right after the pointer down event.
  128409. * Used in screen and gaze target ray mode only
  128410. */
  128411. disablePointerUpOnTouchOut: boolean;
  128412. /**
  128413. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  128414. */
  128415. forceGazeMode: boolean;
  128416. /**
  128417. * 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
  128418. * to start a new countdown to the pointer down event.
  128419. * Defaults to 1.
  128420. */
  128421. gazeModePointerMovedFactor?: number;
  128422. /**
  128423. * Different button type to use instead of the main component
  128424. */
  128425. overrideButtonId?: string;
  128426. /**
  128427. * use this rendering group id for the meshes (optional)
  128428. */
  128429. renderingGroupId?: number;
  128430. /**
  128431. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  128432. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  128433. * 3000 means 3 seconds between pointing at something and selecting it
  128434. */
  128435. timeToSelect?: number;
  128436. /**
  128437. * Should meshes created here be added to a utility layer or the main scene
  128438. */
  128439. useUtilityLayer?: boolean;
  128440. /**
  128441. * Optional WebXR camera to be used for gaze selection
  128442. */
  128443. gazeCamera?: WebXRCamera;
  128444. /**
  128445. * the xr input to use with this pointer selection
  128446. */
  128447. xrInput: WebXRInput;
  128448. }
  128449. /**
  128450. * A module that will enable pointer selection for motion controllers of XR Input Sources
  128451. */
  128452. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  128453. private readonly _options;
  128454. private static _idCounter;
  128455. private _attachController;
  128456. private _controllers;
  128457. private _scene;
  128458. private _tmpVectorForPickCompare;
  128459. /**
  128460. * The module's name
  128461. */
  128462. static readonly Name: string;
  128463. /**
  128464. * The (Babylon) version of this module.
  128465. * This is an integer representing the implementation version.
  128466. * This number does not correspond to the WebXR specs version
  128467. */
  128468. static readonly Version: number;
  128469. /**
  128470. * Disable lighting on the laser pointer (so it will always be visible)
  128471. */
  128472. disablePointerLighting: boolean;
  128473. /**
  128474. * Disable lighting on the selection mesh (so it will always be visible)
  128475. */
  128476. disableSelectionMeshLighting: boolean;
  128477. /**
  128478. * Should the laser pointer be displayed
  128479. */
  128480. displayLaserPointer: boolean;
  128481. /**
  128482. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  128483. */
  128484. displaySelectionMesh: boolean;
  128485. /**
  128486. * This color will be set to the laser pointer when selection is triggered
  128487. */
  128488. laserPointerPickedColor: Color3;
  128489. /**
  128490. * Default color of the laser pointer
  128491. */
  128492. laserPointerDefaultColor: Color3;
  128493. /**
  128494. * default color of the selection ring
  128495. */
  128496. selectionMeshDefaultColor: Color3;
  128497. /**
  128498. * This color will be applied to the selection ring when selection is triggered
  128499. */
  128500. selectionMeshPickedColor: Color3;
  128501. /**
  128502. * Optional filter to be used for ray selection. This predicate shares behavior with
  128503. * scene.pointerMovePredicate which takes priority if it is also assigned.
  128504. */
  128505. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  128506. /**
  128507. * constructs a new background remover module
  128508. * @param _xrSessionManager the session manager for this module
  128509. * @param _options read-only options to be used in this module
  128510. */
  128511. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  128512. /**
  128513. * attach this feature
  128514. * Will usually be called by the features manager
  128515. *
  128516. * @returns true if successful.
  128517. */
  128518. attach(): boolean;
  128519. /**
  128520. * detach this feature.
  128521. * Will usually be called by the features manager
  128522. *
  128523. * @returns true if successful.
  128524. */
  128525. detach(): boolean;
  128526. /**
  128527. * Will get the mesh under a specific pointer.
  128528. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  128529. * @param controllerId the controllerId to check
  128530. * @returns The mesh under pointer or null if no mesh is under the pointer
  128531. */
  128532. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  128533. /**
  128534. * Get the xr controller that correlates to the pointer id in the pointer event
  128535. *
  128536. * @param id the pointer id to search for
  128537. * @returns the controller that correlates to this id or null if not found
  128538. */
  128539. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  128540. protected _onXRFrame(_xrFrame: XRFrame): void;
  128541. private _attachGazeMode;
  128542. private _attachScreenRayMode;
  128543. private _attachTrackedPointerRayMode;
  128544. private _convertNormalToDirectionOfRay;
  128545. private _detachController;
  128546. private _generateNewMeshPair;
  128547. private _pickingMoved;
  128548. private _updatePointerDistance;
  128549. /** @hidden */
  128550. get lasterPointerDefaultColor(): Color3;
  128551. }
  128552. }
  128553. declare module BABYLON {
  128554. /**
  128555. * Button which can be used to enter a different mode of XR
  128556. */
  128557. export class WebXREnterExitUIButton {
  128558. /** button element */
  128559. element: HTMLElement;
  128560. /** XR initialization options for the button */
  128561. sessionMode: XRSessionMode;
  128562. /** Reference space type */
  128563. referenceSpaceType: XRReferenceSpaceType;
  128564. /**
  128565. * Creates a WebXREnterExitUIButton
  128566. * @param element button element
  128567. * @param sessionMode XR initialization session mode
  128568. * @param referenceSpaceType the type of reference space to be used
  128569. */
  128570. constructor(
  128571. /** button element */
  128572. element: HTMLElement,
  128573. /** XR initialization options for the button */
  128574. sessionMode: XRSessionMode,
  128575. /** Reference space type */
  128576. referenceSpaceType: XRReferenceSpaceType);
  128577. /**
  128578. * Extendable function which can be used to update the button's visuals when the state changes
  128579. * @param activeButton the current active button in the UI
  128580. */
  128581. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  128582. }
  128583. /**
  128584. * Options to create the webXR UI
  128585. */
  128586. export class WebXREnterExitUIOptions {
  128587. /**
  128588. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  128589. */
  128590. customButtons?: Array<WebXREnterExitUIButton>;
  128591. /**
  128592. * A reference space type to use when creating the default button.
  128593. * Default is local-floor
  128594. */
  128595. referenceSpaceType?: XRReferenceSpaceType;
  128596. /**
  128597. * Context to enter xr with
  128598. */
  128599. renderTarget?: Nullable<WebXRRenderTarget>;
  128600. /**
  128601. * A session mode to use when creating the default button.
  128602. * Default is immersive-vr
  128603. */
  128604. sessionMode?: XRSessionMode;
  128605. /**
  128606. * A list of optional features to init the session with
  128607. */
  128608. optionalFeatures?: string[];
  128609. /**
  128610. * A list of optional features to init the session with
  128611. */
  128612. requiredFeatures?: string[];
  128613. }
  128614. /**
  128615. * UI to allow the user to enter/exit XR mode
  128616. */
  128617. export class WebXREnterExitUI implements IDisposable {
  128618. private scene;
  128619. /** version of the options passed to this UI */
  128620. options: WebXREnterExitUIOptions;
  128621. private _activeButton;
  128622. private _buttons;
  128623. /**
  128624. * The HTML Div Element to which buttons are added.
  128625. */
  128626. readonly overlay: HTMLDivElement;
  128627. /**
  128628. * Fired every time the active button is changed.
  128629. *
  128630. * When xr is entered via a button that launches xr that button will be the callback parameter
  128631. *
  128632. * When exiting xr the callback parameter will be null)
  128633. */
  128634. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  128635. /**
  128636. *
  128637. * @param scene babylon scene object to use
  128638. * @param options (read-only) version of the options passed to this UI
  128639. */
  128640. private constructor();
  128641. /**
  128642. * Creates UI to allow the user to enter/exit XR mode
  128643. * @param scene the scene to add the ui to
  128644. * @param helper the xr experience helper to enter/exit xr with
  128645. * @param options options to configure the UI
  128646. * @returns the created ui
  128647. */
  128648. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  128649. /**
  128650. * Disposes of the XR UI component
  128651. */
  128652. dispose(): void;
  128653. private _updateButtons;
  128654. }
  128655. }
  128656. declare module BABYLON {
  128657. /**
  128658. * Class containing static functions to help procedurally build meshes
  128659. */
  128660. export class LinesBuilder {
  128661. /**
  128662. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  128663. * * 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
  128664. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  128665. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  128666. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  128667. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  128668. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  128669. * * 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
  128670. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  128671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128672. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  128673. * @param name defines the name of the new line system
  128674. * @param options defines the options used to create the line system
  128675. * @param scene defines the hosting scene
  128676. * @returns a new line system mesh
  128677. */
  128678. static CreateLineSystem(name: string, options: {
  128679. lines: Vector3[][];
  128680. updatable?: boolean;
  128681. instance?: Nullable<LinesMesh>;
  128682. colors?: Nullable<Color4[][]>;
  128683. useVertexAlpha?: boolean;
  128684. }, scene: Nullable<Scene>): LinesMesh;
  128685. /**
  128686. * Creates a line mesh
  128687. * 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
  128688. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  128689. * * The parameter `points` is an array successive Vector3
  128690. * * 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
  128691. * * The optional parameter `colors` is an array of successive Color4, one per line point
  128692. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  128693. * * When updating an instance, remember that only point positions can change, not the number of points
  128694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128695. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  128696. * @param name defines the name of the new line system
  128697. * @param options defines the options used to create the line system
  128698. * @param scene defines the hosting scene
  128699. * @returns a new line mesh
  128700. */
  128701. static CreateLines(name: string, options: {
  128702. points: Vector3[];
  128703. updatable?: boolean;
  128704. instance?: Nullable<LinesMesh>;
  128705. colors?: Color4[];
  128706. useVertexAlpha?: boolean;
  128707. }, scene?: Nullable<Scene>): LinesMesh;
  128708. /**
  128709. * Creates a dashed line mesh
  128710. * * 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
  128711. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  128712. * * The parameter `points` is an array successive Vector3
  128713. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  128714. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  128715. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  128716. * * 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
  128717. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  128718. * * When updating an instance, remember that only point positions can change, not the number of points
  128719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128720. * @param name defines the name of the mesh
  128721. * @param options defines the options used to create the mesh
  128722. * @param scene defines the hosting scene
  128723. * @returns the dashed line mesh
  128724. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  128725. */
  128726. static CreateDashedLines(name: string, options: {
  128727. points: Vector3[];
  128728. dashSize?: number;
  128729. gapSize?: number;
  128730. dashNb?: number;
  128731. updatable?: boolean;
  128732. instance?: LinesMesh;
  128733. useVertexAlpha?: boolean;
  128734. }, scene?: Nullable<Scene>): LinesMesh;
  128735. }
  128736. }
  128737. declare module BABYLON {
  128738. /**
  128739. * Construction options for a timer
  128740. */
  128741. export interface ITimerOptions<T> {
  128742. /**
  128743. * Time-to-end
  128744. */
  128745. timeout: number;
  128746. /**
  128747. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  128748. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  128749. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  128750. */
  128751. contextObservable: Observable<T>;
  128752. /**
  128753. * Optional parameters when adding an observer to the observable
  128754. */
  128755. observableParameters?: {
  128756. mask?: number;
  128757. insertFirst?: boolean;
  128758. scope?: any;
  128759. };
  128760. /**
  128761. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  128762. */
  128763. breakCondition?: (data?: ITimerData<T>) => boolean;
  128764. /**
  128765. * Will be triggered when the time condition has met
  128766. */
  128767. onEnded?: (data: ITimerData<any>) => void;
  128768. /**
  128769. * Will be triggered when the break condition has met (prematurely ended)
  128770. */
  128771. onAborted?: (data: ITimerData<any>) => void;
  128772. /**
  128773. * Optional function to execute on each tick (or count)
  128774. */
  128775. onTick?: (data: ITimerData<any>) => void;
  128776. }
  128777. /**
  128778. * An interface defining the data sent by the timer
  128779. */
  128780. export interface ITimerData<T> {
  128781. /**
  128782. * When did it start
  128783. */
  128784. startTime: number;
  128785. /**
  128786. * Time now
  128787. */
  128788. currentTime: number;
  128789. /**
  128790. * Time passed since started
  128791. */
  128792. deltaTime: number;
  128793. /**
  128794. * How much is completed, in [0.0...1.0].
  128795. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  128796. */
  128797. completeRate: number;
  128798. /**
  128799. * What the registered observable sent in the last count
  128800. */
  128801. payload: T;
  128802. }
  128803. /**
  128804. * The current state of the timer
  128805. */
  128806. export enum TimerState {
  128807. /**
  128808. * Timer initialized, not yet started
  128809. */
  128810. INIT = 0,
  128811. /**
  128812. * Timer started and counting
  128813. */
  128814. STARTED = 1,
  128815. /**
  128816. * Timer ended (whether aborted or time reached)
  128817. */
  128818. ENDED = 2
  128819. }
  128820. /**
  128821. * A simple version of the timer. Will take options and start the timer immediately after calling it
  128822. *
  128823. * @param options options with which to initialize this timer
  128824. */
  128825. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  128826. /**
  128827. * An advanced implementation of a timer class
  128828. */
  128829. export class AdvancedTimer<T = any> implements IDisposable {
  128830. /**
  128831. * Will notify each time the timer calculates the remaining time
  128832. */
  128833. onEachCountObservable: Observable<ITimerData<T>>;
  128834. /**
  128835. * Will trigger when the timer was aborted due to the break condition
  128836. */
  128837. onTimerAbortedObservable: Observable<ITimerData<T>>;
  128838. /**
  128839. * Will trigger when the timer ended successfully
  128840. */
  128841. onTimerEndedObservable: Observable<ITimerData<T>>;
  128842. /**
  128843. * Will trigger when the timer state has changed
  128844. */
  128845. onStateChangedObservable: Observable<TimerState>;
  128846. private _observer;
  128847. private _contextObservable;
  128848. private _observableParameters;
  128849. private _startTime;
  128850. private _timer;
  128851. private _state;
  128852. private _breakCondition;
  128853. private _timeToEnd;
  128854. private _breakOnNextTick;
  128855. /**
  128856. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  128857. * @param options construction options for this advanced timer
  128858. */
  128859. constructor(options: ITimerOptions<T>);
  128860. /**
  128861. * set a breaking condition for this timer. Default is to never break during count
  128862. * @param predicate the new break condition. Returns true to break, false otherwise
  128863. */
  128864. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  128865. /**
  128866. * Reset ALL associated observables in this advanced timer
  128867. */
  128868. clearObservables(): void;
  128869. /**
  128870. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  128871. *
  128872. * @param timeToEnd how much time to measure until timer ended
  128873. */
  128874. start(timeToEnd?: number): void;
  128875. /**
  128876. * Will force a stop on the next tick.
  128877. */
  128878. stop(): void;
  128879. /**
  128880. * Dispose this timer, clearing all resources
  128881. */
  128882. dispose(): void;
  128883. private _setState;
  128884. private _tick;
  128885. private _stop;
  128886. }
  128887. }
  128888. declare module BABYLON {
  128889. /**
  128890. * The options container for the teleportation module
  128891. */
  128892. export interface IWebXRTeleportationOptions {
  128893. /**
  128894. * if provided, this scene will be used to render meshes.
  128895. */
  128896. customUtilityLayerScene?: Scene;
  128897. /**
  128898. * Values to configure the default target mesh
  128899. */
  128900. defaultTargetMeshOptions?: {
  128901. /**
  128902. * Fill color of the teleportation area
  128903. */
  128904. teleportationFillColor?: string;
  128905. /**
  128906. * Border color for the teleportation area
  128907. */
  128908. teleportationBorderColor?: string;
  128909. /**
  128910. * Disable the mesh's animation sequence
  128911. */
  128912. disableAnimation?: boolean;
  128913. /**
  128914. * Disable lighting on the material or the ring and arrow
  128915. */
  128916. disableLighting?: boolean;
  128917. /**
  128918. * Override the default material of the torus and arrow
  128919. */
  128920. torusArrowMaterial?: Material;
  128921. };
  128922. /**
  128923. * A list of meshes to use as floor meshes.
  128924. * Meshes can be added and removed after initializing the feature using the
  128925. * addFloorMesh and removeFloorMesh functions
  128926. * If empty, rotation will still work
  128927. */
  128928. floorMeshes?: AbstractMesh[];
  128929. /**
  128930. * use this rendering group id for the meshes (optional)
  128931. */
  128932. renderingGroupId?: number;
  128933. /**
  128934. * Should teleportation move only to snap points
  128935. */
  128936. snapPointsOnly?: boolean;
  128937. /**
  128938. * An array of points to which the teleportation will snap to.
  128939. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  128940. */
  128941. snapPositions?: Vector3[];
  128942. /**
  128943. * How close should the teleportation ray be in order to snap to position.
  128944. * Default to 0.8 units (meters)
  128945. */
  128946. snapToPositionRadius?: number;
  128947. /**
  128948. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  128949. * If you want to support rotation, make sure your mesh has a direction indicator.
  128950. *
  128951. * When left untouched, the default mesh will be initialized.
  128952. */
  128953. teleportationTargetMesh?: AbstractMesh;
  128954. /**
  128955. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  128956. */
  128957. timeToTeleport?: number;
  128958. /**
  128959. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  128960. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  128961. */
  128962. useMainComponentOnly?: boolean;
  128963. /**
  128964. * Should meshes created here be added to a utility layer or the main scene
  128965. */
  128966. useUtilityLayer?: boolean;
  128967. /**
  128968. * Babylon XR Input class for controller
  128969. */
  128970. xrInput: WebXRInput;
  128971. }
  128972. /**
  128973. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  128974. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  128975. * the input of the attached controllers.
  128976. */
  128977. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  128978. private _options;
  128979. private _controllers;
  128980. private _currentTeleportationControllerId;
  128981. private _floorMeshes;
  128982. private _quadraticBezierCurve;
  128983. private _selectionFeature;
  128984. private _snapToPositions;
  128985. private _snappedToPoint;
  128986. private _teleportationRingMaterial?;
  128987. private _tmpRay;
  128988. private _tmpVector;
  128989. /**
  128990. * The module's name
  128991. */
  128992. static readonly Name: string;
  128993. /**
  128994. * The (Babylon) version of this module.
  128995. * This is an integer representing the implementation version.
  128996. * This number does not correspond to the webxr specs version
  128997. */
  128998. static readonly Version: number;
  128999. /**
  129000. * Is movement backwards enabled
  129001. */
  129002. backwardsMovementEnabled: boolean;
  129003. /**
  129004. * Distance to travel when moving backwards
  129005. */
  129006. backwardsTeleportationDistance: number;
  129007. /**
  129008. * The distance from the user to the inspection point in the direction of the controller
  129009. * A higher number will allow the user to move further
  129010. * defaults to 5 (meters, in xr units)
  129011. */
  129012. parabolicCheckRadius: number;
  129013. /**
  129014. * Should the module support parabolic ray on top of direct ray
  129015. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  129016. * Very helpful when moving between floors / different heights
  129017. */
  129018. parabolicRayEnabled: boolean;
  129019. /**
  129020. * How much rotation should be applied when rotating right and left
  129021. */
  129022. rotationAngle: number;
  129023. /**
  129024. * Is rotation enabled when moving forward?
  129025. * Disabling this feature will prevent the user from deciding the direction when teleporting
  129026. */
  129027. rotationEnabled: boolean;
  129028. /**
  129029. * constructs a new anchor system
  129030. * @param _xrSessionManager an instance of WebXRSessionManager
  129031. * @param _options configuration object for this feature
  129032. */
  129033. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  129034. /**
  129035. * Get the snapPointsOnly flag
  129036. */
  129037. get snapPointsOnly(): boolean;
  129038. /**
  129039. * Sets the snapPointsOnly flag
  129040. * @param snapToPoints should teleportation be exclusively to snap points
  129041. */
  129042. set snapPointsOnly(snapToPoints: boolean);
  129043. /**
  129044. * Add a new mesh to the floor meshes array
  129045. * @param mesh the mesh to use as floor mesh
  129046. */
  129047. addFloorMesh(mesh: AbstractMesh): void;
  129048. /**
  129049. * Add a new snap-to point to fix teleportation to this position
  129050. * @param newSnapPoint The new Snap-To point
  129051. */
  129052. addSnapPoint(newSnapPoint: Vector3): void;
  129053. attach(): boolean;
  129054. detach(): boolean;
  129055. dispose(): void;
  129056. /**
  129057. * Remove a mesh from the floor meshes array
  129058. * @param mesh the mesh to remove
  129059. */
  129060. removeFloorMesh(mesh: AbstractMesh): void;
  129061. /**
  129062. * Remove a mesh from the floor meshes array using its name
  129063. * @param name the mesh name to remove
  129064. */
  129065. removeFloorMeshByName(name: string): void;
  129066. /**
  129067. * 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
  129068. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  129069. * @returns was the point found and removed or not
  129070. */
  129071. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  129072. /**
  129073. * This function sets a selection feature that will be disabled when
  129074. * the forward ray is shown and will be reattached when hidden.
  129075. * This is used to remove the selection rays when moving.
  129076. * @param selectionFeature the feature to disable when forward movement is enabled
  129077. */
  129078. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  129079. protected _onXRFrame(_xrFrame: XRFrame): void;
  129080. private _attachController;
  129081. private _createDefaultTargetMesh;
  129082. private _detachController;
  129083. private _findClosestSnapPointWithRadius;
  129084. private _setTargetMeshPosition;
  129085. private _setTargetMeshVisibility;
  129086. private _showParabolicPath;
  129087. private _teleportForward;
  129088. }
  129089. }
  129090. declare module BABYLON {
  129091. /**
  129092. * Options for the default xr helper
  129093. */
  129094. export class WebXRDefaultExperienceOptions {
  129095. /**
  129096. * Enable or disable default UI to enter XR
  129097. */
  129098. disableDefaultUI?: boolean;
  129099. /**
  129100. * Should teleportation not initialize. defaults to false.
  129101. */
  129102. disableTeleportation?: boolean;
  129103. /**
  129104. * Floor meshes that will be used for teleport
  129105. */
  129106. floorMeshes?: Array<AbstractMesh>;
  129107. /**
  129108. * If set to true, the first frame will not be used to reset position
  129109. * The first frame is mainly used when copying transformation from the old camera
  129110. * Mainly used in AR
  129111. */
  129112. ignoreNativeCameraTransformation?: boolean;
  129113. /**
  129114. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  129115. */
  129116. inputOptions?: IWebXRInputOptions;
  129117. /**
  129118. * optional configuration for the output canvas
  129119. */
  129120. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  129121. /**
  129122. * optional UI options. This can be used among other to change session mode and reference space type
  129123. */
  129124. uiOptions?: WebXREnterExitUIOptions;
  129125. /**
  129126. * When loading teleportation and pointer select, use stable versions instead of latest.
  129127. */
  129128. useStablePlugins?: boolean;
  129129. /**
  129130. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  129131. */
  129132. renderingGroupId?: number;
  129133. /**
  129134. * A list of optional features to init the session with
  129135. * If set to true, all features we support will be added
  129136. */
  129137. optionalFeatures?: boolean | string[];
  129138. }
  129139. /**
  129140. * Default experience which provides a similar setup to the previous webVRExperience
  129141. */
  129142. export class WebXRDefaultExperience {
  129143. /**
  129144. * Base experience
  129145. */
  129146. baseExperience: WebXRExperienceHelper;
  129147. /**
  129148. * Enables ui for entering/exiting xr
  129149. */
  129150. enterExitUI: WebXREnterExitUI;
  129151. /**
  129152. * Input experience extension
  129153. */
  129154. input: WebXRInput;
  129155. /**
  129156. * Enables laser pointer and selection
  129157. */
  129158. pointerSelection: WebXRControllerPointerSelection;
  129159. /**
  129160. * Default target xr should render to
  129161. */
  129162. renderTarget: WebXRRenderTarget;
  129163. /**
  129164. * Enables teleportation
  129165. */
  129166. teleportation: WebXRMotionControllerTeleportation;
  129167. private constructor();
  129168. /**
  129169. * Creates the default xr experience
  129170. * @param scene scene
  129171. * @param options options for basic configuration
  129172. * @returns resulting WebXRDefaultExperience
  129173. */
  129174. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  129175. /**
  129176. * DIsposes of the experience helper
  129177. */
  129178. dispose(): void;
  129179. }
  129180. }
  129181. declare module BABYLON {
  129182. /**
  129183. * Options to modify the vr teleportation behavior.
  129184. */
  129185. export interface VRTeleportationOptions {
  129186. /**
  129187. * The name of the mesh which should be used as the teleportation floor. (default: null)
  129188. */
  129189. floorMeshName?: string;
  129190. /**
  129191. * A list of meshes to be used as the teleportation floor. (default: empty)
  129192. */
  129193. floorMeshes?: Mesh[];
  129194. /**
  129195. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  129196. */
  129197. teleportationMode?: number;
  129198. /**
  129199. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  129200. */
  129201. teleportationTime?: number;
  129202. /**
  129203. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  129204. */
  129205. teleportationSpeed?: number;
  129206. /**
  129207. * The easing function used in the animation or null for Linear. (default CircleEase)
  129208. */
  129209. easingFunction?: EasingFunction;
  129210. }
  129211. /**
  129212. * Options to modify the vr experience helper's behavior.
  129213. */
  129214. export interface VRExperienceHelperOptions extends WebVROptions {
  129215. /**
  129216. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  129217. */
  129218. createDeviceOrientationCamera?: boolean;
  129219. /**
  129220. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  129221. */
  129222. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  129223. /**
  129224. * Uses the main button on the controller to toggle the laser casted. (default: true)
  129225. */
  129226. laserToggle?: boolean;
  129227. /**
  129228. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  129229. */
  129230. floorMeshes?: Mesh[];
  129231. /**
  129232. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  129233. */
  129234. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  129235. /**
  129236. * Defines if WebXR should be used instead of WebVR (if available)
  129237. */
  129238. useXR?: boolean;
  129239. }
  129240. /**
  129241. * Event containing information after VR has been entered
  129242. */
  129243. export class OnAfterEnteringVRObservableEvent {
  129244. /**
  129245. * If entering vr was successful
  129246. */
  129247. success: boolean;
  129248. }
  129249. /**
  129250. * Helps to quickly add VR support to an existing scene.
  129251. * See https://doc.babylonjs.com/how_to/webvr_helper
  129252. */
  129253. export class VRExperienceHelper {
  129254. /** Options to modify the vr experience helper's behavior. */
  129255. webVROptions: VRExperienceHelperOptions;
  129256. private _scene;
  129257. private _position;
  129258. private _btnVR;
  129259. private _btnVRDisplayed;
  129260. private _webVRsupported;
  129261. private _webVRready;
  129262. private _webVRrequesting;
  129263. private _webVRpresenting;
  129264. private _hasEnteredVR;
  129265. private _fullscreenVRpresenting;
  129266. private _inputElement;
  129267. private _webVRCamera;
  129268. private _vrDeviceOrientationCamera;
  129269. private _deviceOrientationCamera;
  129270. private _existingCamera;
  129271. private _onKeyDown;
  129272. private _onVrDisplayPresentChange;
  129273. private _onVRDisplayChanged;
  129274. private _onVRRequestPresentStart;
  129275. private _onVRRequestPresentComplete;
  129276. /**
  129277. * 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)
  129278. */
  129279. enableGazeEvenWhenNoPointerLock: boolean;
  129280. /**
  129281. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  129282. */
  129283. exitVROnDoubleTap: boolean;
  129284. /**
  129285. * Observable raised right before entering VR.
  129286. */
  129287. onEnteringVRObservable: Observable<VRExperienceHelper>;
  129288. /**
  129289. * Observable raised when entering VR has completed.
  129290. */
  129291. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  129292. /**
  129293. * Observable raised when exiting VR.
  129294. */
  129295. onExitingVRObservable: Observable<VRExperienceHelper>;
  129296. /**
  129297. * Observable raised when controller mesh is loaded.
  129298. */
  129299. onControllerMeshLoadedObservable: Observable<WebVRController>;
  129300. /** Return this.onEnteringVRObservable
  129301. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  129302. */
  129303. get onEnteringVR(): Observable<VRExperienceHelper>;
  129304. /** Return this.onExitingVRObservable
  129305. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  129306. */
  129307. get onExitingVR(): Observable<VRExperienceHelper>;
  129308. /** Return this.onControllerMeshLoadedObservable
  129309. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  129310. */
  129311. get onControllerMeshLoaded(): Observable<WebVRController>;
  129312. private _rayLength;
  129313. private _useCustomVRButton;
  129314. private _teleportationRequested;
  129315. private _teleportActive;
  129316. private _floorMeshName;
  129317. private _floorMeshesCollection;
  129318. private _teleportationMode;
  129319. private _teleportationTime;
  129320. private _teleportationSpeed;
  129321. private _teleportationEasing;
  129322. private _rotationAllowed;
  129323. private _teleportBackwardsVector;
  129324. private _teleportationTarget;
  129325. private _isDefaultTeleportationTarget;
  129326. private _postProcessMove;
  129327. private _teleportationFillColor;
  129328. private _teleportationBorderColor;
  129329. private _rotationAngle;
  129330. private _haloCenter;
  129331. private _cameraGazer;
  129332. private _padSensibilityUp;
  129333. private _padSensibilityDown;
  129334. private _leftController;
  129335. private _rightController;
  129336. private _gazeColor;
  129337. private _laserColor;
  129338. private _pickedLaserColor;
  129339. private _pickedGazeColor;
  129340. /**
  129341. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  129342. */
  129343. onNewMeshSelected: Observable<AbstractMesh>;
  129344. /**
  129345. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  129346. * This observable will provide the mesh and the controller used to select the mesh
  129347. */
  129348. onMeshSelectedWithController: Observable<{
  129349. mesh: AbstractMesh;
  129350. controller: WebVRController;
  129351. }>;
  129352. /**
  129353. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  129354. */
  129355. onNewMeshPicked: Observable<PickingInfo>;
  129356. private _circleEase;
  129357. /**
  129358. * Observable raised before camera teleportation
  129359. */
  129360. onBeforeCameraTeleport: Observable<Vector3>;
  129361. /**
  129362. * Observable raised after camera teleportation
  129363. */
  129364. onAfterCameraTeleport: Observable<Vector3>;
  129365. /**
  129366. * Observable raised when current selected mesh gets unselected
  129367. */
  129368. onSelectedMeshUnselected: Observable<AbstractMesh>;
  129369. private _raySelectionPredicate;
  129370. /**
  129371. * To be optionaly changed by user to define custom ray selection
  129372. */
  129373. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129374. /**
  129375. * To be optionaly changed by user to define custom selection logic (after ray selection)
  129376. */
  129377. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  129378. /**
  129379. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  129380. */
  129381. teleportationEnabled: boolean;
  129382. private _defaultHeight;
  129383. private _teleportationInitialized;
  129384. private _interactionsEnabled;
  129385. private _interactionsRequested;
  129386. private _displayGaze;
  129387. private _displayLaserPointer;
  129388. /**
  129389. * The mesh used to display where the user is going to teleport.
  129390. */
  129391. get teleportationTarget(): Mesh;
  129392. /**
  129393. * Sets the mesh to be used to display where the user is going to teleport.
  129394. */
  129395. set teleportationTarget(value: Mesh);
  129396. /**
  129397. * 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
  129398. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  129399. * See https://doc.babylonjs.com/resources/baking_transformations
  129400. */
  129401. get gazeTrackerMesh(): Mesh;
  129402. set gazeTrackerMesh(value: Mesh);
  129403. /**
  129404. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  129405. */
  129406. updateGazeTrackerScale: boolean;
  129407. /**
  129408. * If the gaze trackers color should be updated when selecting meshes
  129409. */
  129410. updateGazeTrackerColor: boolean;
  129411. /**
  129412. * If the controller laser color should be updated when selecting meshes
  129413. */
  129414. updateControllerLaserColor: boolean;
  129415. /**
  129416. * The gaze tracking mesh corresponding to the left controller
  129417. */
  129418. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  129419. /**
  129420. * The gaze tracking mesh corresponding to the right controller
  129421. */
  129422. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  129423. /**
  129424. * If the ray of the gaze should be displayed.
  129425. */
  129426. get displayGaze(): boolean;
  129427. /**
  129428. * Sets if the ray of the gaze should be displayed.
  129429. */
  129430. set displayGaze(value: boolean);
  129431. /**
  129432. * If the ray of the LaserPointer should be displayed.
  129433. */
  129434. get displayLaserPointer(): boolean;
  129435. /**
  129436. * Sets if the ray of the LaserPointer should be displayed.
  129437. */
  129438. set displayLaserPointer(value: boolean);
  129439. /**
  129440. * The deviceOrientationCamera used as the camera when not in VR.
  129441. */
  129442. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  129443. /**
  129444. * Based on the current WebVR support, returns the current VR camera used.
  129445. */
  129446. get currentVRCamera(): Nullable<Camera>;
  129447. /**
  129448. * The webVRCamera which is used when in VR.
  129449. */
  129450. get webVRCamera(): WebVRFreeCamera;
  129451. /**
  129452. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  129453. */
  129454. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  129455. /**
  129456. * The html button that is used to trigger entering into VR.
  129457. */
  129458. get vrButton(): Nullable<HTMLButtonElement>;
  129459. private get _teleportationRequestInitiated();
  129460. /**
  129461. * Defines whether or not Pointer lock should be requested when switching to
  129462. * full screen.
  129463. */
  129464. requestPointerLockOnFullScreen: boolean;
  129465. /**
  129466. * If asking to force XR, this will be populated with the default xr experience
  129467. */
  129468. xr: WebXRDefaultExperience;
  129469. /**
  129470. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  129471. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  129472. */
  129473. xrTestDone: boolean;
  129474. /**
  129475. * Instantiates a VRExperienceHelper.
  129476. * Helps to quickly add VR support to an existing scene.
  129477. * @param scene The scene the VRExperienceHelper belongs to.
  129478. * @param webVROptions Options to modify the vr experience helper's behavior.
  129479. */
  129480. constructor(scene: Scene,
  129481. /** Options to modify the vr experience helper's behavior. */
  129482. webVROptions?: VRExperienceHelperOptions);
  129483. private completeVRInit;
  129484. private _onDefaultMeshLoaded;
  129485. private _onResize;
  129486. private _onFullscreenChange;
  129487. /**
  129488. * Gets a value indicating if we are currently in VR mode.
  129489. */
  129490. get isInVRMode(): boolean;
  129491. private onVrDisplayPresentChange;
  129492. private onVRDisplayChanged;
  129493. private moveButtonToBottomRight;
  129494. private displayVRButton;
  129495. private updateButtonVisibility;
  129496. private _cachedAngularSensibility;
  129497. /**
  129498. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  129499. * Otherwise, will use the fullscreen API.
  129500. */
  129501. enterVR(): void;
  129502. /**
  129503. * Attempt to exit VR, or fullscreen.
  129504. */
  129505. exitVR(): void;
  129506. /**
  129507. * The position of the vr experience helper.
  129508. */
  129509. get position(): Vector3;
  129510. /**
  129511. * Sets the position of the vr experience helper.
  129512. */
  129513. set position(value: Vector3);
  129514. /**
  129515. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  129516. */
  129517. enableInteractions(): void;
  129518. private get _noControllerIsActive();
  129519. private beforeRender;
  129520. private _isTeleportationFloor;
  129521. /**
  129522. * Adds a floor mesh to be used for teleportation.
  129523. * @param floorMesh the mesh to be used for teleportation.
  129524. */
  129525. addFloorMesh(floorMesh: Mesh): void;
  129526. /**
  129527. * Removes a floor mesh from being used for teleportation.
  129528. * @param floorMesh the mesh to be removed.
  129529. */
  129530. removeFloorMesh(floorMesh: Mesh): void;
  129531. /**
  129532. * Enables interactions and teleportation using the VR controllers and gaze.
  129533. * @param vrTeleportationOptions options to modify teleportation behavior.
  129534. */
  129535. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  129536. private _onNewGamepadConnected;
  129537. private _tryEnableInteractionOnController;
  129538. private _onNewGamepadDisconnected;
  129539. private _enableInteractionOnController;
  129540. private _checkTeleportWithRay;
  129541. private _checkRotate;
  129542. private _checkTeleportBackwards;
  129543. private _enableTeleportationOnController;
  129544. private _createTeleportationCircles;
  129545. private _displayTeleportationTarget;
  129546. private _hideTeleportationTarget;
  129547. private _rotateCamera;
  129548. private _moveTeleportationSelectorTo;
  129549. private _workingVector;
  129550. private _workingQuaternion;
  129551. private _workingMatrix;
  129552. /**
  129553. * Time Constant Teleportation Mode
  129554. */
  129555. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  129556. /**
  129557. * Speed Constant Teleportation Mode
  129558. */
  129559. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  129560. /**
  129561. * Teleports the users feet to the desired location
  129562. * @param location The location where the user's feet should be placed
  129563. */
  129564. teleportCamera(location: Vector3): void;
  129565. private _convertNormalToDirectionOfRay;
  129566. private _castRayAndSelectObject;
  129567. private _notifySelectedMeshUnselected;
  129568. /**
  129569. * Permanently set new colors for the laser pointer
  129570. * @param color the new laser color
  129571. * @param pickedColor the new laser color when picked mesh detected
  129572. */
  129573. setLaserColor(color: Color3, pickedColor?: Color3): void;
  129574. /**
  129575. * Set lighting enabled / disabled on the laser pointer of both controllers
  129576. * @param enabled should the lighting be enabled on the laser pointer
  129577. */
  129578. setLaserLightingState(enabled?: boolean): void;
  129579. /**
  129580. * Permanently set new colors for the gaze pointer
  129581. * @param color the new gaze color
  129582. * @param pickedColor the new gaze color when picked mesh detected
  129583. */
  129584. setGazeColor(color: Color3, pickedColor?: Color3): void;
  129585. /**
  129586. * Sets the color of the laser ray from the vr controllers.
  129587. * @param color new color for the ray.
  129588. */
  129589. changeLaserColor(color: Color3): void;
  129590. /**
  129591. * Sets the color of the ray from the vr headsets gaze.
  129592. * @param color new color for the ray.
  129593. */
  129594. changeGazeColor(color: Color3): void;
  129595. /**
  129596. * Exits VR and disposes of the vr experience helper
  129597. */
  129598. dispose(): void;
  129599. /**
  129600. * Gets the name of the VRExperienceHelper class
  129601. * @returns "VRExperienceHelper"
  129602. */
  129603. getClassName(): string;
  129604. }
  129605. }
  129606. declare module BABYLON {
  129607. /**
  129608. * Contains an array of blocks representing the octree
  129609. */
  129610. export interface IOctreeContainer<T> {
  129611. /**
  129612. * Blocks within the octree
  129613. */
  129614. blocks: Array<OctreeBlock<T>>;
  129615. }
  129616. /**
  129617. * Class used to store a cell in an octree
  129618. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129619. */
  129620. export class OctreeBlock<T> {
  129621. /**
  129622. * Gets the content of the current block
  129623. */
  129624. entries: T[];
  129625. /**
  129626. * Gets the list of block children
  129627. */
  129628. blocks: Array<OctreeBlock<T>>;
  129629. private _depth;
  129630. private _maxDepth;
  129631. private _capacity;
  129632. private _minPoint;
  129633. private _maxPoint;
  129634. private _boundingVectors;
  129635. private _creationFunc;
  129636. /**
  129637. * Creates a new block
  129638. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  129639. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  129640. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  129641. * @param depth defines the current depth of this block in the octree
  129642. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  129643. * @param creationFunc defines a callback to call when an element is added to the block
  129644. */
  129645. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  129646. /**
  129647. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  129648. */
  129649. get capacity(): number;
  129650. /**
  129651. * Gets the minimum vector (in world space) of the block's bounding box
  129652. */
  129653. get minPoint(): Vector3;
  129654. /**
  129655. * Gets the maximum vector (in world space) of the block's bounding box
  129656. */
  129657. get maxPoint(): Vector3;
  129658. /**
  129659. * Add a new element to this block
  129660. * @param entry defines the element to add
  129661. */
  129662. addEntry(entry: T): void;
  129663. /**
  129664. * Remove an element from this block
  129665. * @param entry defines the element to remove
  129666. */
  129667. removeEntry(entry: T): void;
  129668. /**
  129669. * Add an array of elements to this block
  129670. * @param entries defines the array of elements to add
  129671. */
  129672. addEntries(entries: T[]): void;
  129673. /**
  129674. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  129675. * @param frustumPlanes defines the frustum planes to test
  129676. * @param selection defines the array to store current content if selection is positive
  129677. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129678. */
  129679. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  129680. /**
  129681. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  129682. * @param sphereCenter defines the bounding sphere center
  129683. * @param sphereRadius defines the bounding sphere radius
  129684. * @param selection defines the array to store current content if selection is positive
  129685. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129686. */
  129687. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  129688. /**
  129689. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  129690. * @param ray defines the ray to test with
  129691. * @param selection defines the array to store current content if selection is positive
  129692. */
  129693. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  129694. /**
  129695. * Subdivide the content into child blocks (this block will then be empty)
  129696. */
  129697. createInnerBlocks(): void;
  129698. /**
  129699. * @hidden
  129700. */
  129701. 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;
  129702. }
  129703. }
  129704. declare module BABYLON {
  129705. /**
  129706. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  129707. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129708. */
  129709. export class Octree<T> {
  129710. /** 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.) */
  129711. maxDepth: number;
  129712. /**
  129713. * Blocks within the octree containing objects
  129714. */
  129715. blocks: Array<OctreeBlock<T>>;
  129716. /**
  129717. * Content stored in the octree
  129718. */
  129719. dynamicContent: T[];
  129720. private _maxBlockCapacity;
  129721. private _selectionContent;
  129722. private _creationFunc;
  129723. /**
  129724. * Creates a octree
  129725. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129726. * @param creationFunc function to be used to instatiate the octree
  129727. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  129728. * @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.)
  129729. */
  129730. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  129731. /** 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.) */
  129732. maxDepth?: number);
  129733. /**
  129734. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  129735. * @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);
  129736. * @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);
  129737. * @param entries meshes to be added to the octree blocks
  129738. */
  129739. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  129740. /**
  129741. * Adds a mesh to the octree
  129742. * @param entry Mesh to add to the octree
  129743. */
  129744. addMesh(entry: T): void;
  129745. /**
  129746. * Remove an element from the octree
  129747. * @param entry defines the element to remove
  129748. */
  129749. removeMesh(entry: T): void;
  129750. /**
  129751. * Selects an array of meshes within the frustum
  129752. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  129753. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  129754. * @returns array of meshes within the frustum
  129755. */
  129756. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  129757. /**
  129758. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  129759. * @param sphereCenter defines the bounding sphere center
  129760. * @param sphereRadius defines the bounding sphere radius
  129761. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129762. * @returns an array of objects that intersect the sphere
  129763. */
  129764. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  129765. /**
  129766. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  129767. * @param ray defines the ray to test with
  129768. * @returns array of intersected objects
  129769. */
  129770. intersectsRay(ray: Ray): SmartArray<T>;
  129771. /**
  129772. * Adds a mesh into the octree block if it intersects the block
  129773. */
  129774. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  129775. /**
  129776. * Adds a submesh into the octree block if it intersects the block
  129777. */
  129778. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  129779. }
  129780. }
  129781. declare module BABYLON {
  129782. interface Scene {
  129783. /**
  129784. * @hidden
  129785. * Backing Filed
  129786. */
  129787. _selectionOctree: Octree<AbstractMesh>;
  129788. /**
  129789. * Gets the octree used to boost mesh selection (picking)
  129790. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129791. */
  129792. selectionOctree: Octree<AbstractMesh>;
  129793. /**
  129794. * Creates or updates the octree used to boost selection (picking)
  129795. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129796. * @param maxCapacity defines the maximum capacity per leaf
  129797. * @param maxDepth defines the maximum depth of the octree
  129798. * @returns an octree of AbstractMesh
  129799. */
  129800. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  129801. }
  129802. interface AbstractMesh {
  129803. /**
  129804. * @hidden
  129805. * Backing Field
  129806. */
  129807. _submeshesOctree: Octree<SubMesh>;
  129808. /**
  129809. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  129810. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  129811. * @param maxCapacity defines the maximum size of each block (64 by default)
  129812. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  129813. * @returns the new octree
  129814. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  129815. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129816. */
  129817. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  129818. }
  129819. /**
  129820. * Defines the octree scene component responsible to manage any octrees
  129821. * in a given scene.
  129822. */
  129823. export class OctreeSceneComponent {
  129824. /**
  129825. * The component name help to identify the component in the list of scene components.
  129826. */
  129827. readonly name: string;
  129828. /**
  129829. * The scene the component belongs to.
  129830. */
  129831. scene: Scene;
  129832. /**
  129833. * Indicates if the meshes have been checked to make sure they are isEnabled()
  129834. */
  129835. readonly checksIsEnabled: boolean;
  129836. /**
  129837. * Creates a new instance of the component for the given scene
  129838. * @param scene Defines the scene to register the component in
  129839. */
  129840. constructor(scene: Scene);
  129841. /**
  129842. * Registers the component in a given scene
  129843. */
  129844. register(): void;
  129845. /**
  129846. * Return the list of active meshes
  129847. * @returns the list of active meshes
  129848. */
  129849. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  129850. /**
  129851. * Return the list of active sub meshes
  129852. * @param mesh The mesh to get the candidates sub meshes from
  129853. * @returns the list of active sub meshes
  129854. */
  129855. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  129856. private _tempRay;
  129857. /**
  129858. * Return the list of sub meshes intersecting with a given local ray
  129859. * @param mesh defines the mesh to find the submesh for
  129860. * @param localRay defines the ray in local space
  129861. * @returns the list of intersecting sub meshes
  129862. */
  129863. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  129864. /**
  129865. * Return the list of sub meshes colliding with a collider
  129866. * @param mesh defines the mesh to find the submesh for
  129867. * @param collider defines the collider to evaluate the collision against
  129868. * @returns the list of colliding sub meshes
  129869. */
  129870. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  129871. /**
  129872. * Rebuilds the elements related to this component in case of
  129873. * context lost for instance.
  129874. */
  129875. rebuild(): void;
  129876. /**
  129877. * Disposes the component and the associated ressources.
  129878. */
  129879. dispose(): void;
  129880. }
  129881. }
  129882. declare module BABYLON {
  129883. /**
  129884. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  129885. */
  129886. export class Gizmo implements IDisposable {
  129887. /** The utility layer the gizmo will be added to */
  129888. gizmoLayer: UtilityLayerRenderer;
  129889. /**
  129890. * The root mesh of the gizmo
  129891. */
  129892. _rootMesh: Mesh;
  129893. private _attachedMesh;
  129894. private _attachedNode;
  129895. /**
  129896. * Ratio for the scale of the gizmo (Default: 1)
  129897. */
  129898. scaleRatio: number;
  129899. /**
  129900. * If a custom mesh has been set (Default: false)
  129901. */
  129902. protected _customMeshSet: boolean;
  129903. /**
  129904. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  129905. * * When set, interactions will be enabled
  129906. */
  129907. get attachedMesh(): Nullable<AbstractMesh>;
  129908. set attachedMesh(value: Nullable<AbstractMesh>);
  129909. /**
  129910. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  129911. * * When set, interactions will be enabled
  129912. */
  129913. get attachedNode(): Nullable<Node>;
  129914. set attachedNode(value: Nullable<Node>);
  129915. /**
  129916. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  129917. * @param mesh The mesh to replace the default mesh of the gizmo
  129918. */
  129919. setCustomMesh(mesh: Mesh): void;
  129920. /**
  129921. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  129922. */
  129923. updateGizmoRotationToMatchAttachedMesh: boolean;
  129924. /**
  129925. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  129926. */
  129927. updateGizmoPositionToMatchAttachedMesh: boolean;
  129928. /**
  129929. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  129930. */
  129931. updateScale: boolean;
  129932. protected _interactionsEnabled: boolean;
  129933. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129934. private _beforeRenderObserver;
  129935. private _tempQuaternion;
  129936. private _tempVector;
  129937. private _tempVector2;
  129938. /**
  129939. * Creates a gizmo
  129940. * @param gizmoLayer The utility layer the gizmo will be added to
  129941. */
  129942. constructor(
  129943. /** The utility layer the gizmo will be added to */
  129944. gizmoLayer?: UtilityLayerRenderer);
  129945. /**
  129946. * Updates the gizmo to match the attached mesh's position/rotation
  129947. */
  129948. protected _update(): void;
  129949. /**
  129950. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  129951. * @param value Node, TransformNode or mesh
  129952. */
  129953. protected _matrixChanged(): void;
  129954. /**
  129955. * Disposes of the gizmo
  129956. */
  129957. dispose(): void;
  129958. }
  129959. }
  129960. declare module BABYLON {
  129961. /**
  129962. * Single plane drag gizmo
  129963. */
  129964. export class PlaneDragGizmo extends Gizmo {
  129965. /**
  129966. * Drag behavior responsible for the gizmos dragging interactions
  129967. */
  129968. dragBehavior: PointerDragBehavior;
  129969. private _pointerObserver;
  129970. /**
  129971. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129972. */
  129973. snapDistance: number;
  129974. /**
  129975. * Event that fires each time the gizmo snaps to a new location.
  129976. * * snapDistance is the the change in distance
  129977. */
  129978. onSnapObservable: Observable<{
  129979. snapDistance: number;
  129980. }>;
  129981. private _plane;
  129982. private _coloredMaterial;
  129983. private _hoverMaterial;
  129984. private _isEnabled;
  129985. private _parent;
  129986. /** @hidden */
  129987. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  129988. /** @hidden */
  129989. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  129990. /**
  129991. * Creates a PlaneDragGizmo
  129992. * @param gizmoLayer The utility layer the gizmo will be added to
  129993. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  129994. * @param color The color of the gizmo
  129995. */
  129996. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  129997. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129998. /**
  129999. * If the gizmo is enabled
  130000. */
  130001. set isEnabled(value: boolean);
  130002. get isEnabled(): boolean;
  130003. /**
  130004. * Disposes of the gizmo
  130005. */
  130006. dispose(): void;
  130007. }
  130008. }
  130009. declare module BABYLON {
  130010. /**
  130011. * Gizmo that enables dragging a mesh along 3 axis
  130012. */
  130013. export class PositionGizmo extends Gizmo {
  130014. /**
  130015. * Internal gizmo used for interactions on the x axis
  130016. */
  130017. xGizmo: AxisDragGizmo;
  130018. /**
  130019. * Internal gizmo used for interactions on the y axis
  130020. */
  130021. yGizmo: AxisDragGizmo;
  130022. /**
  130023. * Internal gizmo used for interactions on the z axis
  130024. */
  130025. zGizmo: AxisDragGizmo;
  130026. /**
  130027. * Internal gizmo used for interactions on the yz plane
  130028. */
  130029. xPlaneGizmo: PlaneDragGizmo;
  130030. /**
  130031. * Internal gizmo used for interactions on the xz plane
  130032. */
  130033. yPlaneGizmo: PlaneDragGizmo;
  130034. /**
  130035. * Internal gizmo used for interactions on the xy plane
  130036. */
  130037. zPlaneGizmo: PlaneDragGizmo;
  130038. /**
  130039. * private variables
  130040. */
  130041. private _meshAttached;
  130042. private _nodeAttached;
  130043. private _updateGizmoRotationToMatchAttachedMesh;
  130044. private _snapDistance;
  130045. private _scaleRatio;
  130046. /** Fires an event when any of it's sub gizmos are dragged */
  130047. onDragStartObservable: Observable<unknown>;
  130048. /** Fires an event when any of it's sub gizmos are released from dragging */
  130049. onDragEndObservable: Observable<unknown>;
  130050. /**
  130051. * If set to true, planar drag is enabled
  130052. */
  130053. private _planarGizmoEnabled;
  130054. get attachedMesh(): Nullable<AbstractMesh>;
  130055. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130056. get attachedNode(): Nullable<Node>;
  130057. set attachedNode(node: Nullable<Node>);
  130058. /**
  130059. * Creates a PositionGizmo
  130060. * @param gizmoLayer The utility layer the gizmo will be added to
  130061. @param thickness display gizmo axis thickness
  130062. */
  130063. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  130064. /**
  130065. * If the planar drag gizmo is enabled
  130066. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  130067. */
  130068. set planarGizmoEnabled(value: boolean);
  130069. get planarGizmoEnabled(): boolean;
  130070. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130071. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130072. /**
  130073. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130074. */
  130075. set snapDistance(value: number);
  130076. get snapDistance(): number;
  130077. /**
  130078. * Ratio for the scale of the gizmo (Default: 1)
  130079. */
  130080. set scaleRatio(value: number);
  130081. get scaleRatio(): number;
  130082. /**
  130083. * Disposes of the gizmo
  130084. */
  130085. dispose(): void;
  130086. /**
  130087. * CustomMeshes are not supported by this gizmo
  130088. * @param mesh The mesh to replace the default mesh of the gizmo
  130089. */
  130090. setCustomMesh(mesh: Mesh): void;
  130091. }
  130092. }
  130093. declare module BABYLON {
  130094. /**
  130095. * Single axis drag gizmo
  130096. */
  130097. export class AxisDragGizmo extends Gizmo {
  130098. /**
  130099. * Drag behavior responsible for the gizmos dragging interactions
  130100. */
  130101. dragBehavior: PointerDragBehavior;
  130102. private _pointerObserver;
  130103. /**
  130104. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130105. */
  130106. snapDistance: number;
  130107. /**
  130108. * Event that fires each time the gizmo snaps to a new location.
  130109. * * snapDistance is the the change in distance
  130110. */
  130111. onSnapObservable: Observable<{
  130112. snapDistance: number;
  130113. }>;
  130114. private _isEnabled;
  130115. private _parent;
  130116. private _arrow;
  130117. private _coloredMaterial;
  130118. private _hoverMaterial;
  130119. /** @hidden */
  130120. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  130121. /** @hidden */
  130122. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130123. /**
  130124. * Creates an AxisDragGizmo
  130125. * @param gizmoLayer The utility layer the gizmo will be added to
  130126. * @param dragAxis The axis which the gizmo will be able to drag on
  130127. * @param color The color of the gizmo
  130128. * @param thickness display gizmo axis thickness
  130129. */
  130130. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  130131. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130132. /**
  130133. * If the gizmo is enabled
  130134. */
  130135. set isEnabled(value: boolean);
  130136. get isEnabled(): boolean;
  130137. /**
  130138. * Disposes of the gizmo
  130139. */
  130140. dispose(): void;
  130141. }
  130142. }
  130143. declare module BABYLON.Debug {
  130144. /**
  130145. * The Axes viewer will show 3 axes in a specific point in space
  130146. */
  130147. export class AxesViewer {
  130148. private _xAxis;
  130149. private _yAxis;
  130150. private _zAxis;
  130151. private _scaleLinesFactor;
  130152. private _instanced;
  130153. /**
  130154. * Gets the hosting scene
  130155. */
  130156. scene: Scene;
  130157. /**
  130158. * Gets or sets a number used to scale line length
  130159. */
  130160. scaleLines: number;
  130161. /** Gets the node hierarchy used to render x-axis */
  130162. get xAxis(): TransformNode;
  130163. /** Gets the node hierarchy used to render y-axis */
  130164. get yAxis(): TransformNode;
  130165. /** Gets the node hierarchy used to render z-axis */
  130166. get zAxis(): TransformNode;
  130167. /**
  130168. * Creates a new AxesViewer
  130169. * @param scene defines the hosting scene
  130170. * @param scaleLines defines a number used to scale line length (1 by default)
  130171. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  130172. * @param xAxis defines the node hierarchy used to render the x-axis
  130173. * @param yAxis defines the node hierarchy used to render the y-axis
  130174. * @param zAxis defines the node hierarchy used to render the z-axis
  130175. */
  130176. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  130177. /**
  130178. * Force the viewer to update
  130179. * @param position defines the position of the viewer
  130180. * @param xaxis defines the x axis of the viewer
  130181. * @param yaxis defines the y axis of the viewer
  130182. * @param zaxis defines the z axis of the viewer
  130183. */
  130184. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  130185. /**
  130186. * Creates an instance of this axes viewer.
  130187. * @returns a new axes viewer with instanced meshes
  130188. */
  130189. createInstance(): AxesViewer;
  130190. /** Releases resources */
  130191. dispose(): void;
  130192. private static _SetRenderingGroupId;
  130193. }
  130194. }
  130195. declare module BABYLON.Debug {
  130196. /**
  130197. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  130198. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  130199. */
  130200. export class BoneAxesViewer extends AxesViewer {
  130201. /**
  130202. * Gets or sets the target mesh where to display the axes viewer
  130203. */
  130204. mesh: Nullable<Mesh>;
  130205. /**
  130206. * Gets or sets the target bone where to display the axes viewer
  130207. */
  130208. bone: Nullable<Bone>;
  130209. /** Gets current position */
  130210. pos: Vector3;
  130211. /** Gets direction of X axis */
  130212. xaxis: Vector3;
  130213. /** Gets direction of Y axis */
  130214. yaxis: Vector3;
  130215. /** Gets direction of Z axis */
  130216. zaxis: Vector3;
  130217. /**
  130218. * Creates a new BoneAxesViewer
  130219. * @param scene defines the hosting scene
  130220. * @param bone defines the target bone
  130221. * @param mesh defines the target mesh
  130222. * @param scaleLines defines a scaling factor for line length (1 by default)
  130223. */
  130224. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  130225. /**
  130226. * Force the viewer to update
  130227. */
  130228. update(): void;
  130229. /** Releases resources */
  130230. dispose(): void;
  130231. }
  130232. }
  130233. declare module BABYLON {
  130234. /**
  130235. * Interface used to define scene explorer extensibility option
  130236. */
  130237. export interface IExplorerExtensibilityOption {
  130238. /**
  130239. * Define the option label
  130240. */
  130241. label: string;
  130242. /**
  130243. * Defines the action to execute on click
  130244. */
  130245. action: (entity: any) => void;
  130246. }
  130247. /**
  130248. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  130249. */
  130250. export interface IExplorerExtensibilityGroup {
  130251. /**
  130252. * Defines a predicate to test if a given type mut be extended
  130253. */
  130254. predicate: (entity: any) => boolean;
  130255. /**
  130256. * Gets the list of options added to a type
  130257. */
  130258. entries: IExplorerExtensibilityOption[];
  130259. }
  130260. /**
  130261. * Interface used to define the options to use to create the Inspector
  130262. */
  130263. export interface IInspectorOptions {
  130264. /**
  130265. * Display in overlay mode (default: false)
  130266. */
  130267. overlay?: boolean;
  130268. /**
  130269. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  130270. */
  130271. globalRoot?: HTMLElement;
  130272. /**
  130273. * Display the Scene explorer
  130274. */
  130275. showExplorer?: boolean;
  130276. /**
  130277. * Display the property inspector
  130278. */
  130279. showInspector?: boolean;
  130280. /**
  130281. * Display in embed mode (both panes on the right)
  130282. */
  130283. embedMode?: boolean;
  130284. /**
  130285. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  130286. */
  130287. handleResize?: boolean;
  130288. /**
  130289. * Allow the panes to popup (default: true)
  130290. */
  130291. enablePopup?: boolean;
  130292. /**
  130293. * Allow the panes to be closed by users (default: true)
  130294. */
  130295. enableClose?: boolean;
  130296. /**
  130297. * Optional list of extensibility entries
  130298. */
  130299. explorerExtensibility?: IExplorerExtensibilityGroup[];
  130300. /**
  130301. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  130302. */
  130303. inspectorURL?: string;
  130304. /**
  130305. * Optional initial tab (default to DebugLayerTab.Properties)
  130306. */
  130307. initialTab?: DebugLayerTab;
  130308. }
  130309. interface Scene {
  130310. /**
  130311. * @hidden
  130312. * Backing field
  130313. */
  130314. _debugLayer: DebugLayer;
  130315. /**
  130316. * Gets the debug layer (aka Inspector) associated with the scene
  130317. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130318. */
  130319. debugLayer: DebugLayer;
  130320. }
  130321. /**
  130322. * Enum of inspector action tab
  130323. */
  130324. export enum DebugLayerTab {
  130325. /**
  130326. * Properties tag (default)
  130327. */
  130328. Properties = 0,
  130329. /**
  130330. * Debug tab
  130331. */
  130332. Debug = 1,
  130333. /**
  130334. * Statistics tab
  130335. */
  130336. Statistics = 2,
  130337. /**
  130338. * Tools tab
  130339. */
  130340. Tools = 3,
  130341. /**
  130342. * Settings tab
  130343. */
  130344. Settings = 4
  130345. }
  130346. /**
  130347. * The debug layer (aka Inspector) is the go to tool in order to better understand
  130348. * what is happening in your scene
  130349. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130350. */
  130351. export class DebugLayer {
  130352. /**
  130353. * Define the url to get the inspector script from.
  130354. * By default it uses the babylonjs CDN.
  130355. * @ignoreNaming
  130356. */
  130357. static InspectorURL: string;
  130358. private _scene;
  130359. private BJSINSPECTOR;
  130360. private _onPropertyChangedObservable?;
  130361. /**
  130362. * Observable triggered when a property is changed through the inspector.
  130363. */
  130364. get onPropertyChangedObservable(): any;
  130365. /**
  130366. * Instantiates a new debug layer.
  130367. * The debug layer (aka Inspector) is the go to tool in order to better understand
  130368. * what is happening in your scene
  130369. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130370. * @param scene Defines the scene to inspect
  130371. */
  130372. constructor(scene: Scene);
  130373. /** Creates the inspector window. */
  130374. private _createInspector;
  130375. /**
  130376. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  130377. * @param entity defines the entity to select
  130378. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  130379. */
  130380. select(entity: any, lineContainerTitles?: string | string[]): void;
  130381. /** Get the inspector from bundle or global */
  130382. private _getGlobalInspector;
  130383. /**
  130384. * Get if the inspector is visible or not.
  130385. * @returns true if visible otherwise, false
  130386. */
  130387. isVisible(): boolean;
  130388. /**
  130389. * Hide the inspector and close its window.
  130390. */
  130391. hide(): void;
  130392. /**
  130393. * Update the scene in the inspector
  130394. */
  130395. setAsActiveScene(): void;
  130396. /**
  130397. * Launch the debugLayer.
  130398. * @param config Define the configuration of the inspector
  130399. * @return a promise fulfilled when the debug layer is visible
  130400. */
  130401. show(config?: IInspectorOptions): Promise<DebugLayer>;
  130402. }
  130403. }
  130404. declare module BABYLON {
  130405. /**
  130406. * Class containing static functions to help procedurally build meshes
  130407. */
  130408. export class BoxBuilder {
  130409. /**
  130410. * Creates a box mesh
  130411. * * The parameter `size` sets the size (float) of each box side (default 1)
  130412. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  130413. * * 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)
  130414. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130418. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  130419. * @param name defines the name of the mesh
  130420. * @param options defines the options used to create the mesh
  130421. * @param scene defines the hosting scene
  130422. * @returns the box mesh
  130423. */
  130424. static CreateBox(name: string, options: {
  130425. size?: number;
  130426. width?: number;
  130427. height?: number;
  130428. depth?: number;
  130429. faceUV?: Vector4[];
  130430. faceColors?: Color4[];
  130431. sideOrientation?: number;
  130432. frontUVs?: Vector4;
  130433. backUVs?: Vector4;
  130434. wrap?: boolean;
  130435. topBaseAt?: number;
  130436. bottomBaseAt?: number;
  130437. updatable?: boolean;
  130438. }, scene?: Nullable<Scene>): Mesh;
  130439. }
  130440. }
  130441. declare module BABYLON.Debug {
  130442. /**
  130443. * Used to show the physics impostor around the specific mesh
  130444. */
  130445. export class PhysicsViewer {
  130446. /** @hidden */
  130447. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  130448. /** @hidden */
  130449. protected _meshes: Array<Nullable<AbstractMesh>>;
  130450. /** @hidden */
  130451. protected _scene: Nullable<Scene>;
  130452. /** @hidden */
  130453. protected _numMeshes: number;
  130454. /** @hidden */
  130455. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  130456. private _renderFunction;
  130457. private _utilityLayer;
  130458. private _debugBoxMesh;
  130459. private _debugSphereMesh;
  130460. private _debugCylinderMesh;
  130461. private _debugMaterial;
  130462. private _debugMeshMeshes;
  130463. /**
  130464. * Creates a new PhysicsViewer
  130465. * @param scene defines the hosting scene
  130466. */
  130467. constructor(scene: Scene);
  130468. /** @hidden */
  130469. protected _updateDebugMeshes(): void;
  130470. /**
  130471. * Renders a specified physic impostor
  130472. * @param impostor defines the impostor to render
  130473. * @param targetMesh defines the mesh represented by the impostor
  130474. * @returns the new debug mesh used to render the impostor
  130475. */
  130476. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  130477. /**
  130478. * Hides a specified physic impostor
  130479. * @param impostor defines the impostor to hide
  130480. */
  130481. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  130482. private _getDebugMaterial;
  130483. private _getDebugBoxMesh;
  130484. private _getDebugSphereMesh;
  130485. private _getDebugCylinderMesh;
  130486. private _getDebugMeshMesh;
  130487. private _getDebugMesh;
  130488. /** Releases all resources */
  130489. dispose(): void;
  130490. }
  130491. }
  130492. declare module BABYLON {
  130493. /**
  130494. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  130495. * in order to better appreciate the issue one might have.
  130496. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  130497. */
  130498. export class RayHelper {
  130499. /**
  130500. * Defines the ray we are currently tryin to visualize.
  130501. */
  130502. ray: Nullable<Ray>;
  130503. private _renderPoints;
  130504. private _renderLine;
  130505. private _renderFunction;
  130506. private _scene;
  130507. private _onAfterRenderObserver;
  130508. private _onAfterStepObserver;
  130509. private _attachedToMesh;
  130510. private _meshSpaceDirection;
  130511. private _meshSpaceOrigin;
  130512. /**
  130513. * Helper function to create a colored helper in a scene in one line.
  130514. * @param ray Defines the ray we are currently tryin to visualize
  130515. * @param scene Defines the scene the ray is used in
  130516. * @param color Defines the color we want to see the ray in
  130517. * @returns The newly created ray helper.
  130518. */
  130519. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  130520. /**
  130521. * Instantiate a new ray helper.
  130522. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  130523. * in order to better appreciate the issue one might have.
  130524. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  130525. * @param ray Defines the ray we are currently tryin to visualize
  130526. */
  130527. constructor(ray: Ray);
  130528. /**
  130529. * Shows the ray we are willing to debug.
  130530. * @param scene Defines the scene the ray needs to be rendered in
  130531. * @param color Defines the color the ray needs to be rendered in
  130532. */
  130533. show(scene: Scene, color?: Color3): void;
  130534. /**
  130535. * Hides the ray we are debugging.
  130536. */
  130537. hide(): void;
  130538. private _render;
  130539. /**
  130540. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  130541. * @param mesh Defines the mesh we want the helper attached to
  130542. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  130543. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  130544. * @param length Defines the length of the ray
  130545. */
  130546. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  130547. /**
  130548. * Detach the ray helper from the mesh it has previously been attached to.
  130549. */
  130550. detachFromMesh(): void;
  130551. private _updateToMesh;
  130552. /**
  130553. * Dispose the helper and release its associated resources.
  130554. */
  130555. dispose(): void;
  130556. }
  130557. }
  130558. declare module BABYLON {
  130559. /**
  130560. * Defines the options associated with the creation of a SkeletonViewer.
  130561. */
  130562. export interface ISkeletonViewerOptions {
  130563. /** Should the system pause animations before building the Viewer? */
  130564. pauseAnimations: boolean;
  130565. /** Should the system return the skeleton to rest before building? */
  130566. returnToRest: boolean;
  130567. /** public Display Mode of the Viewer */
  130568. displayMode: number;
  130569. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  130570. displayOptions: ISkeletonViewerDisplayOptions;
  130571. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  130572. computeBonesUsingShaders: boolean;
  130573. }
  130574. /**
  130575. * Defines how to display the various bone meshes for the viewer.
  130576. */
  130577. export interface ISkeletonViewerDisplayOptions {
  130578. /** How far down to start tapering the bone spurs */
  130579. midStep?: number;
  130580. /** How big is the midStep? */
  130581. midStepFactor?: number;
  130582. /** Base for the Sphere Size */
  130583. sphereBaseSize?: number;
  130584. /** The ratio of the sphere to the longest bone in units */
  130585. sphereScaleUnit?: number;
  130586. /** Ratio for the Sphere Size */
  130587. sphereFactor?: number;
  130588. }
  130589. }
  130590. declare module BABYLON {
  130591. /**
  130592. * Class containing static functions to help procedurally build meshes
  130593. */
  130594. export class RibbonBuilder {
  130595. /**
  130596. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130597. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  130598. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  130599. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  130600. * * 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
  130601. * * 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
  130602. * * 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
  130603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130604. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130605. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130606. * * 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
  130607. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  130608. * * 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
  130609. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  130610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130611. * @param name defines the name of the mesh
  130612. * @param options defines the options used to create the mesh
  130613. * @param scene defines the hosting scene
  130614. * @returns the ribbon mesh
  130615. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  130616. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130617. */
  130618. static CreateRibbon(name: string, options: {
  130619. pathArray: Vector3[][];
  130620. closeArray?: boolean;
  130621. closePath?: boolean;
  130622. offset?: number;
  130623. updatable?: boolean;
  130624. sideOrientation?: number;
  130625. frontUVs?: Vector4;
  130626. backUVs?: Vector4;
  130627. instance?: Mesh;
  130628. invertUV?: boolean;
  130629. uvs?: Vector2[];
  130630. colors?: Color4[];
  130631. }, scene?: Nullable<Scene>): Mesh;
  130632. }
  130633. }
  130634. declare module BABYLON {
  130635. /**
  130636. * Class containing static functions to help procedurally build meshes
  130637. */
  130638. export class ShapeBuilder {
  130639. /**
  130640. * 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.
  130641. * * 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.
  130642. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130643. * * 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.
  130644. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  130645. * * 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
  130646. * * 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
  130647. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  130648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130650. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  130651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130652. * @param name defines the name of the mesh
  130653. * @param options defines the options used to create the mesh
  130654. * @param scene defines the hosting scene
  130655. * @returns the extruded shape mesh
  130656. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130657. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130658. */
  130659. static ExtrudeShape(name: string, options: {
  130660. shape: Vector3[];
  130661. path: Vector3[];
  130662. scale?: number;
  130663. rotation?: number;
  130664. cap?: number;
  130665. updatable?: boolean;
  130666. sideOrientation?: number;
  130667. frontUVs?: Vector4;
  130668. backUVs?: Vector4;
  130669. instance?: Mesh;
  130670. invertUV?: boolean;
  130671. }, scene?: Nullable<Scene>): Mesh;
  130672. /**
  130673. * Creates an custom extruded shape mesh.
  130674. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  130675. * * 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.
  130676. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130677. * * 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
  130678. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  130679. * * 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
  130680. * * It must returns a float value that will be the scale value applied to the shape on each path point
  130681. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  130682. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  130683. * * 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
  130684. * * 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
  130685. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  130686. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130687. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130688. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130690. * @param name defines the name of the mesh
  130691. * @param options defines the options used to create the mesh
  130692. * @param scene defines the hosting scene
  130693. * @returns the custom extruded shape mesh
  130694. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  130695. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130696. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130697. */
  130698. static ExtrudeShapeCustom(name: string, options: {
  130699. shape: Vector3[];
  130700. path: Vector3[];
  130701. scaleFunction?: any;
  130702. rotationFunction?: any;
  130703. ribbonCloseArray?: boolean;
  130704. ribbonClosePath?: boolean;
  130705. cap?: number;
  130706. updatable?: boolean;
  130707. sideOrientation?: number;
  130708. frontUVs?: Vector4;
  130709. backUVs?: Vector4;
  130710. instance?: Mesh;
  130711. invertUV?: boolean;
  130712. }, scene?: Nullable<Scene>): Mesh;
  130713. private static _ExtrudeShapeGeneric;
  130714. }
  130715. }
  130716. declare module BABYLON.Debug {
  130717. /**
  130718. * Class used to render a debug view of a given skeleton
  130719. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  130720. */
  130721. export class SkeletonViewer {
  130722. /** defines the skeleton to render */
  130723. skeleton: Skeleton;
  130724. /** defines the mesh attached to the skeleton */
  130725. mesh: AbstractMesh;
  130726. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  130727. autoUpdateBonesMatrices: boolean;
  130728. /** defines the rendering group id to use with the viewer */
  130729. renderingGroupId: number;
  130730. /** is the options for the viewer */
  130731. options: Partial<ISkeletonViewerOptions>;
  130732. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  130733. static readonly DISPLAY_LINES: number;
  130734. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  130735. static readonly DISPLAY_SPHERES: number;
  130736. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  130737. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  130738. /** If SkeletonViewer scene scope. */
  130739. private _scene;
  130740. /** Gets or sets the color used to render the skeleton */
  130741. color: Color3;
  130742. /** Array of the points of the skeleton fo the line view. */
  130743. private _debugLines;
  130744. /** The SkeletonViewers Mesh. */
  130745. private _debugMesh;
  130746. /** If SkeletonViewer is enabled. */
  130747. private _isEnabled;
  130748. /** If SkeletonViewer is ready. */
  130749. private _ready;
  130750. /** SkeletonViewer render observable. */
  130751. private _obs;
  130752. /** The Utility Layer to render the gizmos in. */
  130753. private _utilityLayer;
  130754. private _boneIndices;
  130755. /** Gets the Scene. */
  130756. get scene(): Scene;
  130757. /** Gets the utilityLayer. */
  130758. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  130759. /** Checks Ready Status. */
  130760. get isReady(): Boolean;
  130761. /** Sets Ready Status. */
  130762. set ready(value: boolean);
  130763. /** Gets the debugMesh */
  130764. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  130765. /** Sets the debugMesh */
  130766. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  130767. /** Gets the material */
  130768. get material(): StandardMaterial;
  130769. /** Sets the material */
  130770. set material(value: StandardMaterial);
  130771. /** Gets the material */
  130772. get displayMode(): number;
  130773. /** Sets the material */
  130774. set displayMode(value: number);
  130775. /**
  130776. * Creates a new SkeletonViewer
  130777. * @param skeleton defines the skeleton to render
  130778. * @param mesh defines the mesh attached to the skeleton
  130779. * @param scene defines the hosting scene
  130780. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  130781. * @param renderingGroupId defines the rendering group id to use with the viewer
  130782. * @param options All of the extra constructor options for the SkeletonViewer
  130783. */
  130784. constructor(
  130785. /** defines the skeleton to render */
  130786. skeleton: Skeleton,
  130787. /** defines the mesh attached to the skeleton */
  130788. mesh: AbstractMesh,
  130789. /** The Scene scope*/
  130790. scene: Scene,
  130791. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  130792. autoUpdateBonesMatrices?: boolean,
  130793. /** defines the rendering group id to use with the viewer */
  130794. renderingGroupId?: number,
  130795. /** is the options for the viewer */
  130796. options?: Partial<ISkeletonViewerOptions>);
  130797. /** The Dynamic bindings for the update functions */
  130798. private _bindObs;
  130799. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  130800. update(): void;
  130801. /** Gets or sets a boolean indicating if the viewer is enabled */
  130802. set isEnabled(value: boolean);
  130803. get isEnabled(): boolean;
  130804. private _getBonePosition;
  130805. private _getLinesForBonesWithLength;
  130806. private _getLinesForBonesNoLength;
  130807. /** function to revert the mesh and scene back to the initial state. */
  130808. private _revert;
  130809. /** function to build and bind sphere joint points and spur bone representations. */
  130810. private _buildSpheresAndSpurs;
  130811. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  130812. private _displayLinesUpdate;
  130813. /** Changes the displayMode of the skeleton viewer
  130814. * @param mode The displayMode numerical value
  130815. */
  130816. changeDisplayMode(mode: number): void;
  130817. /** Changes the displayMode of the skeleton viewer
  130818. * @param option String of the option name
  130819. * @param value The numerical option value
  130820. */
  130821. changeDisplayOptions(option: string, value: number): void;
  130822. /** Release associated resources */
  130823. dispose(): void;
  130824. }
  130825. }
  130826. declare module BABYLON {
  130827. /**
  130828. * Enum for Device Types
  130829. */
  130830. export enum DeviceType {
  130831. /** Generic */
  130832. Generic = 0,
  130833. /** Keyboard */
  130834. Keyboard = 1,
  130835. /** Mouse */
  130836. Mouse = 2,
  130837. /** Touch Pointers */
  130838. Touch = 3,
  130839. /** PS4 Dual Shock */
  130840. DualShock = 4,
  130841. /** Xbox */
  130842. Xbox = 5,
  130843. /** Switch Controller */
  130844. Switch = 6
  130845. }
  130846. /**
  130847. * Enum for All Pointers (Touch/Mouse)
  130848. */
  130849. export enum PointerInput {
  130850. /** Horizontal Axis */
  130851. Horizontal = 0,
  130852. /** Vertical Axis */
  130853. Vertical = 1,
  130854. /** Left Click or Touch */
  130855. LeftClick = 2,
  130856. /** Middle Click */
  130857. MiddleClick = 3,
  130858. /** Right Click */
  130859. RightClick = 4,
  130860. /** Browser Back */
  130861. BrowserBack = 5,
  130862. /** Browser Forward */
  130863. BrowserForward = 6
  130864. }
  130865. /**
  130866. * Enum for Dual Shock Gamepad
  130867. */
  130868. export enum DualShockInput {
  130869. /** Cross */
  130870. Cross = 0,
  130871. /** Circle */
  130872. Circle = 1,
  130873. /** Square */
  130874. Square = 2,
  130875. /** Triangle */
  130876. Triangle = 3,
  130877. /** L1 */
  130878. L1 = 4,
  130879. /** R1 */
  130880. R1 = 5,
  130881. /** L2 */
  130882. L2 = 6,
  130883. /** R2 */
  130884. R2 = 7,
  130885. /** Share */
  130886. Share = 8,
  130887. /** Options */
  130888. Options = 9,
  130889. /** L3 */
  130890. L3 = 10,
  130891. /** R3 */
  130892. R3 = 11,
  130893. /** DPadUp */
  130894. DPadUp = 12,
  130895. /** DPadDown */
  130896. DPadDown = 13,
  130897. /** DPadLeft */
  130898. DPadLeft = 14,
  130899. /** DRight */
  130900. DPadRight = 15,
  130901. /** Home */
  130902. Home = 16,
  130903. /** TouchPad */
  130904. TouchPad = 17,
  130905. /** LStickXAxis */
  130906. LStickXAxis = 18,
  130907. /** LStickYAxis */
  130908. LStickYAxis = 19,
  130909. /** RStickXAxis */
  130910. RStickXAxis = 20,
  130911. /** RStickYAxis */
  130912. RStickYAxis = 21
  130913. }
  130914. /**
  130915. * Enum for Xbox Gamepad
  130916. */
  130917. export enum XboxInput {
  130918. /** A */
  130919. A = 0,
  130920. /** B */
  130921. B = 1,
  130922. /** X */
  130923. X = 2,
  130924. /** Y */
  130925. Y = 3,
  130926. /** LB */
  130927. LB = 4,
  130928. /** RB */
  130929. RB = 5,
  130930. /** LT */
  130931. LT = 6,
  130932. /** RT */
  130933. RT = 7,
  130934. /** Back */
  130935. Back = 8,
  130936. /** Start */
  130937. Start = 9,
  130938. /** LS */
  130939. LS = 10,
  130940. /** RS */
  130941. RS = 11,
  130942. /** DPadUp */
  130943. DPadUp = 12,
  130944. /** DPadDown */
  130945. DPadDown = 13,
  130946. /** DPadLeft */
  130947. DPadLeft = 14,
  130948. /** DRight */
  130949. DPadRight = 15,
  130950. /** Home */
  130951. Home = 16,
  130952. /** LStickXAxis */
  130953. LStickXAxis = 17,
  130954. /** LStickYAxis */
  130955. LStickYAxis = 18,
  130956. /** RStickXAxis */
  130957. RStickXAxis = 19,
  130958. /** RStickYAxis */
  130959. RStickYAxis = 20
  130960. }
  130961. /**
  130962. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  130963. */
  130964. export enum SwitchInput {
  130965. /** B */
  130966. B = 0,
  130967. /** A */
  130968. A = 1,
  130969. /** Y */
  130970. Y = 2,
  130971. /** X */
  130972. X = 3,
  130973. /** L */
  130974. L = 4,
  130975. /** R */
  130976. R = 5,
  130977. /** ZL */
  130978. ZL = 6,
  130979. /** ZR */
  130980. ZR = 7,
  130981. /** Minus */
  130982. Minus = 8,
  130983. /** Plus */
  130984. Plus = 9,
  130985. /** LS */
  130986. LS = 10,
  130987. /** RS */
  130988. RS = 11,
  130989. /** DPadUp */
  130990. DPadUp = 12,
  130991. /** DPadDown */
  130992. DPadDown = 13,
  130993. /** DPadLeft */
  130994. DPadLeft = 14,
  130995. /** DRight */
  130996. DPadRight = 15,
  130997. /** Home */
  130998. Home = 16,
  130999. /** Capture */
  131000. Capture = 17,
  131001. /** LStickXAxis */
  131002. LStickXAxis = 18,
  131003. /** LStickYAxis */
  131004. LStickYAxis = 19,
  131005. /** RStickXAxis */
  131006. RStickXAxis = 20,
  131007. /** RStickYAxis */
  131008. RStickYAxis = 21
  131009. }
  131010. }
  131011. declare module BABYLON {
  131012. /**
  131013. * This class will take all inputs from Keyboard, Pointer, and
  131014. * any Gamepads and provide a polling system that all devices
  131015. * will use. This class assumes that there will only be one
  131016. * pointer device and one keyboard.
  131017. */
  131018. export class DeviceInputSystem implements IDisposable {
  131019. /**
  131020. * Callback to be triggered when a device is connected
  131021. */
  131022. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131023. /**
  131024. * Callback to be triggered when a device is disconnected
  131025. */
  131026. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131027. /**
  131028. * Callback to be triggered when event driven input is updated
  131029. */
  131030. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  131031. private _inputs;
  131032. private _gamepads;
  131033. private _keyboardActive;
  131034. private _pointerActive;
  131035. private _elementToAttachTo;
  131036. private _keyboardDownEvent;
  131037. private _keyboardUpEvent;
  131038. private _pointerMoveEvent;
  131039. private _pointerDownEvent;
  131040. private _pointerUpEvent;
  131041. private _gamepadConnectedEvent;
  131042. private _gamepadDisconnectedEvent;
  131043. private static _MAX_KEYCODES;
  131044. private static _MAX_POINTER_INPUTS;
  131045. private constructor();
  131046. /**
  131047. * Creates a new DeviceInputSystem instance
  131048. * @param engine Engine to pull input element from
  131049. * @returns The new instance
  131050. */
  131051. static Create(engine: Engine): DeviceInputSystem;
  131052. /**
  131053. * Checks for current device input value, given an id and input index
  131054. * @param deviceName Id of connected device
  131055. * @param inputIndex Index of device input
  131056. * @returns Current value of input
  131057. */
  131058. /**
  131059. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  131060. * @param deviceType Enum specifiying device type
  131061. * @param deviceSlot "Slot" or index that device is referenced in
  131062. * @param inputIndex Id of input to be checked
  131063. * @returns Current value of input
  131064. */
  131065. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  131066. /**
  131067. * Dispose of all the eventlisteners
  131068. */
  131069. dispose(): void;
  131070. /**
  131071. * Add device and inputs to device array
  131072. * @param deviceType Enum specifiying device type
  131073. * @param deviceSlot "Slot" or index that device is referenced in
  131074. * @param numberOfInputs Number of input entries to create for given device
  131075. */
  131076. private _registerDevice;
  131077. /**
  131078. * Given a specific device name, remove that device from the device map
  131079. * @param deviceType Enum specifiying device type
  131080. * @param deviceSlot "Slot" or index that device is referenced in
  131081. */
  131082. private _unregisterDevice;
  131083. /**
  131084. * Handle all actions that come from keyboard interaction
  131085. */
  131086. private _handleKeyActions;
  131087. /**
  131088. * Handle all actions that come from pointer interaction
  131089. */
  131090. private _handlePointerActions;
  131091. /**
  131092. * Handle all actions that come from gamepad interaction
  131093. */
  131094. private _handleGamepadActions;
  131095. /**
  131096. * Update all non-event based devices with each frame
  131097. * @param deviceType Enum specifiying device type
  131098. * @param deviceSlot "Slot" or index that device is referenced in
  131099. * @param inputIndex Id of input to be checked
  131100. */
  131101. private _updateDevice;
  131102. /**
  131103. * Gets DeviceType from the device name
  131104. * @param deviceName Name of Device from DeviceInputSystem
  131105. * @returns DeviceType enum value
  131106. */
  131107. private _getGamepadDeviceType;
  131108. }
  131109. }
  131110. declare module BABYLON {
  131111. /**
  131112. * Type to handle enforcement of inputs
  131113. */
  131114. 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;
  131115. }
  131116. declare module BABYLON {
  131117. /**
  131118. * Class that handles all input for a specific device
  131119. */
  131120. export class DeviceSource<T extends DeviceType> {
  131121. /** Type of device */
  131122. readonly deviceType: DeviceType;
  131123. /** "Slot" or index that device is referenced in */
  131124. readonly deviceSlot: number;
  131125. /**
  131126. * Observable to handle device input changes per device
  131127. */
  131128. readonly onInputChangedObservable: Observable<{
  131129. inputIndex: DeviceInput<T>;
  131130. previousState: Nullable<number>;
  131131. currentState: Nullable<number>;
  131132. }>;
  131133. private readonly _deviceInputSystem;
  131134. /**
  131135. * Default Constructor
  131136. * @param deviceInputSystem Reference to DeviceInputSystem
  131137. * @param deviceType Type of device
  131138. * @param deviceSlot "Slot" or index that device is referenced in
  131139. */
  131140. constructor(deviceInputSystem: DeviceInputSystem,
  131141. /** Type of device */
  131142. deviceType: DeviceType,
  131143. /** "Slot" or index that device is referenced in */
  131144. deviceSlot?: number);
  131145. /**
  131146. * Get input for specific input
  131147. * @param inputIndex index of specific input on device
  131148. * @returns Input value from DeviceInputSystem
  131149. */
  131150. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  131151. }
  131152. /**
  131153. * Class to keep track of devices
  131154. */
  131155. export class DeviceSourceManager implements IDisposable {
  131156. /**
  131157. * Observable to be triggered when before a device is connected
  131158. */
  131159. readonly onBeforeDeviceConnectedObservable: Observable<{
  131160. deviceType: DeviceType;
  131161. deviceSlot: number;
  131162. }>;
  131163. /**
  131164. * Observable to be triggered when before a device is disconnected
  131165. */
  131166. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  131167. deviceType: DeviceType;
  131168. deviceSlot: number;
  131169. }>;
  131170. /**
  131171. * Observable to be triggered when after a device is connected
  131172. */
  131173. readonly onAfterDeviceConnectedObservable: Observable<{
  131174. deviceType: DeviceType;
  131175. deviceSlot: number;
  131176. }>;
  131177. /**
  131178. * Observable to be triggered when after a device is disconnected
  131179. */
  131180. readonly onAfterDeviceDisconnectedObservable: Observable<{
  131181. deviceType: DeviceType;
  131182. deviceSlot: number;
  131183. }>;
  131184. private readonly _devices;
  131185. private readonly _firstDevice;
  131186. private readonly _deviceInputSystem;
  131187. /**
  131188. * Default Constructor
  131189. * @param engine engine to pull input element from
  131190. */
  131191. constructor(engine: Engine);
  131192. /**
  131193. * Gets a DeviceSource, given a type and slot
  131194. * @param deviceType Enum specifying device type
  131195. * @param deviceSlot "Slot" or index that device is referenced in
  131196. * @returns DeviceSource object
  131197. */
  131198. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  131199. /**
  131200. * Gets an array of DeviceSource objects for a given device type
  131201. * @param deviceType Enum specifying device type
  131202. * @returns Array of DeviceSource objects
  131203. */
  131204. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  131205. /**
  131206. * Dispose of DeviceInputSystem and other parts
  131207. */
  131208. dispose(): void;
  131209. /**
  131210. * Function to add device name to device list
  131211. * @param deviceType Enum specifying device type
  131212. * @param deviceSlot "Slot" or index that device is referenced in
  131213. */
  131214. private _addDevice;
  131215. /**
  131216. * Function to remove device name to device list
  131217. * @param deviceType Enum specifying device type
  131218. * @param deviceSlot "Slot" or index that device is referenced in
  131219. */
  131220. private _removeDevice;
  131221. /**
  131222. * Updates array storing first connected device of each type
  131223. * @param type Type of Device
  131224. */
  131225. private _updateFirstDevices;
  131226. }
  131227. }
  131228. declare module BABYLON {
  131229. /**
  131230. * Options to create the null engine
  131231. */
  131232. export class NullEngineOptions {
  131233. /**
  131234. * Render width (Default: 512)
  131235. */
  131236. renderWidth: number;
  131237. /**
  131238. * Render height (Default: 256)
  131239. */
  131240. renderHeight: number;
  131241. /**
  131242. * Texture size (Default: 512)
  131243. */
  131244. textureSize: number;
  131245. /**
  131246. * If delta time between frames should be constant
  131247. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131248. */
  131249. deterministicLockstep: boolean;
  131250. /**
  131251. * Maximum about of steps between frames (Default: 4)
  131252. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131253. */
  131254. lockstepMaxSteps: number;
  131255. /**
  131256. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  131257. */
  131258. useHighPrecisionMatrix?: boolean;
  131259. }
  131260. /**
  131261. * The null engine class provides support for headless version of babylon.js.
  131262. * This can be used in server side scenario or for testing purposes
  131263. */
  131264. export class NullEngine extends Engine {
  131265. private _options;
  131266. /**
  131267. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  131268. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131269. * @returns true if engine is in deterministic lock step mode
  131270. */
  131271. isDeterministicLockStep(): boolean;
  131272. /**
  131273. * Gets the max steps when engine is running in deterministic lock step
  131274. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131275. * @returns the max steps
  131276. */
  131277. getLockstepMaxSteps(): number;
  131278. /**
  131279. * Gets the current hardware scaling level.
  131280. * By default the hardware scaling level is computed from the window device ratio.
  131281. * 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.
  131282. * @returns a number indicating the current hardware scaling level
  131283. */
  131284. getHardwareScalingLevel(): number;
  131285. constructor(options?: NullEngineOptions);
  131286. /**
  131287. * Creates a vertex buffer
  131288. * @param vertices the data for the vertex buffer
  131289. * @returns the new WebGL static buffer
  131290. */
  131291. createVertexBuffer(vertices: FloatArray): DataBuffer;
  131292. /**
  131293. * Creates a new index buffer
  131294. * @param indices defines the content of the index buffer
  131295. * @param updatable defines if the index buffer must be updatable
  131296. * @returns a new webGL buffer
  131297. */
  131298. createIndexBuffer(indices: IndicesArray): DataBuffer;
  131299. /**
  131300. * Clear the current render buffer or the current render target (if any is set up)
  131301. * @param color defines the color to use
  131302. * @param backBuffer defines if the back buffer must be cleared
  131303. * @param depth defines if the depth buffer must be cleared
  131304. * @param stencil defines if the stencil buffer must be cleared
  131305. */
  131306. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  131307. /**
  131308. * Gets the current render width
  131309. * @param useScreen defines if screen size must be used (or the current render target if any)
  131310. * @returns a number defining the current render width
  131311. */
  131312. getRenderWidth(useScreen?: boolean): number;
  131313. /**
  131314. * Gets the current render height
  131315. * @param useScreen defines if screen size must be used (or the current render target if any)
  131316. * @returns a number defining the current render height
  131317. */
  131318. getRenderHeight(useScreen?: boolean): number;
  131319. /**
  131320. * Set the WebGL's viewport
  131321. * @param viewport defines the viewport element to be used
  131322. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  131323. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  131324. */
  131325. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  131326. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  131327. /**
  131328. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  131329. * @param pipelineContext defines the pipeline context to use
  131330. * @param uniformsNames defines the list of uniform names
  131331. * @returns an array of webGL uniform locations
  131332. */
  131333. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  131334. /**
  131335. * Gets the lsit of active attributes for a given webGL program
  131336. * @param pipelineContext defines the pipeline context to use
  131337. * @param attributesNames defines the list of attribute names to get
  131338. * @returns an array of indices indicating the offset of each attribute
  131339. */
  131340. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  131341. /**
  131342. * Binds an effect to the webGL context
  131343. * @param effect defines the effect to bind
  131344. */
  131345. bindSamplers(effect: Effect): void;
  131346. /**
  131347. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  131348. * @param effect defines the effect to activate
  131349. */
  131350. enableEffect(effect: Effect): void;
  131351. /**
  131352. * Set various states to the webGL context
  131353. * @param culling defines backface culling state
  131354. * @param zOffset defines the value to apply to zOffset (0 by default)
  131355. * @param force defines if states must be applied even if cache is up to date
  131356. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  131357. */
  131358. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  131359. /**
  131360. * Set the value of an uniform to an array of int32
  131361. * @param uniform defines the webGL uniform location where to store the value
  131362. * @param array defines the array of int32 to store
  131363. */
  131364. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  131365. /**
  131366. * Set the value of an uniform to an array of int32 (stored as vec2)
  131367. * @param uniform defines the webGL uniform location where to store the value
  131368. * @param array defines the array of int32 to store
  131369. */
  131370. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  131371. /**
  131372. * Set the value of an uniform to an array of int32 (stored as vec3)
  131373. * @param uniform defines the webGL uniform location where to store the value
  131374. * @param array defines the array of int32 to store
  131375. */
  131376. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  131377. /**
  131378. * Set the value of an uniform to an array of int32 (stored as vec4)
  131379. * @param uniform defines the webGL uniform location where to store the value
  131380. * @param array defines the array of int32 to store
  131381. */
  131382. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  131383. /**
  131384. * Set the value of an uniform to an array of float32
  131385. * @param uniform defines the webGL uniform location where to store the value
  131386. * @param array defines the array of float32 to store
  131387. */
  131388. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  131389. /**
  131390. * Set the value of an uniform to an array of float32 (stored as vec2)
  131391. * @param uniform defines the webGL uniform location where to store the value
  131392. * @param array defines the array of float32 to store
  131393. */
  131394. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  131395. /**
  131396. * Set the value of an uniform to an array of float32 (stored as vec3)
  131397. * @param uniform defines the webGL uniform location where to store the value
  131398. * @param array defines the array of float32 to store
  131399. */
  131400. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  131401. /**
  131402. * Set the value of an uniform to an array of float32 (stored as vec4)
  131403. * @param uniform defines the webGL uniform location where to store the value
  131404. * @param array defines the array of float32 to store
  131405. */
  131406. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  131407. /**
  131408. * Set the value of an uniform to an array of number
  131409. * @param uniform defines the webGL uniform location where to store the value
  131410. * @param array defines the array of number to store
  131411. */
  131412. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  131413. /**
  131414. * Set the value of an uniform to an array of number (stored as vec2)
  131415. * @param uniform defines the webGL uniform location where to store the value
  131416. * @param array defines the array of number to store
  131417. */
  131418. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  131419. /**
  131420. * Set the value of an uniform to an array of number (stored as vec3)
  131421. * @param uniform defines the webGL uniform location where to store the value
  131422. * @param array defines the array of number to store
  131423. */
  131424. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  131425. /**
  131426. * Set the value of an uniform to an array of number (stored as vec4)
  131427. * @param uniform defines the webGL uniform location where to store the value
  131428. * @param array defines the array of number to store
  131429. */
  131430. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  131431. /**
  131432. * Set the value of an uniform to an array of float32 (stored as matrices)
  131433. * @param uniform defines the webGL uniform location where to store the value
  131434. * @param matrices defines the array of float32 to store
  131435. */
  131436. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  131437. /**
  131438. * Set the value of an uniform to a matrix (3x3)
  131439. * @param uniform defines the webGL uniform location where to store the value
  131440. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  131441. */
  131442. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131443. /**
  131444. * Set the value of an uniform to a matrix (2x2)
  131445. * @param uniform defines the webGL uniform location where to store the value
  131446. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  131447. */
  131448. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131449. /**
  131450. * Set the value of an uniform to a number (float)
  131451. * @param uniform defines the webGL uniform location where to store the value
  131452. * @param value defines the float number to store
  131453. */
  131454. setFloat(uniform: WebGLUniformLocation, value: number): void;
  131455. /**
  131456. * Set the value of an uniform to a vec2
  131457. * @param uniform defines the webGL uniform location where to store the value
  131458. * @param x defines the 1st component of the value
  131459. * @param y defines the 2nd component of the value
  131460. */
  131461. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  131462. /**
  131463. * Set the value of an uniform to a vec3
  131464. * @param uniform defines the webGL uniform location where to store the value
  131465. * @param x defines the 1st component of the value
  131466. * @param y defines the 2nd component of the value
  131467. * @param z defines the 3rd component of the value
  131468. */
  131469. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  131470. /**
  131471. * Set the value of an uniform to a boolean
  131472. * @param uniform defines the webGL uniform location where to store the value
  131473. * @param bool defines the boolean to store
  131474. */
  131475. setBool(uniform: WebGLUniformLocation, bool: number): void;
  131476. /**
  131477. * Set the value of an uniform to a vec4
  131478. * @param uniform defines the webGL uniform location where to store the value
  131479. * @param x defines the 1st component of the value
  131480. * @param y defines the 2nd component of the value
  131481. * @param z defines the 3rd component of the value
  131482. * @param w defines the 4th component of the value
  131483. */
  131484. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  131485. /**
  131486. * Sets the current alpha mode
  131487. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  131488. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  131489. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131490. */
  131491. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  131492. /**
  131493. * Bind webGl buffers directly to the webGL context
  131494. * @param vertexBuffers defines the vertex buffer to bind
  131495. * @param indexBuffer defines the index buffer to bind
  131496. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  131497. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  131498. * @param effect defines the effect associated with the vertex buffer
  131499. */
  131500. bindBuffers(vertexBuffers: {
  131501. [key: string]: VertexBuffer;
  131502. }, indexBuffer: DataBuffer, effect: Effect): void;
  131503. /**
  131504. * Force the entire cache to be cleared
  131505. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  131506. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  131507. */
  131508. wipeCaches(bruteForce?: boolean): void;
  131509. /**
  131510. * Send a draw order
  131511. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  131512. * @param indexStart defines the starting index
  131513. * @param indexCount defines the number of index to draw
  131514. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131515. */
  131516. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  131517. /**
  131518. * Draw a list of indexed primitives
  131519. * @param fillMode defines the primitive to use
  131520. * @param indexStart defines the starting index
  131521. * @param indexCount defines the number of index to draw
  131522. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131523. */
  131524. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  131525. /**
  131526. * Draw a list of unindexed primitives
  131527. * @param fillMode defines the primitive to use
  131528. * @param verticesStart defines the index of first vertex to draw
  131529. * @param verticesCount defines the count of vertices to draw
  131530. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131531. */
  131532. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  131533. /** @hidden */
  131534. _createTexture(): WebGLTexture;
  131535. /** @hidden */
  131536. _releaseTexture(texture: InternalTexture): void;
  131537. /**
  131538. * Usually called from Texture.ts.
  131539. * Passed information to create a WebGLTexture
  131540. * @param urlArg defines a value which contains one of the following:
  131541. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  131542. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  131543. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  131544. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  131545. * @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)
  131546. * @param scene needed for loading to the correct scene
  131547. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  131548. * @param onLoad optional callback to be called upon successful completion
  131549. * @param onError optional callback to be called upon failure
  131550. * @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
  131551. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  131552. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  131553. * @param forcedExtension defines the extension to use to pick the right loader
  131554. * @param mimeType defines an optional mime type
  131555. * @returns a InternalTexture for assignment back into BABYLON.Texture
  131556. */
  131557. 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;
  131558. /**
  131559. * Creates a new render target texture
  131560. * @param size defines the size of the texture
  131561. * @param options defines the options used to create the texture
  131562. * @returns a new render target texture stored in an InternalTexture
  131563. */
  131564. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  131565. /**
  131566. * Update the sampling mode of a given texture
  131567. * @param samplingMode defines the required sampling mode
  131568. * @param texture defines the texture to update
  131569. */
  131570. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  131571. /**
  131572. * Binds the frame buffer to the specified texture.
  131573. * @param texture The texture to render to or null for the default canvas
  131574. * @param faceIndex The face of the texture to render to in case of cube texture
  131575. * @param requiredWidth The width of the target to render to
  131576. * @param requiredHeight The height of the target to render to
  131577. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  131578. * @param lodLevel defines le lod level to bind to the frame buffer
  131579. */
  131580. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  131581. /**
  131582. * Unbind the current render target texture from the webGL context
  131583. * @param texture defines the render target texture to unbind
  131584. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  131585. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  131586. */
  131587. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  131588. /**
  131589. * Creates a dynamic vertex buffer
  131590. * @param vertices the data for the dynamic vertex buffer
  131591. * @returns the new WebGL dynamic buffer
  131592. */
  131593. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  131594. /**
  131595. * Update the content of a dynamic texture
  131596. * @param texture defines the texture to update
  131597. * @param canvas defines the canvas containing the source
  131598. * @param invertY defines if data must be stored with Y axis inverted
  131599. * @param premulAlpha defines if alpha is stored as premultiplied
  131600. * @param format defines the format of the data
  131601. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  131602. */
  131603. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  131604. /**
  131605. * Gets a boolean indicating if all created effects are ready
  131606. * @returns true if all effects are ready
  131607. */
  131608. areAllEffectsReady(): boolean;
  131609. /**
  131610. * @hidden
  131611. * Get the current error code of the webGL context
  131612. * @returns the error code
  131613. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  131614. */
  131615. getError(): number;
  131616. /** @hidden */
  131617. _getUnpackAlignement(): number;
  131618. /** @hidden */
  131619. _unpackFlipY(value: boolean): void;
  131620. /**
  131621. * Update a dynamic index buffer
  131622. * @param indexBuffer defines the target index buffer
  131623. * @param indices defines the data to update
  131624. * @param offset defines the offset in the target index buffer where update should start
  131625. */
  131626. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  131627. /**
  131628. * Updates a dynamic vertex buffer.
  131629. * @param vertexBuffer the vertex buffer to update
  131630. * @param vertices the data used to update the vertex buffer
  131631. * @param byteOffset the byte offset of the data (optional)
  131632. * @param byteLength the byte length of the data (optional)
  131633. */
  131634. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  131635. /** @hidden */
  131636. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  131637. /** @hidden */
  131638. _bindTexture(channel: number, texture: InternalTexture): void;
  131639. protected _deleteBuffer(buffer: WebGLBuffer): void;
  131640. /**
  131641. * 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
  131642. */
  131643. releaseEffects(): void;
  131644. displayLoadingUI(): void;
  131645. hideLoadingUI(): void;
  131646. /** @hidden */
  131647. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131648. /** @hidden */
  131649. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131650. /** @hidden */
  131651. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131652. /** @hidden */
  131653. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  131654. }
  131655. }
  131656. declare module BABYLON {
  131657. /**
  131658. * @hidden
  131659. **/
  131660. export class _TimeToken {
  131661. _startTimeQuery: Nullable<WebGLQuery>;
  131662. _endTimeQuery: Nullable<WebGLQuery>;
  131663. _timeElapsedQuery: Nullable<WebGLQuery>;
  131664. _timeElapsedQueryEnded: boolean;
  131665. }
  131666. }
  131667. declare module BABYLON {
  131668. /** @hidden */
  131669. export class _OcclusionDataStorage {
  131670. /** @hidden */
  131671. occlusionInternalRetryCounter: number;
  131672. /** @hidden */
  131673. isOcclusionQueryInProgress: boolean;
  131674. /** @hidden */
  131675. isOccluded: boolean;
  131676. /** @hidden */
  131677. occlusionRetryCount: number;
  131678. /** @hidden */
  131679. occlusionType: number;
  131680. /** @hidden */
  131681. occlusionQueryAlgorithmType: number;
  131682. }
  131683. interface Engine {
  131684. /**
  131685. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  131686. * @return the new query
  131687. */
  131688. createQuery(): WebGLQuery;
  131689. /**
  131690. * Delete and release a webGL query
  131691. * @param query defines the query to delete
  131692. * @return the current engine
  131693. */
  131694. deleteQuery(query: WebGLQuery): Engine;
  131695. /**
  131696. * Check if a given query has resolved and got its value
  131697. * @param query defines the query to check
  131698. * @returns true if the query got its value
  131699. */
  131700. isQueryResultAvailable(query: WebGLQuery): boolean;
  131701. /**
  131702. * Gets the value of a given query
  131703. * @param query defines the query to check
  131704. * @returns the value of the query
  131705. */
  131706. getQueryResult(query: WebGLQuery): number;
  131707. /**
  131708. * Initiates an occlusion query
  131709. * @param algorithmType defines the algorithm to use
  131710. * @param query defines the query to use
  131711. * @returns the current engine
  131712. * @see https://doc.babylonjs.com/features/occlusionquery
  131713. */
  131714. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  131715. /**
  131716. * Ends an occlusion query
  131717. * @see https://doc.babylonjs.com/features/occlusionquery
  131718. * @param algorithmType defines the algorithm to use
  131719. * @returns the current engine
  131720. */
  131721. endOcclusionQuery(algorithmType: number): Engine;
  131722. /**
  131723. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  131724. * Please note that only one query can be issued at a time
  131725. * @returns a time token used to track the time span
  131726. */
  131727. startTimeQuery(): Nullable<_TimeToken>;
  131728. /**
  131729. * Ends a time query
  131730. * @param token defines the token used to measure the time span
  131731. * @returns the time spent (in ns)
  131732. */
  131733. endTimeQuery(token: _TimeToken): int;
  131734. /** @hidden */
  131735. _currentNonTimestampToken: Nullable<_TimeToken>;
  131736. /** @hidden */
  131737. _createTimeQuery(): WebGLQuery;
  131738. /** @hidden */
  131739. _deleteTimeQuery(query: WebGLQuery): void;
  131740. /** @hidden */
  131741. _getGlAlgorithmType(algorithmType: number): number;
  131742. /** @hidden */
  131743. _getTimeQueryResult(query: WebGLQuery): any;
  131744. /** @hidden */
  131745. _getTimeQueryAvailability(query: WebGLQuery): any;
  131746. }
  131747. interface AbstractMesh {
  131748. /**
  131749. * Backing filed
  131750. * @hidden
  131751. */
  131752. __occlusionDataStorage: _OcclusionDataStorage;
  131753. /**
  131754. * Access property
  131755. * @hidden
  131756. */
  131757. _occlusionDataStorage: _OcclusionDataStorage;
  131758. /**
  131759. * 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.
  131760. * The default value is -1 which means don't break the query and wait till the result
  131761. * @see https://doc.babylonjs.com/features/occlusionquery
  131762. */
  131763. occlusionRetryCount: number;
  131764. /**
  131765. * 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:
  131766. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  131767. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  131768. * * 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.
  131769. * @see https://doc.babylonjs.com/features/occlusionquery
  131770. */
  131771. occlusionType: number;
  131772. /**
  131773. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  131774. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  131775. * * 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.
  131776. * @see https://doc.babylonjs.com/features/occlusionquery
  131777. */
  131778. occlusionQueryAlgorithmType: number;
  131779. /**
  131780. * 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
  131781. * @see https://doc.babylonjs.com/features/occlusionquery
  131782. */
  131783. isOccluded: boolean;
  131784. /**
  131785. * Flag to check the progress status of the query
  131786. * @see https://doc.babylonjs.com/features/occlusionquery
  131787. */
  131788. isOcclusionQueryInProgress: boolean;
  131789. }
  131790. }
  131791. declare module BABYLON {
  131792. /** @hidden */
  131793. export var _forceTransformFeedbackToBundle: boolean;
  131794. interface Engine {
  131795. /**
  131796. * Creates a webGL transform feedback object
  131797. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  131798. * @returns the webGL transform feedback object
  131799. */
  131800. createTransformFeedback(): WebGLTransformFeedback;
  131801. /**
  131802. * Delete a webGL transform feedback object
  131803. * @param value defines the webGL transform feedback object to delete
  131804. */
  131805. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  131806. /**
  131807. * Bind a webGL transform feedback object to the webgl context
  131808. * @param value defines the webGL transform feedback object to bind
  131809. */
  131810. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  131811. /**
  131812. * Begins a transform feedback operation
  131813. * @param usePoints defines if points or triangles must be used
  131814. */
  131815. beginTransformFeedback(usePoints: boolean): void;
  131816. /**
  131817. * Ends a transform feedback operation
  131818. */
  131819. endTransformFeedback(): void;
  131820. /**
  131821. * Specify the varyings to use with transform feedback
  131822. * @param program defines the associated webGL program
  131823. * @param value defines the list of strings representing the varying names
  131824. */
  131825. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  131826. /**
  131827. * Bind a webGL buffer for a transform feedback operation
  131828. * @param value defines the webGL buffer to bind
  131829. */
  131830. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  131831. }
  131832. }
  131833. declare module BABYLON {
  131834. /**
  131835. * Class used to define an additional view for the engine
  131836. * @see https://doc.babylonjs.com/how_to/multi_canvases
  131837. */
  131838. export class EngineView {
  131839. /** Defines the canvas where to render the view */
  131840. target: HTMLCanvasElement;
  131841. /** Defines an optional camera used to render the view (will use active camera else) */
  131842. camera?: Camera;
  131843. }
  131844. interface Engine {
  131845. /**
  131846. * Gets or sets the HTML element to use for attaching events
  131847. */
  131848. inputElement: Nullable<HTMLElement>;
  131849. /**
  131850. * Gets the current engine view
  131851. * @see https://doc.babylonjs.com/how_to/multi_canvases
  131852. */
  131853. activeView: Nullable<EngineView>;
  131854. /** Gets or sets the list of views */
  131855. views: EngineView[];
  131856. /**
  131857. * Register a new child canvas
  131858. * @param canvas defines the canvas to register
  131859. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  131860. * @returns the associated view
  131861. */
  131862. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  131863. /**
  131864. * Remove a registered child canvas
  131865. * @param canvas defines the canvas to remove
  131866. * @returns the current engine
  131867. */
  131868. unRegisterView(canvas: HTMLCanvasElement): Engine;
  131869. }
  131870. }
  131871. declare module BABYLON {
  131872. interface Engine {
  131873. /** @hidden */
  131874. _excludedCompressedTextures: string[];
  131875. /** @hidden */
  131876. _textureFormatInUse: string;
  131877. /**
  131878. * Gets the list of texture formats supported
  131879. */
  131880. readonly texturesSupported: Array<string>;
  131881. /**
  131882. * Gets the texture format in use
  131883. */
  131884. readonly textureFormatInUse: Nullable<string>;
  131885. /**
  131886. * Set the compressed texture extensions or file names to skip.
  131887. *
  131888. * @param skippedFiles defines the list of those texture files you want to skip
  131889. * Example: [".dds", ".env", "myfile.png"]
  131890. */
  131891. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  131892. /**
  131893. * Set the compressed texture format to use, based on the formats you have, and the formats
  131894. * supported by the hardware / browser.
  131895. *
  131896. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  131897. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  131898. * to API arguments needed to compressed textures. This puts the burden on the container
  131899. * generator to house the arcane code for determining these for current & future formats.
  131900. *
  131901. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  131902. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  131903. *
  131904. * Note: The result of this call is not taken into account when a texture is base64.
  131905. *
  131906. * @param formatsAvailable defines the list of those format families you have created
  131907. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  131908. *
  131909. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  131910. * @returns The extension selected.
  131911. */
  131912. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  131913. }
  131914. }
  131915. declare module BABYLON {
  131916. /**
  131917. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  131918. */
  131919. export interface CubeMapInfo {
  131920. /**
  131921. * The pixel array for the front face.
  131922. * This is stored in format, left to right, up to down format.
  131923. */
  131924. front: Nullable<ArrayBufferView>;
  131925. /**
  131926. * The pixel array for the back face.
  131927. * This is stored in format, left to right, up to down format.
  131928. */
  131929. back: Nullable<ArrayBufferView>;
  131930. /**
  131931. * The pixel array for the left face.
  131932. * This is stored in format, left to right, up to down format.
  131933. */
  131934. left: Nullable<ArrayBufferView>;
  131935. /**
  131936. * The pixel array for the right face.
  131937. * This is stored in format, left to right, up to down format.
  131938. */
  131939. right: Nullable<ArrayBufferView>;
  131940. /**
  131941. * The pixel array for the up face.
  131942. * This is stored in format, left to right, up to down format.
  131943. */
  131944. up: Nullable<ArrayBufferView>;
  131945. /**
  131946. * The pixel array for the down face.
  131947. * This is stored in format, left to right, up to down format.
  131948. */
  131949. down: Nullable<ArrayBufferView>;
  131950. /**
  131951. * The size of the cubemap stored.
  131952. *
  131953. * Each faces will be size * size pixels.
  131954. */
  131955. size: number;
  131956. /**
  131957. * The format of the texture.
  131958. *
  131959. * RGBA, RGB.
  131960. */
  131961. format: number;
  131962. /**
  131963. * The type of the texture data.
  131964. *
  131965. * UNSIGNED_INT, FLOAT.
  131966. */
  131967. type: number;
  131968. /**
  131969. * Specifies whether the texture is in gamma space.
  131970. */
  131971. gammaSpace: boolean;
  131972. }
  131973. /**
  131974. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  131975. */
  131976. export class PanoramaToCubeMapTools {
  131977. private static FACE_LEFT;
  131978. private static FACE_RIGHT;
  131979. private static FACE_FRONT;
  131980. private static FACE_BACK;
  131981. private static FACE_DOWN;
  131982. private static FACE_UP;
  131983. /**
  131984. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  131985. *
  131986. * @param float32Array The source data.
  131987. * @param inputWidth The width of the input panorama.
  131988. * @param inputHeight The height of the input panorama.
  131989. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  131990. * @return The cubemap data
  131991. */
  131992. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  131993. private static CreateCubemapTexture;
  131994. private static CalcProjectionSpherical;
  131995. }
  131996. }
  131997. declare module BABYLON {
  131998. /**
  131999. * Helper class dealing with the extraction of spherical polynomial dataArray
  132000. * from a cube map.
  132001. */
  132002. export class CubeMapToSphericalPolynomialTools {
  132003. private static FileFaces;
  132004. /**
  132005. * Converts a texture to the according Spherical Polynomial data.
  132006. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132007. *
  132008. * @param texture The texture to extract the information from.
  132009. * @return The Spherical Polynomial data.
  132010. */
  132011. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  132012. /**
  132013. * Converts a cubemap to the according Spherical Polynomial data.
  132014. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132015. *
  132016. * @param cubeInfo The Cube map to extract the information from.
  132017. * @return The Spherical Polynomial data.
  132018. */
  132019. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  132020. }
  132021. }
  132022. declare module BABYLON {
  132023. interface BaseTexture {
  132024. /**
  132025. * Get the polynomial representation of the texture data.
  132026. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  132027. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  132028. */
  132029. sphericalPolynomial: Nullable<SphericalPolynomial>;
  132030. }
  132031. }
  132032. declare module BABYLON {
  132033. /** @hidden */
  132034. export var rgbdEncodePixelShader: {
  132035. name: string;
  132036. shader: string;
  132037. };
  132038. }
  132039. declare module BABYLON {
  132040. /** @hidden */
  132041. export var rgbdDecodePixelShader: {
  132042. name: string;
  132043. shader: string;
  132044. };
  132045. }
  132046. declare module BABYLON {
  132047. /**
  132048. * Raw texture data and descriptor sufficient for WebGL texture upload
  132049. */
  132050. export interface EnvironmentTextureInfo {
  132051. /**
  132052. * Version of the environment map
  132053. */
  132054. version: number;
  132055. /**
  132056. * Width of image
  132057. */
  132058. width: number;
  132059. /**
  132060. * Irradiance information stored in the file.
  132061. */
  132062. irradiance: any;
  132063. /**
  132064. * Specular information stored in the file.
  132065. */
  132066. specular: any;
  132067. }
  132068. /**
  132069. * Defines One Image in the file. It requires only the position in the file
  132070. * as well as the length.
  132071. */
  132072. interface BufferImageData {
  132073. /**
  132074. * Length of the image data.
  132075. */
  132076. length: number;
  132077. /**
  132078. * Position of the data from the null terminator delimiting the end of the JSON.
  132079. */
  132080. position: number;
  132081. }
  132082. /**
  132083. * Defines the specular data enclosed in the file.
  132084. * This corresponds to the version 1 of the data.
  132085. */
  132086. export interface EnvironmentTextureSpecularInfoV1 {
  132087. /**
  132088. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  132089. */
  132090. specularDataPosition?: number;
  132091. /**
  132092. * This contains all the images data needed to reconstruct the cubemap.
  132093. */
  132094. mipmaps: Array<BufferImageData>;
  132095. /**
  132096. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  132097. */
  132098. lodGenerationScale: number;
  132099. }
  132100. /**
  132101. * Sets of helpers addressing the serialization and deserialization of environment texture
  132102. * stored in a BabylonJS env file.
  132103. * Those files are usually stored as .env files.
  132104. */
  132105. export class EnvironmentTextureTools {
  132106. /**
  132107. * Magic number identifying the env file.
  132108. */
  132109. private static _MagicBytes;
  132110. /**
  132111. * Gets the environment info from an env file.
  132112. * @param data The array buffer containing the .env bytes.
  132113. * @returns the environment file info (the json header) if successfully parsed.
  132114. */
  132115. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  132116. /**
  132117. * Creates an environment texture from a loaded cube texture.
  132118. * @param texture defines the cube texture to convert in env file
  132119. * @return a promise containing the environment data if succesfull.
  132120. */
  132121. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  132122. /**
  132123. * Creates a JSON representation of the spherical data.
  132124. * @param texture defines the texture containing the polynomials
  132125. * @return the JSON representation of the spherical info
  132126. */
  132127. private static _CreateEnvTextureIrradiance;
  132128. /**
  132129. * Creates the ArrayBufferViews used for initializing environment texture image data.
  132130. * @param data the image data
  132131. * @param info parameters that determine what views will be created for accessing the underlying buffer
  132132. * @return the views described by info providing access to the underlying buffer
  132133. */
  132134. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  132135. /**
  132136. * Uploads the texture info contained in the env file to the GPU.
  132137. * @param texture defines the internal texture to upload to
  132138. * @param data defines the data to load
  132139. * @param info defines the texture info retrieved through the GetEnvInfo method
  132140. * @returns a promise
  132141. */
  132142. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  132143. private static _OnImageReadyAsync;
  132144. /**
  132145. * Uploads the levels of image data to the GPU.
  132146. * @param texture defines the internal texture to upload to
  132147. * @param imageData defines the array buffer views of image data [mipmap][face]
  132148. * @returns a promise
  132149. */
  132150. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  132151. /**
  132152. * Uploads spherical polynomials information to the texture.
  132153. * @param texture defines the texture we are trying to upload the information to
  132154. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  132155. */
  132156. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  132157. /** @hidden */
  132158. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  132159. }
  132160. }
  132161. declare module BABYLON {
  132162. /**
  132163. * Class used to inline functions in shader code
  132164. */
  132165. export class ShaderCodeInliner {
  132166. private static readonly _RegexpFindFunctionNameAndType;
  132167. private _sourceCode;
  132168. private _functionDescr;
  132169. private _numMaxIterations;
  132170. /** Gets or sets the token used to mark the functions to inline */
  132171. inlineToken: string;
  132172. /** Gets or sets the debug mode */
  132173. debug: boolean;
  132174. /** Gets the code after the inlining process */
  132175. get code(): string;
  132176. /**
  132177. * Initializes the inliner
  132178. * @param sourceCode shader code source to inline
  132179. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  132180. */
  132181. constructor(sourceCode: string, numMaxIterations?: number);
  132182. /**
  132183. * Start the processing of the shader code
  132184. */
  132185. processCode(): void;
  132186. private _collectFunctions;
  132187. private _processInlining;
  132188. private _extractBetweenMarkers;
  132189. private _skipWhitespaces;
  132190. private _removeComments;
  132191. private _replaceFunctionCallsByCode;
  132192. private _findBackward;
  132193. private _escapeRegExp;
  132194. private _replaceNames;
  132195. }
  132196. }
  132197. declare module BABYLON {
  132198. /**
  132199. * Container for accessors for natively-stored mesh data buffers.
  132200. */
  132201. class NativeDataBuffer extends DataBuffer {
  132202. /**
  132203. * Accessor value used to identify/retrieve a natively-stored index buffer.
  132204. */
  132205. nativeIndexBuffer?: any;
  132206. /**
  132207. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  132208. */
  132209. nativeVertexBuffer?: any;
  132210. }
  132211. /** @hidden */
  132212. class NativeTexture extends InternalTexture {
  132213. getInternalTexture(): InternalTexture;
  132214. getViewCount(): number;
  132215. }
  132216. /** @hidden */
  132217. export class NativeEngine extends Engine {
  132218. private readonly _native;
  132219. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  132220. private readonly INVALID_HANDLE;
  132221. private _boundBuffersVertexArray;
  132222. getHardwareScalingLevel(): number;
  132223. constructor();
  132224. dispose(): void;
  132225. /**
  132226. * Can be used to override the current requestAnimationFrame requester.
  132227. * @hidden
  132228. */
  132229. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  132230. /**
  132231. * Override default engine behavior.
  132232. * @param color
  132233. * @param backBuffer
  132234. * @param depth
  132235. * @param stencil
  132236. */
  132237. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  132238. /**
  132239. * Gets host document
  132240. * @returns the host document object
  132241. */
  132242. getHostDocument(): Nullable<Document>;
  132243. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  132244. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  132245. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  132246. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  132247. [key: string]: VertexBuffer;
  132248. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  132249. bindBuffers(vertexBuffers: {
  132250. [key: string]: VertexBuffer;
  132251. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  132252. recordVertexArrayObject(vertexBuffers: {
  132253. [key: string]: VertexBuffer;
  132254. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  132255. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  132256. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  132257. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  132258. /**
  132259. * Draw a list of indexed primitives
  132260. * @param fillMode defines the primitive to use
  132261. * @param indexStart defines the starting index
  132262. * @param indexCount defines the number of index to draw
  132263. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132264. */
  132265. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132266. /**
  132267. * Draw a list of unindexed primitives
  132268. * @param fillMode defines the primitive to use
  132269. * @param verticesStart defines the index of first vertex to draw
  132270. * @param verticesCount defines the count of vertices to draw
  132271. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132272. */
  132273. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132274. createPipelineContext(): IPipelineContext;
  132275. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  132276. /** @hidden */
  132277. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  132278. /** @hidden */
  132279. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  132280. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  132281. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  132282. protected _setProgram(program: WebGLProgram): void;
  132283. _releaseEffect(effect: Effect): void;
  132284. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  132285. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  132286. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  132287. bindSamplers(effect: Effect): void;
  132288. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  132289. getRenderWidth(useScreen?: boolean): number;
  132290. getRenderHeight(useScreen?: boolean): number;
  132291. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  132292. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  132293. /**
  132294. * Set the z offset to apply to current rendering
  132295. * @param value defines the offset to apply
  132296. */
  132297. setZOffset(value: number): void;
  132298. /**
  132299. * Gets the current value of the zOffset
  132300. * @returns the current zOffset state
  132301. */
  132302. getZOffset(): number;
  132303. /**
  132304. * Enable or disable depth buffering
  132305. * @param enable defines the state to set
  132306. */
  132307. setDepthBuffer(enable: boolean): void;
  132308. /**
  132309. * Gets a boolean indicating if depth writing is enabled
  132310. * @returns the current depth writing state
  132311. */
  132312. getDepthWrite(): boolean;
  132313. /**
  132314. * Enable or disable depth writing
  132315. * @param enable defines the state to set
  132316. */
  132317. setDepthWrite(enable: boolean): void;
  132318. /**
  132319. * Enable or disable color writing
  132320. * @param enable defines the state to set
  132321. */
  132322. setColorWrite(enable: boolean): void;
  132323. /**
  132324. * Gets a boolean indicating if color writing is enabled
  132325. * @returns the current color writing state
  132326. */
  132327. getColorWrite(): boolean;
  132328. /**
  132329. * Sets alpha constants used by some alpha blending modes
  132330. * @param r defines the red component
  132331. * @param g defines the green component
  132332. * @param b defines the blue component
  132333. * @param a defines the alpha component
  132334. */
  132335. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  132336. /**
  132337. * Sets the current alpha mode
  132338. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  132339. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132340. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132341. */
  132342. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132343. /**
  132344. * Gets the current alpha mode
  132345. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132346. * @returns the current alpha mode
  132347. */
  132348. getAlphaMode(): number;
  132349. setInt(uniform: WebGLUniformLocation, int: number): void;
  132350. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  132351. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  132352. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  132353. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  132354. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  132355. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  132356. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  132357. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  132358. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  132359. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  132360. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  132361. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  132362. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  132363. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  132364. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  132365. setFloat(uniform: WebGLUniformLocation, value: number): void;
  132366. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  132367. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  132368. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  132369. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  132370. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  132371. wipeCaches(bruteForce?: boolean): void;
  132372. _createTexture(): WebGLTexture;
  132373. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  132374. /**
  132375. * Usually called from Texture.ts.
  132376. * Passed information to create a WebGLTexture
  132377. * @param url defines a value which contains one of the following:
  132378. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132379. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132380. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132381. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132382. * @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)
  132383. * @param scene needed for loading to the correct scene
  132384. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132385. * @param onLoad optional callback to be called upon successful completion
  132386. * @param onError optional callback to be called upon failure
  132387. * @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
  132388. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132389. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132390. * @param forcedExtension defines the extension to use to pick the right loader
  132391. * @param mimeType defines an optional mime type
  132392. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132393. */
  132394. 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;
  132395. /**
  132396. * Creates a cube texture
  132397. * @param rootUrl defines the url where the files to load is located
  132398. * @param scene defines the current scene
  132399. * @param files defines the list of files to load (1 per face)
  132400. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  132401. * @param onLoad defines an optional callback raised when the texture is loaded
  132402. * @param onError defines an optional callback raised if there is an issue to load the texture
  132403. * @param format defines the format of the data
  132404. * @param forcedExtension defines the extension to use to pick the right loader
  132405. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  132406. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  132407. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  132408. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  132409. * @returns the cube texture as an InternalTexture
  132410. */
  132411. 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;
  132412. private _getSamplingFilter;
  132413. private static _GetNativeTextureFormat;
  132414. createRenderTargetTexture(size: number | {
  132415. width: number;
  132416. height: number;
  132417. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  132418. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132419. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132420. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132421. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  132422. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  132423. /**
  132424. * Updates a dynamic vertex buffer.
  132425. * @param vertexBuffer the vertex buffer to update
  132426. * @param data the data used to update the vertex buffer
  132427. * @param byteOffset the byte offset of the data (optional)
  132428. * @param byteLength the byte length of the data (optional)
  132429. */
  132430. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  132431. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  132432. private _updateAnisotropicLevel;
  132433. private _getAddressMode;
  132434. /** @hidden */
  132435. _bindTexture(channel: number, texture: InternalTexture): void;
  132436. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  132437. releaseEffects(): void;
  132438. /** @hidden */
  132439. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132440. /** @hidden */
  132441. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132442. /** @hidden */
  132443. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132444. /** @hidden */
  132445. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132446. }
  132447. }
  132448. declare module BABYLON {
  132449. /**
  132450. * Gather the list of clipboard event types as constants.
  132451. */
  132452. export class ClipboardEventTypes {
  132453. /**
  132454. * The clipboard event is fired when a copy command is active (pressed).
  132455. */
  132456. static readonly COPY: number;
  132457. /**
  132458. * The clipboard event is fired when a cut command is active (pressed).
  132459. */
  132460. static readonly CUT: number;
  132461. /**
  132462. * The clipboard event is fired when a paste command is active (pressed).
  132463. */
  132464. static readonly PASTE: number;
  132465. }
  132466. /**
  132467. * This class is used to store clipboard related info for the onClipboardObservable event.
  132468. */
  132469. export class ClipboardInfo {
  132470. /**
  132471. * Defines the type of event (BABYLON.ClipboardEventTypes)
  132472. */
  132473. type: number;
  132474. /**
  132475. * Defines the related dom event
  132476. */
  132477. event: ClipboardEvent;
  132478. /**
  132479. *Creates an instance of ClipboardInfo.
  132480. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  132481. * @param event Defines the related dom event
  132482. */
  132483. constructor(
  132484. /**
  132485. * Defines the type of event (BABYLON.ClipboardEventTypes)
  132486. */
  132487. type: number,
  132488. /**
  132489. * Defines the related dom event
  132490. */
  132491. event: ClipboardEvent);
  132492. /**
  132493. * Get the clipboard event's type from the keycode.
  132494. * @param keyCode Defines the keyCode for the current keyboard event.
  132495. * @return {number}
  132496. */
  132497. static GetTypeFromCharacter(keyCode: number): number;
  132498. }
  132499. }
  132500. declare module BABYLON {
  132501. /**
  132502. * Google Daydream controller
  132503. */
  132504. export class DaydreamController extends WebVRController {
  132505. /**
  132506. * Base Url for the controller model.
  132507. */
  132508. static MODEL_BASE_URL: string;
  132509. /**
  132510. * File name for the controller model.
  132511. */
  132512. static MODEL_FILENAME: string;
  132513. /**
  132514. * Gamepad Id prefix used to identify Daydream Controller.
  132515. */
  132516. static readonly GAMEPAD_ID_PREFIX: string;
  132517. /**
  132518. * Creates a new DaydreamController from a gamepad
  132519. * @param vrGamepad the gamepad that the controller should be created from
  132520. */
  132521. constructor(vrGamepad: any);
  132522. /**
  132523. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132524. * @param scene scene in which to add meshes
  132525. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132526. */
  132527. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132528. /**
  132529. * Called once for each button that changed state since the last frame
  132530. * @param buttonIdx Which button index changed
  132531. * @param state New state of the button
  132532. * @param changes Which properties on the state changed since last frame
  132533. */
  132534. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132535. }
  132536. }
  132537. declare module BABYLON {
  132538. /**
  132539. * Gear VR Controller
  132540. */
  132541. export class GearVRController extends WebVRController {
  132542. /**
  132543. * Base Url for the controller model.
  132544. */
  132545. static MODEL_BASE_URL: string;
  132546. /**
  132547. * File name for the controller model.
  132548. */
  132549. static MODEL_FILENAME: string;
  132550. /**
  132551. * Gamepad Id prefix used to identify this controller.
  132552. */
  132553. static readonly GAMEPAD_ID_PREFIX: string;
  132554. private readonly _buttonIndexToObservableNameMap;
  132555. /**
  132556. * Creates a new GearVRController from a gamepad
  132557. * @param vrGamepad the gamepad that the controller should be created from
  132558. */
  132559. constructor(vrGamepad: any);
  132560. /**
  132561. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132562. * @param scene scene in which to add meshes
  132563. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132564. */
  132565. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132566. /**
  132567. * Called once for each button that changed state since the last frame
  132568. * @param buttonIdx Which button index changed
  132569. * @param state New state of the button
  132570. * @param changes Which properties on the state changed since last frame
  132571. */
  132572. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132573. }
  132574. }
  132575. declare module BABYLON {
  132576. /**
  132577. * Generic Controller
  132578. */
  132579. export class GenericController extends WebVRController {
  132580. /**
  132581. * Base Url for the controller model.
  132582. */
  132583. static readonly MODEL_BASE_URL: string;
  132584. /**
  132585. * File name for the controller model.
  132586. */
  132587. static readonly MODEL_FILENAME: string;
  132588. /**
  132589. * Creates a new GenericController from a gamepad
  132590. * @param vrGamepad the gamepad that the controller should be created from
  132591. */
  132592. constructor(vrGamepad: any);
  132593. /**
  132594. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132595. * @param scene scene in which to add meshes
  132596. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132597. */
  132598. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132599. /**
  132600. * Called once for each button that changed state since the last frame
  132601. * @param buttonIdx Which button index changed
  132602. * @param state New state of the button
  132603. * @param changes Which properties on the state changed since last frame
  132604. */
  132605. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132606. }
  132607. }
  132608. declare module BABYLON {
  132609. /**
  132610. * Oculus Touch Controller
  132611. */
  132612. export class OculusTouchController extends WebVRController {
  132613. /**
  132614. * Base Url for the controller model.
  132615. */
  132616. static MODEL_BASE_URL: string;
  132617. /**
  132618. * File name for the left controller model.
  132619. */
  132620. static MODEL_LEFT_FILENAME: string;
  132621. /**
  132622. * File name for the right controller model.
  132623. */
  132624. static MODEL_RIGHT_FILENAME: string;
  132625. /**
  132626. * Base Url for the Quest controller model.
  132627. */
  132628. static QUEST_MODEL_BASE_URL: string;
  132629. /**
  132630. * @hidden
  132631. * If the controllers are running on a device that needs the updated Quest controller models
  132632. */
  132633. static _IsQuest: boolean;
  132634. /**
  132635. * Fired when the secondary trigger on this controller is modified
  132636. */
  132637. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  132638. /**
  132639. * Fired when the thumb rest on this controller is modified
  132640. */
  132641. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  132642. /**
  132643. * Creates a new OculusTouchController from a gamepad
  132644. * @param vrGamepad the gamepad that the controller should be created from
  132645. */
  132646. constructor(vrGamepad: any);
  132647. /**
  132648. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132649. * @param scene scene in which to add meshes
  132650. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132651. */
  132652. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132653. /**
  132654. * Fired when the A button on this controller is modified
  132655. */
  132656. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132657. /**
  132658. * Fired when the B button on this controller is modified
  132659. */
  132660. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132661. /**
  132662. * Fired when the X button on this controller is modified
  132663. */
  132664. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132665. /**
  132666. * Fired when the Y button on this controller is modified
  132667. */
  132668. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132669. /**
  132670. * Called once for each button that changed state since the last frame
  132671. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  132672. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  132673. * 2) secondary trigger (same)
  132674. * 3) A (right) X (left), touch, pressed = value
  132675. * 4) B / Y
  132676. * 5) thumb rest
  132677. * @param buttonIdx Which button index changed
  132678. * @param state New state of the button
  132679. * @param changes Which properties on the state changed since last frame
  132680. */
  132681. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132682. }
  132683. }
  132684. declare module BABYLON {
  132685. /**
  132686. * Vive Controller
  132687. */
  132688. export class ViveController extends WebVRController {
  132689. /**
  132690. * Base Url for the controller model.
  132691. */
  132692. static MODEL_BASE_URL: string;
  132693. /**
  132694. * File name for the controller model.
  132695. */
  132696. static MODEL_FILENAME: string;
  132697. /**
  132698. * Creates a new ViveController from a gamepad
  132699. * @param vrGamepad the gamepad that the controller should be created from
  132700. */
  132701. constructor(vrGamepad: any);
  132702. /**
  132703. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132704. * @param scene scene in which to add meshes
  132705. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132706. */
  132707. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132708. /**
  132709. * Fired when the left button on this controller is modified
  132710. */
  132711. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132712. /**
  132713. * Fired when the right button on this controller is modified
  132714. */
  132715. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132716. /**
  132717. * Fired when the menu button on this controller is modified
  132718. */
  132719. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132720. /**
  132721. * Called once for each button that changed state since the last frame
  132722. * Vive mapping:
  132723. * 0: touchpad
  132724. * 1: trigger
  132725. * 2: left AND right buttons
  132726. * 3: menu button
  132727. * @param buttonIdx Which button index changed
  132728. * @param state New state of the button
  132729. * @param changes Which properties on the state changed since last frame
  132730. */
  132731. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132732. }
  132733. }
  132734. declare module BABYLON {
  132735. /**
  132736. * Defines the WindowsMotionController object that the state of the windows motion controller
  132737. */
  132738. export class WindowsMotionController extends WebVRController {
  132739. /**
  132740. * The base url used to load the left and right controller models
  132741. */
  132742. static MODEL_BASE_URL: string;
  132743. /**
  132744. * The name of the left controller model file
  132745. */
  132746. static MODEL_LEFT_FILENAME: string;
  132747. /**
  132748. * The name of the right controller model file
  132749. */
  132750. static MODEL_RIGHT_FILENAME: string;
  132751. /**
  132752. * The controller name prefix for this controller type
  132753. */
  132754. static readonly GAMEPAD_ID_PREFIX: string;
  132755. /**
  132756. * The controller id pattern for this controller type
  132757. */
  132758. private static readonly GAMEPAD_ID_PATTERN;
  132759. private _loadedMeshInfo;
  132760. protected readonly _mapping: {
  132761. buttons: string[];
  132762. buttonMeshNames: {
  132763. trigger: string;
  132764. menu: string;
  132765. grip: string;
  132766. thumbstick: string;
  132767. trackpad: string;
  132768. };
  132769. buttonObservableNames: {
  132770. trigger: string;
  132771. menu: string;
  132772. grip: string;
  132773. thumbstick: string;
  132774. trackpad: string;
  132775. };
  132776. axisMeshNames: string[];
  132777. pointingPoseMeshName: string;
  132778. };
  132779. /**
  132780. * Fired when the trackpad on this controller is clicked
  132781. */
  132782. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  132783. /**
  132784. * Fired when the trackpad on this controller is modified
  132785. */
  132786. onTrackpadValuesChangedObservable: Observable<StickValues>;
  132787. /**
  132788. * The current x and y values of this controller's trackpad
  132789. */
  132790. trackpad: StickValues;
  132791. /**
  132792. * Creates a new WindowsMotionController from a gamepad
  132793. * @param vrGamepad the gamepad that the controller should be created from
  132794. */
  132795. constructor(vrGamepad: any);
  132796. /**
  132797. * Fired when the trigger on this controller is modified
  132798. */
  132799. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132800. /**
  132801. * Fired when the menu button on this controller is modified
  132802. */
  132803. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132804. /**
  132805. * Fired when the grip button on this controller is modified
  132806. */
  132807. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132808. /**
  132809. * Fired when the thumbstick button on this controller is modified
  132810. */
  132811. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132812. /**
  132813. * Fired when the touchpad button on this controller is modified
  132814. */
  132815. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132816. /**
  132817. * Fired when the touchpad values on this controller are modified
  132818. */
  132819. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  132820. protected _updateTrackpad(): void;
  132821. /**
  132822. * Called once per frame by the engine.
  132823. */
  132824. update(): void;
  132825. /**
  132826. * Called once for each button that changed state since the last frame
  132827. * @param buttonIdx Which button index changed
  132828. * @param state New state of the button
  132829. * @param changes Which properties on the state changed since last frame
  132830. */
  132831. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132832. /**
  132833. * Moves the buttons on the controller mesh based on their current state
  132834. * @param buttonName the name of the button to move
  132835. * @param buttonValue the value of the button which determines the buttons new position
  132836. */
  132837. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  132838. /**
  132839. * Moves the axis on the controller mesh based on its current state
  132840. * @param axis the index of the axis
  132841. * @param axisValue the value of the axis which determines the meshes new position
  132842. * @hidden
  132843. */
  132844. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  132845. /**
  132846. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132847. * @param scene scene in which to add meshes
  132848. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132849. */
  132850. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  132851. /**
  132852. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  132853. * can be transformed by button presses and axes values, based on this._mapping.
  132854. *
  132855. * @param scene scene in which the meshes exist
  132856. * @param meshes list of meshes that make up the controller model to process
  132857. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  132858. */
  132859. private processModel;
  132860. private createMeshInfo;
  132861. /**
  132862. * Gets the ray of the controller in the direction the controller is pointing
  132863. * @param length the length the resulting ray should be
  132864. * @returns a ray in the direction the controller is pointing
  132865. */
  132866. getForwardRay(length?: number): Ray;
  132867. /**
  132868. * Disposes of the controller
  132869. */
  132870. dispose(): void;
  132871. }
  132872. /**
  132873. * This class represents a new windows motion controller in XR.
  132874. */
  132875. export class XRWindowsMotionController extends WindowsMotionController {
  132876. /**
  132877. * Changing the original WIndowsMotionController mapping to fir the new mapping
  132878. */
  132879. protected readonly _mapping: {
  132880. buttons: string[];
  132881. buttonMeshNames: {
  132882. trigger: string;
  132883. menu: string;
  132884. grip: string;
  132885. thumbstick: string;
  132886. trackpad: string;
  132887. };
  132888. buttonObservableNames: {
  132889. trigger: string;
  132890. menu: string;
  132891. grip: string;
  132892. thumbstick: string;
  132893. trackpad: string;
  132894. };
  132895. axisMeshNames: string[];
  132896. pointingPoseMeshName: string;
  132897. };
  132898. /**
  132899. * Construct a new XR-Based windows motion controller
  132900. *
  132901. * @param gamepadInfo the gamepad object from the browser
  132902. */
  132903. constructor(gamepadInfo: any);
  132904. /**
  132905. * holds the thumbstick values (X,Y)
  132906. */
  132907. thumbstickValues: StickValues;
  132908. /**
  132909. * Fired when the thumbstick on this controller is clicked
  132910. */
  132911. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  132912. /**
  132913. * Fired when the thumbstick on this controller is modified
  132914. */
  132915. onThumbstickValuesChangedObservable: Observable<StickValues>;
  132916. /**
  132917. * Fired when the touchpad button on this controller is modified
  132918. */
  132919. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  132920. /**
  132921. * Fired when the touchpad values on this controller are modified
  132922. */
  132923. onTrackpadValuesChangedObservable: Observable<StickValues>;
  132924. /**
  132925. * Fired when the thumbstick button on this controller is modified
  132926. * here to prevent breaking changes
  132927. */
  132928. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132929. /**
  132930. * updating the thumbstick(!) and not the trackpad.
  132931. * This is named this way due to the difference between WebVR and XR and to avoid
  132932. * changing the parent class.
  132933. */
  132934. protected _updateTrackpad(): void;
  132935. /**
  132936. * Disposes the class with joy
  132937. */
  132938. dispose(): void;
  132939. }
  132940. }
  132941. declare module BABYLON {
  132942. /**
  132943. * Class containing static functions to help procedurally build meshes
  132944. */
  132945. export class PolyhedronBuilder {
  132946. /**
  132947. * Creates a polyhedron mesh
  132948. * * 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
  132949. * * The parameter `size` (positive float, default 1) sets the polygon size
  132950. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  132951. * * 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`
  132952. * * 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
  132953. * * 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)`)
  132954. * * 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
  132955. * * 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
  132956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132957. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132959. * @param name defines the name of the mesh
  132960. * @param options defines the options used to create the mesh
  132961. * @param scene defines the hosting scene
  132962. * @returns the polyhedron mesh
  132963. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  132964. */
  132965. static CreatePolyhedron(name: string, options: {
  132966. type?: number;
  132967. size?: number;
  132968. sizeX?: number;
  132969. sizeY?: number;
  132970. sizeZ?: number;
  132971. custom?: any;
  132972. faceUV?: Vector4[];
  132973. faceColors?: Color4[];
  132974. flat?: boolean;
  132975. updatable?: boolean;
  132976. sideOrientation?: number;
  132977. frontUVs?: Vector4;
  132978. backUVs?: Vector4;
  132979. }, scene?: Nullable<Scene>): Mesh;
  132980. }
  132981. }
  132982. declare module BABYLON {
  132983. /**
  132984. * Gizmo that enables scaling a mesh along 3 axis
  132985. */
  132986. export class ScaleGizmo extends Gizmo {
  132987. /**
  132988. * Internal gizmo used for interactions on the x axis
  132989. */
  132990. xGizmo: AxisScaleGizmo;
  132991. /**
  132992. * Internal gizmo used for interactions on the y axis
  132993. */
  132994. yGizmo: AxisScaleGizmo;
  132995. /**
  132996. * Internal gizmo used for interactions on the z axis
  132997. */
  132998. zGizmo: AxisScaleGizmo;
  132999. /**
  133000. * Internal gizmo used to scale all axis equally
  133001. */
  133002. uniformScaleGizmo: AxisScaleGizmo;
  133003. private _meshAttached;
  133004. private _nodeAttached;
  133005. private _updateGizmoRotationToMatchAttachedMesh;
  133006. private _snapDistance;
  133007. private _scaleRatio;
  133008. private _uniformScalingMesh;
  133009. private _octahedron;
  133010. private _sensitivity;
  133011. /** Fires an event when any of it's sub gizmos are dragged */
  133012. onDragStartObservable: Observable<unknown>;
  133013. /** Fires an event when any of it's sub gizmos are released from dragging */
  133014. onDragEndObservable: Observable<unknown>;
  133015. get attachedMesh(): Nullable<AbstractMesh>;
  133016. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133017. get attachedNode(): Nullable<Node>;
  133018. set attachedNode(node: Nullable<Node>);
  133019. /**
  133020. * Creates a ScaleGizmo
  133021. * @param gizmoLayer The utility layer the gizmo will be added to
  133022. * @param thickness display gizmo axis thickness
  133023. */
  133024. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  133025. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133026. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133027. /**
  133028. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133029. */
  133030. set snapDistance(value: number);
  133031. get snapDistance(): number;
  133032. /**
  133033. * Ratio for the scale of the gizmo (Default: 1)
  133034. */
  133035. set scaleRatio(value: number);
  133036. get scaleRatio(): number;
  133037. /**
  133038. * Sensitivity factor for dragging (Default: 1)
  133039. */
  133040. set sensitivity(value: number);
  133041. get sensitivity(): number;
  133042. /**
  133043. * Disposes of the gizmo
  133044. */
  133045. dispose(): void;
  133046. }
  133047. }
  133048. declare module BABYLON {
  133049. /**
  133050. * Single axis scale gizmo
  133051. */
  133052. export class AxisScaleGizmo extends Gizmo {
  133053. /**
  133054. * Drag behavior responsible for the gizmos dragging interactions
  133055. */
  133056. dragBehavior: PointerDragBehavior;
  133057. private _pointerObserver;
  133058. /**
  133059. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133060. */
  133061. snapDistance: number;
  133062. /**
  133063. * Event that fires each time the gizmo snaps to a new location.
  133064. * * snapDistance is the the change in distance
  133065. */
  133066. onSnapObservable: Observable<{
  133067. snapDistance: number;
  133068. }>;
  133069. /**
  133070. * If the scaling operation should be done on all axis (default: false)
  133071. */
  133072. uniformScaling: boolean;
  133073. /**
  133074. * Custom sensitivity value for the drag strength
  133075. */
  133076. sensitivity: number;
  133077. private _isEnabled;
  133078. private _parent;
  133079. private _arrow;
  133080. private _coloredMaterial;
  133081. private _hoverMaterial;
  133082. /**
  133083. * Creates an AxisScaleGizmo
  133084. * @param gizmoLayer The utility layer the gizmo will be added to
  133085. * @param dragAxis The axis which the gizmo will be able to scale on
  133086. * @param color The color of the gizmo
  133087. * @param thickness display gizmo axis thickness
  133088. */
  133089. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  133090. protected _attachedNodeChanged(value: Nullable<Node>): void;
  133091. /**
  133092. * If the gizmo is enabled
  133093. */
  133094. set isEnabled(value: boolean);
  133095. get isEnabled(): boolean;
  133096. /**
  133097. * Disposes of the gizmo
  133098. */
  133099. dispose(): void;
  133100. /**
  133101. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  133102. * @param mesh The mesh to replace the default mesh of the gizmo
  133103. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  133104. */
  133105. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  133106. }
  133107. }
  133108. declare module BABYLON {
  133109. /**
  133110. * Bounding box gizmo
  133111. */
  133112. export class BoundingBoxGizmo extends Gizmo {
  133113. private _lineBoundingBox;
  133114. private _rotateSpheresParent;
  133115. private _scaleBoxesParent;
  133116. private _boundingDimensions;
  133117. private _renderObserver;
  133118. private _pointerObserver;
  133119. private _scaleDragSpeed;
  133120. private _tmpQuaternion;
  133121. private _tmpVector;
  133122. private _tmpRotationMatrix;
  133123. /**
  133124. * 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)
  133125. */
  133126. ignoreChildren: boolean;
  133127. /**
  133128. * 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)
  133129. */
  133130. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  133131. /**
  133132. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  133133. */
  133134. rotationSphereSize: number;
  133135. /**
  133136. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  133137. */
  133138. scaleBoxSize: number;
  133139. /**
  133140. * 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)
  133141. */
  133142. fixedDragMeshScreenSize: boolean;
  133143. /**
  133144. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  133145. */
  133146. fixedDragMeshScreenSizeDistanceFactor: number;
  133147. /**
  133148. * Fired when a rotation sphere or scale box is dragged
  133149. */
  133150. onDragStartObservable: Observable<{}>;
  133151. /**
  133152. * Fired when a scale box is dragged
  133153. */
  133154. onScaleBoxDragObservable: Observable<{}>;
  133155. /**
  133156. * Fired when a scale box drag is ended
  133157. */
  133158. onScaleBoxDragEndObservable: Observable<{}>;
  133159. /**
  133160. * Fired when a rotation sphere is dragged
  133161. */
  133162. onRotationSphereDragObservable: Observable<{}>;
  133163. /**
  133164. * Fired when a rotation sphere drag is ended
  133165. */
  133166. onRotationSphereDragEndObservable: Observable<{}>;
  133167. /**
  133168. * 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)
  133169. */
  133170. scalePivot: Nullable<Vector3>;
  133171. /**
  133172. * Mesh used as a pivot to rotate the attached node
  133173. */
  133174. private _anchorMesh;
  133175. private _existingMeshScale;
  133176. private _dragMesh;
  133177. private pointerDragBehavior;
  133178. private coloredMaterial;
  133179. private hoverColoredMaterial;
  133180. /**
  133181. * Sets the color of the bounding box gizmo
  133182. * @param color the color to set
  133183. */
  133184. setColor(color: Color3): void;
  133185. /**
  133186. * Creates an BoundingBoxGizmo
  133187. * @param gizmoLayer The utility layer the gizmo will be added to
  133188. * @param color The color of the gizmo
  133189. */
  133190. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  133191. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  133192. private _selectNode;
  133193. /**
  133194. * Updates the bounding box information for the Gizmo
  133195. */
  133196. updateBoundingBox(): void;
  133197. private _updateRotationSpheres;
  133198. private _updateScaleBoxes;
  133199. /**
  133200. * Enables rotation on the specified axis and disables rotation on the others
  133201. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  133202. */
  133203. setEnabledRotationAxis(axis: string): void;
  133204. /**
  133205. * Enables/disables scaling
  133206. * @param enable if scaling should be enabled
  133207. * @param homogeneousScaling defines if scaling should only be homogeneous
  133208. */
  133209. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  133210. private _updateDummy;
  133211. /**
  133212. * Enables a pointer drag behavior on the bounding box of the gizmo
  133213. */
  133214. enableDragBehavior(): void;
  133215. /**
  133216. * Disposes of the gizmo
  133217. */
  133218. dispose(): void;
  133219. /**
  133220. * 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)
  133221. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  133222. * @returns the bounding box mesh with the passed in mesh as a child
  133223. */
  133224. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  133225. /**
  133226. * CustomMeshes are not supported by this gizmo
  133227. * @param mesh The mesh to replace the default mesh of the gizmo
  133228. */
  133229. setCustomMesh(mesh: Mesh): void;
  133230. }
  133231. }
  133232. declare module BABYLON {
  133233. /**
  133234. * Single plane rotation gizmo
  133235. */
  133236. export class PlaneRotationGizmo extends Gizmo {
  133237. /**
  133238. * Drag behavior responsible for the gizmos dragging interactions
  133239. */
  133240. dragBehavior: PointerDragBehavior;
  133241. private _pointerObserver;
  133242. /**
  133243. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  133244. */
  133245. snapDistance: number;
  133246. /**
  133247. * Event that fires each time the gizmo snaps to a new location.
  133248. * * snapDistance is the the change in distance
  133249. */
  133250. onSnapObservable: Observable<{
  133251. snapDistance: number;
  133252. }>;
  133253. private _isEnabled;
  133254. private _parent;
  133255. /**
  133256. * Creates a PlaneRotationGizmo
  133257. * @param gizmoLayer The utility layer the gizmo will be added to
  133258. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  133259. * @param color The color of the gizmo
  133260. * @param tessellation Amount of tessellation to be used when creating rotation circles
  133261. * @param useEulerRotation Use and update Euler angle instead of quaternion
  133262. * @param thickness display gizmo axis thickness
  133263. */
  133264. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  133265. protected _attachedNodeChanged(value: Nullable<Node>): void;
  133266. /**
  133267. * If the gizmo is enabled
  133268. */
  133269. set isEnabled(value: boolean);
  133270. get isEnabled(): boolean;
  133271. /**
  133272. * Disposes of the gizmo
  133273. */
  133274. dispose(): void;
  133275. }
  133276. }
  133277. declare module BABYLON {
  133278. /**
  133279. * Gizmo that enables rotating a mesh along 3 axis
  133280. */
  133281. export class RotationGizmo extends Gizmo {
  133282. /**
  133283. * Internal gizmo used for interactions on the x axis
  133284. */
  133285. xGizmo: PlaneRotationGizmo;
  133286. /**
  133287. * Internal gizmo used for interactions on the y axis
  133288. */
  133289. yGizmo: PlaneRotationGizmo;
  133290. /**
  133291. * Internal gizmo used for interactions on the z axis
  133292. */
  133293. zGizmo: PlaneRotationGizmo;
  133294. /** Fires an event when any of it's sub gizmos are dragged */
  133295. onDragStartObservable: Observable<unknown>;
  133296. /** Fires an event when any of it's sub gizmos are released from dragging */
  133297. onDragEndObservable: Observable<unknown>;
  133298. private _meshAttached;
  133299. private _nodeAttached;
  133300. get attachedMesh(): Nullable<AbstractMesh>;
  133301. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133302. get attachedNode(): Nullable<Node>;
  133303. set attachedNode(node: Nullable<Node>);
  133304. /**
  133305. * Creates a RotationGizmo
  133306. * @param gizmoLayer The utility layer the gizmo will be added to
  133307. * @param tessellation Amount of tessellation to be used when creating rotation circles
  133308. * @param useEulerRotation Use and update Euler angle instead of quaternion
  133309. * @param thickness display gizmo axis thickness
  133310. */
  133311. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  133312. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133313. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133314. /**
  133315. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133316. */
  133317. set snapDistance(value: number);
  133318. get snapDistance(): number;
  133319. /**
  133320. * Ratio for the scale of the gizmo (Default: 1)
  133321. */
  133322. set scaleRatio(value: number);
  133323. get scaleRatio(): number;
  133324. /**
  133325. * Disposes of the gizmo
  133326. */
  133327. dispose(): void;
  133328. /**
  133329. * CustomMeshes are not supported by this gizmo
  133330. * @param mesh The mesh to replace the default mesh of the gizmo
  133331. */
  133332. setCustomMesh(mesh: Mesh): void;
  133333. }
  133334. }
  133335. declare module BABYLON {
  133336. /**
  133337. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  133338. */
  133339. export class GizmoManager implements IDisposable {
  133340. private scene;
  133341. /**
  133342. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  133343. */
  133344. gizmos: {
  133345. positionGizmo: Nullable<PositionGizmo>;
  133346. rotationGizmo: Nullable<RotationGizmo>;
  133347. scaleGizmo: Nullable<ScaleGizmo>;
  133348. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  133349. };
  133350. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  133351. clearGizmoOnEmptyPointerEvent: boolean;
  133352. /** Fires an event when the manager is attached to a mesh */
  133353. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  133354. /** Fires an event when the manager is attached to a node */
  133355. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  133356. private _gizmosEnabled;
  133357. private _pointerObserver;
  133358. private _attachedMesh;
  133359. private _attachedNode;
  133360. private _boundingBoxColor;
  133361. private _defaultUtilityLayer;
  133362. private _defaultKeepDepthUtilityLayer;
  133363. private _thickness;
  133364. /**
  133365. * When bounding box gizmo is enabled, this can be used to track drag/end events
  133366. */
  133367. boundingBoxDragBehavior: SixDofDragBehavior;
  133368. /**
  133369. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  133370. */
  133371. attachableMeshes: Nullable<Array<AbstractMesh>>;
  133372. /**
  133373. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  133374. */
  133375. attachableNodes: Nullable<Array<Node>>;
  133376. /**
  133377. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  133378. */
  133379. usePointerToAttachGizmos: boolean;
  133380. /**
  133381. * Utility layer that the bounding box gizmo belongs to
  133382. */
  133383. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  133384. /**
  133385. * Utility layer that all gizmos besides bounding box belong to
  133386. */
  133387. get utilityLayer(): UtilityLayerRenderer;
  133388. /**
  133389. * Instatiates a gizmo manager
  133390. * @param scene the scene to overlay the gizmos on top of
  133391. * @param thickness display gizmo axis thickness
  133392. */
  133393. constructor(scene: Scene, thickness?: number);
  133394. /**
  133395. * Attaches a set of gizmos to the specified mesh
  133396. * @param mesh The mesh the gizmo's should be attached to
  133397. */
  133398. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  133399. /**
  133400. * Attaches a set of gizmos to the specified node
  133401. * @param node The node the gizmo's should be attached to
  133402. */
  133403. attachToNode(node: Nullable<Node>): void;
  133404. /**
  133405. * If the position gizmo is enabled
  133406. */
  133407. set positionGizmoEnabled(value: boolean);
  133408. get positionGizmoEnabled(): boolean;
  133409. /**
  133410. * If the rotation gizmo is enabled
  133411. */
  133412. set rotationGizmoEnabled(value: boolean);
  133413. get rotationGizmoEnabled(): boolean;
  133414. /**
  133415. * If the scale gizmo is enabled
  133416. */
  133417. set scaleGizmoEnabled(value: boolean);
  133418. get scaleGizmoEnabled(): boolean;
  133419. /**
  133420. * If the boundingBox gizmo is enabled
  133421. */
  133422. set boundingBoxGizmoEnabled(value: boolean);
  133423. get boundingBoxGizmoEnabled(): boolean;
  133424. /**
  133425. * Disposes of the gizmo manager
  133426. */
  133427. dispose(): void;
  133428. }
  133429. }
  133430. declare module BABYLON {
  133431. /**
  133432. * A directional light is defined by a direction (what a surprise!).
  133433. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  133434. * 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.
  133435. * Documentation: https://doc.babylonjs.com/babylon101/lights
  133436. */
  133437. export class DirectionalLight extends ShadowLight {
  133438. private _shadowFrustumSize;
  133439. /**
  133440. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  133441. */
  133442. get shadowFrustumSize(): number;
  133443. /**
  133444. * Specifies a fix frustum size for the shadow generation.
  133445. */
  133446. set shadowFrustumSize(value: number);
  133447. private _shadowOrthoScale;
  133448. /**
  133449. * Gets the shadow projection scale against the optimal computed one.
  133450. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  133451. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  133452. */
  133453. get shadowOrthoScale(): number;
  133454. /**
  133455. * Sets the shadow projection scale against the optimal computed one.
  133456. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  133457. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  133458. */
  133459. set shadowOrthoScale(value: number);
  133460. /**
  133461. * Automatically compute the projection matrix to best fit (including all the casters)
  133462. * on each frame.
  133463. */
  133464. autoUpdateExtends: boolean;
  133465. /**
  133466. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  133467. * on each frame. autoUpdateExtends must be set to true for this to work
  133468. */
  133469. autoCalcShadowZBounds: boolean;
  133470. private _orthoLeft;
  133471. private _orthoRight;
  133472. private _orthoTop;
  133473. private _orthoBottom;
  133474. /**
  133475. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  133476. * The directional light is emitted from everywhere in the given direction.
  133477. * It can cast shadows.
  133478. * Documentation : https://doc.babylonjs.com/babylon101/lights
  133479. * @param name The friendly name of the light
  133480. * @param direction The direction of the light
  133481. * @param scene The scene the light belongs to
  133482. */
  133483. constructor(name: string, direction: Vector3, scene: Scene);
  133484. /**
  133485. * Returns the string "DirectionalLight".
  133486. * @return The class name
  133487. */
  133488. getClassName(): string;
  133489. /**
  133490. * Returns the integer 1.
  133491. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  133492. */
  133493. getTypeID(): number;
  133494. /**
  133495. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  133496. * Returns the DirectionalLight Shadow projection matrix.
  133497. */
  133498. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133499. /**
  133500. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  133501. * Returns the DirectionalLight Shadow projection matrix.
  133502. */
  133503. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  133504. /**
  133505. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  133506. * Returns the DirectionalLight Shadow projection matrix.
  133507. */
  133508. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133509. protected _buildUniformLayout(): void;
  133510. /**
  133511. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  133512. * @param effect The effect to update
  133513. * @param lightIndex The index of the light in the effect to update
  133514. * @returns The directional light
  133515. */
  133516. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  133517. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  133518. /**
  133519. * Gets the minZ used for shadow according to both the scene and the light.
  133520. *
  133521. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  133522. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  133523. * @param activeCamera The camera we are returning the min for
  133524. * @returns the depth min z
  133525. */
  133526. getDepthMinZ(activeCamera: Camera): number;
  133527. /**
  133528. * Gets the maxZ used for shadow according to both the scene and the light.
  133529. *
  133530. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  133531. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  133532. * @param activeCamera The camera we are returning the max for
  133533. * @returns the depth max z
  133534. */
  133535. getDepthMaxZ(activeCamera: Camera): number;
  133536. /**
  133537. * Prepares the list of defines specific to the light type.
  133538. * @param defines the list of defines
  133539. * @param lightIndex defines the index of the light for the effect
  133540. */
  133541. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  133542. }
  133543. }
  133544. declare module BABYLON {
  133545. /**
  133546. * Class containing static functions to help procedurally build meshes
  133547. */
  133548. export class HemisphereBuilder {
  133549. /**
  133550. * Creates a hemisphere mesh
  133551. * @param name defines the name of the mesh
  133552. * @param options defines the options used to create the mesh
  133553. * @param scene defines the hosting scene
  133554. * @returns the hemisphere mesh
  133555. */
  133556. static CreateHemisphere(name: string, options: {
  133557. segments?: number;
  133558. diameter?: number;
  133559. sideOrientation?: number;
  133560. }, scene: any): Mesh;
  133561. }
  133562. }
  133563. declare module BABYLON {
  133564. /**
  133565. * A spot light is defined by a position, a direction, an angle, and an exponent.
  133566. * These values define a cone of light starting from the position, emitting toward the direction.
  133567. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  133568. * and the exponent defines the speed of the decay of the light with distance (reach).
  133569. * Documentation: https://doc.babylonjs.com/babylon101/lights
  133570. */
  133571. export class SpotLight extends ShadowLight {
  133572. private _angle;
  133573. private _innerAngle;
  133574. private _cosHalfAngle;
  133575. private _lightAngleScale;
  133576. private _lightAngleOffset;
  133577. /**
  133578. * Gets the cone angle of the spot light in Radians.
  133579. */
  133580. get angle(): number;
  133581. /**
  133582. * Sets the cone angle of the spot light in Radians.
  133583. */
  133584. set angle(value: number);
  133585. /**
  133586. * Only used in gltf falloff mode, this defines the angle where
  133587. * the directional falloff will start before cutting at angle which could be seen
  133588. * as outer angle.
  133589. */
  133590. get innerAngle(): number;
  133591. /**
  133592. * Only used in gltf falloff mode, this defines the angle where
  133593. * the directional falloff will start before cutting at angle which could be seen
  133594. * as outer angle.
  133595. */
  133596. set innerAngle(value: number);
  133597. private _shadowAngleScale;
  133598. /**
  133599. * Allows scaling the angle of the light for shadow generation only.
  133600. */
  133601. get shadowAngleScale(): number;
  133602. /**
  133603. * Allows scaling the angle of the light for shadow generation only.
  133604. */
  133605. set shadowAngleScale(value: number);
  133606. /**
  133607. * The light decay speed with the distance from the emission spot.
  133608. */
  133609. exponent: number;
  133610. private _projectionTextureMatrix;
  133611. /**
  133612. * Allows reading the projecton texture
  133613. */
  133614. get projectionTextureMatrix(): Matrix;
  133615. protected _projectionTextureLightNear: number;
  133616. /**
  133617. * Gets the near clip of the Spotlight for texture projection.
  133618. */
  133619. get projectionTextureLightNear(): number;
  133620. /**
  133621. * Sets the near clip of the Spotlight for texture projection.
  133622. */
  133623. set projectionTextureLightNear(value: number);
  133624. protected _projectionTextureLightFar: number;
  133625. /**
  133626. * Gets the far clip of the Spotlight for texture projection.
  133627. */
  133628. get projectionTextureLightFar(): number;
  133629. /**
  133630. * Sets the far clip of the Spotlight for texture projection.
  133631. */
  133632. set projectionTextureLightFar(value: number);
  133633. protected _projectionTextureUpDirection: Vector3;
  133634. /**
  133635. * Gets the Up vector of the Spotlight for texture projection.
  133636. */
  133637. get projectionTextureUpDirection(): Vector3;
  133638. /**
  133639. * Sets the Up vector of the Spotlight for texture projection.
  133640. */
  133641. set projectionTextureUpDirection(value: Vector3);
  133642. private _projectionTexture;
  133643. /**
  133644. * Gets the projection texture of the light.
  133645. */
  133646. get projectionTexture(): Nullable<BaseTexture>;
  133647. /**
  133648. * Sets the projection texture of the light.
  133649. */
  133650. set projectionTexture(value: Nullable<BaseTexture>);
  133651. private _projectionTextureViewLightDirty;
  133652. private _projectionTextureProjectionLightDirty;
  133653. private _projectionTextureDirty;
  133654. private _projectionTextureViewTargetVector;
  133655. private _projectionTextureViewLightMatrix;
  133656. private _projectionTextureProjectionLightMatrix;
  133657. private _projectionTextureScalingMatrix;
  133658. /**
  133659. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  133660. * It can cast shadows.
  133661. * Documentation : https://doc.babylonjs.com/babylon101/lights
  133662. * @param name The light friendly name
  133663. * @param position The position of the spot light in the scene
  133664. * @param direction The direction of the light in the scene
  133665. * @param angle The cone angle of the light in Radians
  133666. * @param exponent The light decay speed with the distance from the emission spot
  133667. * @param scene The scene the lights belongs to
  133668. */
  133669. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  133670. /**
  133671. * Returns the string "SpotLight".
  133672. * @returns the class name
  133673. */
  133674. getClassName(): string;
  133675. /**
  133676. * Returns the integer 2.
  133677. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  133678. */
  133679. getTypeID(): number;
  133680. /**
  133681. * Overrides the direction setter to recompute the projection texture view light Matrix.
  133682. */
  133683. protected _setDirection(value: Vector3): void;
  133684. /**
  133685. * Overrides the position setter to recompute the projection texture view light Matrix.
  133686. */
  133687. protected _setPosition(value: Vector3): void;
  133688. /**
  133689. * 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.
  133690. * Returns the SpotLight.
  133691. */
  133692. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133693. protected _computeProjectionTextureViewLightMatrix(): void;
  133694. protected _computeProjectionTextureProjectionLightMatrix(): void;
  133695. /**
  133696. * Main function for light texture projection matrix computing.
  133697. */
  133698. protected _computeProjectionTextureMatrix(): void;
  133699. protected _buildUniformLayout(): void;
  133700. private _computeAngleValues;
  133701. /**
  133702. * Sets the passed Effect "effect" with the Light textures.
  133703. * @param effect The effect to update
  133704. * @param lightIndex The index of the light in the effect to update
  133705. * @returns The light
  133706. */
  133707. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  133708. /**
  133709. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  133710. * @param effect The effect to update
  133711. * @param lightIndex The index of the light in the effect to update
  133712. * @returns The spot light
  133713. */
  133714. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  133715. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  133716. /**
  133717. * Disposes the light and the associated resources.
  133718. */
  133719. dispose(): void;
  133720. /**
  133721. * Prepares the list of defines specific to the light type.
  133722. * @param defines the list of defines
  133723. * @param lightIndex defines the index of the light for the effect
  133724. */
  133725. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  133726. }
  133727. }
  133728. declare module BABYLON {
  133729. /**
  133730. * Gizmo that enables viewing a light
  133731. */
  133732. export class LightGizmo extends Gizmo {
  133733. private _lightMesh;
  133734. private _material;
  133735. private _cachedPosition;
  133736. private _cachedForward;
  133737. private _attachedMeshParent;
  133738. /**
  133739. * Creates a LightGizmo
  133740. * @param gizmoLayer The utility layer the gizmo will be added to
  133741. */
  133742. constructor(gizmoLayer?: UtilityLayerRenderer);
  133743. private _light;
  133744. /**
  133745. * The light that the gizmo is attached to
  133746. */
  133747. set light(light: Nullable<Light>);
  133748. get light(): Nullable<Light>;
  133749. /**
  133750. * Gets the material used to render the light gizmo
  133751. */
  133752. get material(): StandardMaterial;
  133753. /**
  133754. * @hidden
  133755. * Updates the gizmo to match the attached mesh's position/rotation
  133756. */
  133757. protected _update(): void;
  133758. private static _Scale;
  133759. /**
  133760. * Creates the lines for a light mesh
  133761. */
  133762. private static _CreateLightLines;
  133763. /**
  133764. * Disposes of the light gizmo
  133765. */
  133766. dispose(): void;
  133767. private static _CreateHemisphericLightMesh;
  133768. private static _CreatePointLightMesh;
  133769. private static _CreateSpotLightMesh;
  133770. private static _CreateDirectionalLightMesh;
  133771. }
  133772. }
  133773. declare module BABYLON {
  133774. /**
  133775. * Gizmo that enables viewing a camera
  133776. */
  133777. export class CameraGizmo extends Gizmo {
  133778. private _cameraMesh;
  133779. private _cameraLinesMesh;
  133780. private _material;
  133781. /**
  133782. * Creates a CameraGizmo
  133783. * @param gizmoLayer The utility layer the gizmo will be added to
  133784. */
  133785. constructor(gizmoLayer?: UtilityLayerRenderer);
  133786. private _camera;
  133787. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  133788. get displayFrustum(): boolean;
  133789. set displayFrustum(value: boolean);
  133790. /**
  133791. * The camera that the gizmo is attached to
  133792. */
  133793. set camera(camera: Nullable<Camera>);
  133794. get camera(): Nullable<Camera>;
  133795. /**
  133796. * Gets the material used to render the camera gizmo
  133797. */
  133798. get material(): StandardMaterial;
  133799. /**
  133800. * @hidden
  133801. * Updates the gizmo to match the attached mesh's position/rotation
  133802. */
  133803. protected _update(): void;
  133804. private static _Scale;
  133805. private _invProjection;
  133806. /**
  133807. * Disposes of the camera gizmo
  133808. */
  133809. dispose(): void;
  133810. private static _CreateCameraMesh;
  133811. private static _CreateCameraFrustum;
  133812. }
  133813. }
  133814. declare module BABYLON {
  133815. /** @hidden */
  133816. export var backgroundFragmentDeclaration: {
  133817. name: string;
  133818. shader: string;
  133819. };
  133820. }
  133821. declare module BABYLON {
  133822. /** @hidden */
  133823. export var backgroundUboDeclaration: {
  133824. name: string;
  133825. shader: string;
  133826. };
  133827. }
  133828. declare module BABYLON {
  133829. /** @hidden */
  133830. export var backgroundPixelShader: {
  133831. name: string;
  133832. shader: string;
  133833. };
  133834. }
  133835. declare module BABYLON {
  133836. /** @hidden */
  133837. export var backgroundVertexDeclaration: {
  133838. name: string;
  133839. shader: string;
  133840. };
  133841. }
  133842. declare module BABYLON {
  133843. /** @hidden */
  133844. export var backgroundVertexShader: {
  133845. name: string;
  133846. shader: string;
  133847. };
  133848. }
  133849. declare module BABYLON {
  133850. /**
  133851. * Background material used to create an efficient environement around your scene.
  133852. */
  133853. export class BackgroundMaterial extends PushMaterial {
  133854. /**
  133855. * Standard reflectance value at parallel view angle.
  133856. */
  133857. static StandardReflectance0: number;
  133858. /**
  133859. * Standard reflectance value at grazing angle.
  133860. */
  133861. static StandardReflectance90: number;
  133862. protected _primaryColor: Color3;
  133863. /**
  133864. * Key light Color (multiply against the environement texture)
  133865. */
  133866. primaryColor: Color3;
  133867. protected __perceptualColor: Nullable<Color3>;
  133868. /**
  133869. * Experimental Internal Use Only.
  133870. *
  133871. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  133872. * This acts as a helper to set the primary color to a more "human friendly" value.
  133873. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  133874. * output color as close as possible from the chosen value.
  133875. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  133876. * part of lighting setup.)
  133877. */
  133878. get _perceptualColor(): Nullable<Color3>;
  133879. set _perceptualColor(value: Nullable<Color3>);
  133880. protected _primaryColorShadowLevel: float;
  133881. /**
  133882. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  133883. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  133884. */
  133885. get primaryColorShadowLevel(): float;
  133886. set primaryColorShadowLevel(value: float);
  133887. protected _primaryColorHighlightLevel: float;
  133888. /**
  133889. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  133890. * The primary color is used at the level chosen to define what the white area would look.
  133891. */
  133892. get primaryColorHighlightLevel(): float;
  133893. set primaryColorHighlightLevel(value: float);
  133894. protected _reflectionTexture: Nullable<BaseTexture>;
  133895. /**
  133896. * Reflection Texture used in the material.
  133897. * Should be author in a specific way for the best result (refer to the documentation).
  133898. */
  133899. reflectionTexture: Nullable<BaseTexture>;
  133900. protected _reflectionBlur: float;
  133901. /**
  133902. * Reflection Texture level of blur.
  133903. *
  133904. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  133905. * texture twice.
  133906. */
  133907. reflectionBlur: float;
  133908. protected _diffuseTexture: Nullable<BaseTexture>;
  133909. /**
  133910. * Diffuse Texture used in the material.
  133911. * Should be author in a specific way for the best result (refer to the documentation).
  133912. */
  133913. diffuseTexture: Nullable<BaseTexture>;
  133914. protected _shadowLights: Nullable<IShadowLight[]>;
  133915. /**
  133916. * Specify the list of lights casting shadow on the material.
  133917. * All scene shadow lights will be included if null.
  133918. */
  133919. shadowLights: Nullable<IShadowLight[]>;
  133920. protected _shadowLevel: float;
  133921. /**
  133922. * Helps adjusting the shadow to a softer level if required.
  133923. * 0 means black shadows and 1 means no shadows.
  133924. */
  133925. shadowLevel: float;
  133926. protected _sceneCenter: Vector3;
  133927. /**
  133928. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  133929. * It is usually zero but might be interesting to modify according to your setup.
  133930. */
  133931. sceneCenter: Vector3;
  133932. protected _opacityFresnel: boolean;
  133933. /**
  133934. * This helps specifying that the material is falling off to the sky box at grazing angle.
  133935. * This helps ensuring a nice transition when the camera goes under the ground.
  133936. */
  133937. opacityFresnel: boolean;
  133938. protected _reflectionFresnel: boolean;
  133939. /**
  133940. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  133941. * This helps adding a mirror texture on the ground.
  133942. */
  133943. reflectionFresnel: boolean;
  133944. protected _reflectionFalloffDistance: number;
  133945. /**
  133946. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  133947. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  133948. */
  133949. reflectionFalloffDistance: number;
  133950. protected _reflectionAmount: number;
  133951. /**
  133952. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  133953. */
  133954. reflectionAmount: number;
  133955. protected _reflectionReflectance0: number;
  133956. /**
  133957. * This specifies the weight of the reflection at grazing angle.
  133958. */
  133959. reflectionReflectance0: number;
  133960. protected _reflectionReflectance90: number;
  133961. /**
  133962. * This specifies the weight of the reflection at a perpendicular point of view.
  133963. */
  133964. reflectionReflectance90: number;
  133965. /**
  133966. * Sets the reflection reflectance fresnel values according to the default standard
  133967. * empirically know to work well :-)
  133968. */
  133969. set reflectionStandardFresnelWeight(value: number);
  133970. protected _useRGBColor: boolean;
  133971. /**
  133972. * Helps to directly use the maps channels instead of their level.
  133973. */
  133974. useRGBColor: boolean;
  133975. protected _enableNoise: boolean;
  133976. /**
  133977. * This helps reducing the banding effect that could occur on the background.
  133978. */
  133979. enableNoise: boolean;
  133980. /**
  133981. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  133982. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  133983. * Recommended to be keep at 1.0 except for special cases.
  133984. */
  133985. get fovMultiplier(): number;
  133986. set fovMultiplier(value: number);
  133987. private _fovMultiplier;
  133988. /**
  133989. * Enable the FOV adjustment feature controlled by fovMultiplier.
  133990. */
  133991. useEquirectangularFOV: boolean;
  133992. private _maxSimultaneousLights;
  133993. /**
  133994. * Number of Simultaneous lights allowed on the material.
  133995. */
  133996. maxSimultaneousLights: int;
  133997. private _shadowOnly;
  133998. /**
  133999. * Make the material only render shadows
  134000. */
  134001. shadowOnly: boolean;
  134002. /**
  134003. * Default configuration related to image processing available in the Background Material.
  134004. */
  134005. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134006. /**
  134007. * Keep track of the image processing observer to allow dispose and replace.
  134008. */
  134009. private _imageProcessingObserver;
  134010. /**
  134011. * Attaches a new image processing configuration to the PBR Material.
  134012. * @param configuration (if null the scene configuration will be use)
  134013. */
  134014. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134015. /**
  134016. * Gets the image processing configuration used either in this material.
  134017. */
  134018. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  134019. /**
  134020. * Sets the Default image processing configuration used either in the this material.
  134021. *
  134022. * If sets to null, the scene one is in use.
  134023. */
  134024. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  134025. /**
  134026. * Gets wether the color curves effect is enabled.
  134027. */
  134028. get cameraColorCurvesEnabled(): boolean;
  134029. /**
  134030. * Sets wether the color curves effect is enabled.
  134031. */
  134032. set cameraColorCurvesEnabled(value: boolean);
  134033. /**
  134034. * Gets wether the color grading effect is enabled.
  134035. */
  134036. get cameraColorGradingEnabled(): boolean;
  134037. /**
  134038. * Gets wether the color grading effect is enabled.
  134039. */
  134040. set cameraColorGradingEnabled(value: boolean);
  134041. /**
  134042. * Gets wether tonemapping is enabled or not.
  134043. */
  134044. get cameraToneMappingEnabled(): boolean;
  134045. /**
  134046. * Sets wether tonemapping is enabled or not
  134047. */
  134048. set cameraToneMappingEnabled(value: boolean);
  134049. /**
  134050. * The camera exposure used on this material.
  134051. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134052. * This corresponds to a photographic exposure.
  134053. */
  134054. get cameraExposure(): float;
  134055. /**
  134056. * The camera exposure used on this material.
  134057. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134058. * This corresponds to a photographic exposure.
  134059. */
  134060. set cameraExposure(value: float);
  134061. /**
  134062. * Gets The camera contrast used on this material.
  134063. */
  134064. get cameraContrast(): float;
  134065. /**
  134066. * Sets The camera contrast used on this material.
  134067. */
  134068. set cameraContrast(value: float);
  134069. /**
  134070. * Gets the Color Grading 2D Lookup Texture.
  134071. */
  134072. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  134073. /**
  134074. * Sets the Color Grading 2D Lookup Texture.
  134075. */
  134076. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  134077. /**
  134078. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134079. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134080. * 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;
  134081. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134082. */
  134083. get cameraColorCurves(): Nullable<ColorCurves>;
  134084. /**
  134085. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134086. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134087. * 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;
  134088. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134089. */
  134090. set cameraColorCurves(value: Nullable<ColorCurves>);
  134091. /**
  134092. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  134093. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  134094. */
  134095. switchToBGR: boolean;
  134096. private _renderTargets;
  134097. private _reflectionControls;
  134098. private _white;
  134099. private _primaryShadowColor;
  134100. private _primaryHighlightColor;
  134101. /**
  134102. * Instantiates a Background Material in the given scene
  134103. * @param name The friendly name of the material
  134104. * @param scene The scene to add the material to
  134105. */
  134106. constructor(name: string, scene: Scene);
  134107. /**
  134108. * Gets a boolean indicating that current material needs to register RTT
  134109. */
  134110. get hasRenderTargetTextures(): boolean;
  134111. /**
  134112. * The entire material has been created in order to prevent overdraw.
  134113. * @returns false
  134114. */
  134115. needAlphaTesting(): boolean;
  134116. /**
  134117. * The entire material has been created in order to prevent overdraw.
  134118. * @returns true if blending is enable
  134119. */
  134120. needAlphaBlending(): boolean;
  134121. /**
  134122. * Checks wether the material is ready to be rendered for a given mesh.
  134123. * @param mesh The mesh to render
  134124. * @param subMesh The submesh to check against
  134125. * @param useInstances Specify wether or not the material is used with instances
  134126. * @returns true if all the dependencies are ready (Textures, Effects...)
  134127. */
  134128. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  134129. /**
  134130. * Compute the primary color according to the chosen perceptual color.
  134131. */
  134132. private _computePrimaryColorFromPerceptualColor;
  134133. /**
  134134. * Compute the highlights and shadow colors according to their chosen levels.
  134135. */
  134136. private _computePrimaryColors;
  134137. /**
  134138. * Build the uniform buffer used in the material.
  134139. */
  134140. buildUniformLayout(): void;
  134141. /**
  134142. * Unbind the material.
  134143. */
  134144. unbind(): void;
  134145. /**
  134146. * Bind only the world matrix to the material.
  134147. * @param world The world matrix to bind.
  134148. */
  134149. bindOnlyWorldMatrix(world: Matrix): void;
  134150. /**
  134151. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  134152. * @param world The world matrix to bind.
  134153. * @param subMesh The submesh to bind for.
  134154. */
  134155. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134156. /**
  134157. * Checks to see if a texture is used in the material.
  134158. * @param texture - Base texture to use.
  134159. * @returns - Boolean specifying if a texture is used in the material.
  134160. */
  134161. hasTexture(texture: BaseTexture): boolean;
  134162. /**
  134163. * Dispose the material.
  134164. * @param forceDisposeEffect Force disposal of the associated effect.
  134165. * @param forceDisposeTextures Force disposal of the associated textures.
  134166. */
  134167. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  134168. /**
  134169. * Clones the material.
  134170. * @param name The cloned name.
  134171. * @returns The cloned material.
  134172. */
  134173. clone(name: string): BackgroundMaterial;
  134174. /**
  134175. * Serializes the current material to its JSON representation.
  134176. * @returns The JSON representation.
  134177. */
  134178. serialize(): any;
  134179. /**
  134180. * Gets the class name of the material
  134181. * @returns "BackgroundMaterial"
  134182. */
  134183. getClassName(): string;
  134184. /**
  134185. * Parse a JSON input to create back a background material.
  134186. * @param source The JSON data to parse
  134187. * @param scene The scene to create the parsed material in
  134188. * @param rootUrl The root url of the assets the material depends upon
  134189. * @returns the instantiated BackgroundMaterial.
  134190. */
  134191. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  134192. }
  134193. }
  134194. declare module BABYLON {
  134195. /**
  134196. * Represents the different options available during the creation of
  134197. * a Environment helper.
  134198. *
  134199. * This can control the default ground, skybox and image processing setup of your scene.
  134200. */
  134201. export interface IEnvironmentHelperOptions {
  134202. /**
  134203. * Specifies whether or not to create a ground.
  134204. * True by default.
  134205. */
  134206. createGround: boolean;
  134207. /**
  134208. * Specifies the ground size.
  134209. * 15 by default.
  134210. */
  134211. groundSize: number;
  134212. /**
  134213. * The texture used on the ground for the main color.
  134214. * Comes from the BabylonJS CDN by default.
  134215. *
  134216. * Remarks: Can be either a texture or a url.
  134217. */
  134218. groundTexture: string | BaseTexture;
  134219. /**
  134220. * The color mixed in the ground texture by default.
  134221. * BabylonJS clearColor by default.
  134222. */
  134223. groundColor: Color3;
  134224. /**
  134225. * Specifies the ground opacity.
  134226. * 1 by default.
  134227. */
  134228. groundOpacity: number;
  134229. /**
  134230. * Enables the ground to receive shadows.
  134231. * True by default.
  134232. */
  134233. enableGroundShadow: boolean;
  134234. /**
  134235. * Helps preventing the shadow to be fully black on the ground.
  134236. * 0.5 by default.
  134237. */
  134238. groundShadowLevel: number;
  134239. /**
  134240. * Creates a mirror texture attach to the ground.
  134241. * false by default.
  134242. */
  134243. enableGroundMirror: boolean;
  134244. /**
  134245. * Specifies the ground mirror size ratio.
  134246. * 0.3 by default as the default kernel is 64.
  134247. */
  134248. groundMirrorSizeRatio: number;
  134249. /**
  134250. * Specifies the ground mirror blur kernel size.
  134251. * 64 by default.
  134252. */
  134253. groundMirrorBlurKernel: number;
  134254. /**
  134255. * Specifies the ground mirror visibility amount.
  134256. * 1 by default
  134257. */
  134258. groundMirrorAmount: number;
  134259. /**
  134260. * Specifies the ground mirror reflectance weight.
  134261. * This uses the standard weight of the background material to setup the fresnel effect
  134262. * of the mirror.
  134263. * 1 by default.
  134264. */
  134265. groundMirrorFresnelWeight: number;
  134266. /**
  134267. * Specifies the ground mirror Falloff distance.
  134268. * This can helps reducing the size of the reflection.
  134269. * 0 by Default.
  134270. */
  134271. groundMirrorFallOffDistance: number;
  134272. /**
  134273. * Specifies the ground mirror texture type.
  134274. * Unsigned Int by Default.
  134275. */
  134276. groundMirrorTextureType: number;
  134277. /**
  134278. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  134279. * the shown objects.
  134280. */
  134281. groundYBias: number;
  134282. /**
  134283. * Specifies whether or not to create a skybox.
  134284. * True by default.
  134285. */
  134286. createSkybox: boolean;
  134287. /**
  134288. * Specifies the skybox size.
  134289. * 20 by default.
  134290. */
  134291. skyboxSize: number;
  134292. /**
  134293. * The texture used on the skybox for the main color.
  134294. * Comes from the BabylonJS CDN by default.
  134295. *
  134296. * Remarks: Can be either a texture or a url.
  134297. */
  134298. skyboxTexture: string | BaseTexture;
  134299. /**
  134300. * The color mixed in the skybox texture by default.
  134301. * BabylonJS clearColor by default.
  134302. */
  134303. skyboxColor: Color3;
  134304. /**
  134305. * The background rotation around the Y axis of the scene.
  134306. * This helps aligning the key lights of your scene with the background.
  134307. * 0 by default.
  134308. */
  134309. backgroundYRotation: number;
  134310. /**
  134311. * Compute automatically the size of the elements to best fit with the scene.
  134312. */
  134313. sizeAuto: boolean;
  134314. /**
  134315. * Default position of the rootMesh if autoSize is not true.
  134316. */
  134317. rootPosition: Vector3;
  134318. /**
  134319. * Sets up the image processing in the scene.
  134320. * true by default.
  134321. */
  134322. setupImageProcessing: boolean;
  134323. /**
  134324. * The texture used as your environment texture in the scene.
  134325. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  134326. *
  134327. * Remarks: Can be either a texture or a url.
  134328. */
  134329. environmentTexture: string | BaseTexture;
  134330. /**
  134331. * The value of the exposure to apply to the scene.
  134332. * 0.6 by default if setupImageProcessing is true.
  134333. */
  134334. cameraExposure: number;
  134335. /**
  134336. * The value of the contrast to apply to the scene.
  134337. * 1.6 by default if setupImageProcessing is true.
  134338. */
  134339. cameraContrast: number;
  134340. /**
  134341. * Specifies whether or not tonemapping should be enabled in the scene.
  134342. * true by default if setupImageProcessing is true.
  134343. */
  134344. toneMappingEnabled: boolean;
  134345. }
  134346. /**
  134347. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  134348. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  134349. * It also helps with the default setup of your imageProcessing configuration.
  134350. */
  134351. export class EnvironmentHelper {
  134352. /**
  134353. * Default ground texture URL.
  134354. */
  134355. private static _groundTextureCDNUrl;
  134356. /**
  134357. * Default skybox texture URL.
  134358. */
  134359. private static _skyboxTextureCDNUrl;
  134360. /**
  134361. * Default environment texture URL.
  134362. */
  134363. private static _environmentTextureCDNUrl;
  134364. /**
  134365. * Creates the default options for the helper.
  134366. */
  134367. private static _getDefaultOptions;
  134368. private _rootMesh;
  134369. /**
  134370. * Gets the root mesh created by the helper.
  134371. */
  134372. get rootMesh(): Mesh;
  134373. private _skybox;
  134374. /**
  134375. * Gets the skybox created by the helper.
  134376. */
  134377. get skybox(): Nullable<Mesh>;
  134378. private _skyboxTexture;
  134379. /**
  134380. * Gets the skybox texture created by the helper.
  134381. */
  134382. get skyboxTexture(): Nullable<BaseTexture>;
  134383. private _skyboxMaterial;
  134384. /**
  134385. * Gets the skybox material created by the helper.
  134386. */
  134387. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  134388. private _ground;
  134389. /**
  134390. * Gets the ground mesh created by the helper.
  134391. */
  134392. get ground(): Nullable<Mesh>;
  134393. private _groundTexture;
  134394. /**
  134395. * Gets the ground texture created by the helper.
  134396. */
  134397. get groundTexture(): Nullable<BaseTexture>;
  134398. private _groundMirror;
  134399. /**
  134400. * Gets the ground mirror created by the helper.
  134401. */
  134402. get groundMirror(): Nullable<MirrorTexture>;
  134403. /**
  134404. * Gets the ground mirror render list to helps pushing the meshes
  134405. * you wish in the ground reflection.
  134406. */
  134407. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  134408. private _groundMaterial;
  134409. /**
  134410. * Gets the ground material created by the helper.
  134411. */
  134412. get groundMaterial(): Nullable<BackgroundMaterial>;
  134413. /**
  134414. * Stores the creation options.
  134415. */
  134416. private readonly _scene;
  134417. private _options;
  134418. /**
  134419. * This observable will be notified with any error during the creation of the environment,
  134420. * mainly texture creation errors.
  134421. */
  134422. onErrorObservable: Observable<{
  134423. message?: string;
  134424. exception?: any;
  134425. }>;
  134426. /**
  134427. * constructor
  134428. * @param options Defines the options we want to customize the helper
  134429. * @param scene The scene to add the material to
  134430. */
  134431. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  134432. /**
  134433. * Updates the background according to the new options
  134434. * @param options
  134435. */
  134436. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  134437. /**
  134438. * Sets the primary color of all the available elements.
  134439. * @param color the main color to affect to the ground and the background
  134440. */
  134441. setMainColor(color: Color3): void;
  134442. /**
  134443. * Setup the image processing according to the specified options.
  134444. */
  134445. private _setupImageProcessing;
  134446. /**
  134447. * Setup the environment texture according to the specified options.
  134448. */
  134449. private _setupEnvironmentTexture;
  134450. /**
  134451. * Setup the background according to the specified options.
  134452. */
  134453. private _setupBackground;
  134454. /**
  134455. * Get the scene sizes according to the setup.
  134456. */
  134457. private _getSceneSize;
  134458. /**
  134459. * Setup the ground according to the specified options.
  134460. */
  134461. private _setupGround;
  134462. /**
  134463. * Setup the ground material according to the specified options.
  134464. */
  134465. private _setupGroundMaterial;
  134466. /**
  134467. * Setup the ground diffuse texture according to the specified options.
  134468. */
  134469. private _setupGroundDiffuseTexture;
  134470. /**
  134471. * Setup the ground mirror texture according to the specified options.
  134472. */
  134473. private _setupGroundMirrorTexture;
  134474. /**
  134475. * Setup the ground to receive the mirror texture.
  134476. */
  134477. private _setupMirrorInGroundMaterial;
  134478. /**
  134479. * Setup the skybox according to the specified options.
  134480. */
  134481. private _setupSkybox;
  134482. /**
  134483. * Setup the skybox material according to the specified options.
  134484. */
  134485. private _setupSkyboxMaterial;
  134486. /**
  134487. * Setup the skybox reflection texture according to the specified options.
  134488. */
  134489. private _setupSkyboxReflectionTexture;
  134490. private _errorHandler;
  134491. /**
  134492. * Dispose all the elements created by the Helper.
  134493. */
  134494. dispose(): void;
  134495. }
  134496. }
  134497. declare module BABYLON {
  134498. /**
  134499. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  134500. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  134501. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  134502. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134503. */
  134504. export abstract class TextureDome<T extends Texture> extends TransformNode {
  134505. protected onError: Nullable<(message?: string, exception?: any) => void>;
  134506. /**
  134507. * Define the source as a Monoscopic panoramic 360/180.
  134508. */
  134509. static readonly MODE_MONOSCOPIC: number;
  134510. /**
  134511. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  134512. */
  134513. static readonly MODE_TOPBOTTOM: number;
  134514. /**
  134515. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  134516. */
  134517. static readonly MODE_SIDEBYSIDE: number;
  134518. private _halfDome;
  134519. protected _useDirectMapping: boolean;
  134520. /**
  134521. * The texture being displayed on the sphere
  134522. */
  134523. protected _texture: T;
  134524. /**
  134525. * Gets the texture being displayed on the sphere
  134526. */
  134527. get texture(): T;
  134528. /**
  134529. * Sets the texture being displayed on the sphere
  134530. */
  134531. set texture(newTexture: T);
  134532. /**
  134533. * The skybox material
  134534. */
  134535. protected _material: BackgroundMaterial;
  134536. /**
  134537. * The surface used for the dome
  134538. */
  134539. protected _mesh: Mesh;
  134540. /**
  134541. * Gets the mesh used for the dome.
  134542. */
  134543. get mesh(): Mesh;
  134544. /**
  134545. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  134546. */
  134547. private _halfDomeMask;
  134548. /**
  134549. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134550. * Also see the options.resolution property.
  134551. */
  134552. get fovMultiplier(): number;
  134553. set fovMultiplier(value: number);
  134554. protected _textureMode: number;
  134555. /**
  134556. * Gets or set the current texture mode for the texture. It can be:
  134557. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  134558. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  134559. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  134560. */
  134561. get textureMode(): number;
  134562. /**
  134563. * Sets the current texture mode for the texture. It can be:
  134564. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  134565. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  134566. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  134567. */
  134568. set textureMode(value: number);
  134569. /**
  134570. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  134571. */
  134572. get halfDome(): boolean;
  134573. /**
  134574. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  134575. */
  134576. set halfDome(enabled: boolean);
  134577. /**
  134578. * Oberserver used in Stereoscopic VR Mode.
  134579. */
  134580. private _onBeforeCameraRenderObserver;
  134581. /**
  134582. * Observable raised when an error occured while loading the 360 image
  134583. */
  134584. onLoadErrorObservable: Observable<string>;
  134585. /**
  134586. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  134587. * @param name Element's name, child elements will append suffixes for their own names.
  134588. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  134589. * @param options An object containing optional or exposed sub element properties
  134590. */
  134591. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  134592. resolution?: number;
  134593. clickToPlay?: boolean;
  134594. autoPlay?: boolean;
  134595. loop?: boolean;
  134596. size?: number;
  134597. poster?: string;
  134598. faceForward?: boolean;
  134599. useDirectMapping?: boolean;
  134600. halfDomeMode?: boolean;
  134601. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  134602. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  134603. protected _changeTextureMode(value: number): void;
  134604. /**
  134605. * Releases resources associated with this node.
  134606. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  134607. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  134608. */
  134609. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  134610. }
  134611. }
  134612. declare module BABYLON {
  134613. /**
  134614. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  134615. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  134616. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  134617. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134618. */
  134619. export class PhotoDome extends TextureDome<Texture> {
  134620. /**
  134621. * Define the image as a Monoscopic panoramic 360 image.
  134622. */
  134623. static readonly MODE_MONOSCOPIC: number;
  134624. /**
  134625. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  134626. */
  134627. static readonly MODE_TOPBOTTOM: number;
  134628. /**
  134629. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  134630. */
  134631. static readonly MODE_SIDEBYSIDE: number;
  134632. /**
  134633. * Gets or sets the texture being displayed on the sphere
  134634. */
  134635. get photoTexture(): Texture;
  134636. /**
  134637. * sets the texture being displayed on the sphere
  134638. */
  134639. set photoTexture(value: Texture);
  134640. /**
  134641. * Gets the current video mode for the video. It can be:
  134642. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  134643. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  134644. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  134645. */
  134646. get imageMode(): number;
  134647. /**
  134648. * Sets the current video mode for the video. It can be:
  134649. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  134650. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  134651. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  134652. */
  134653. set imageMode(value: number);
  134654. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  134655. }
  134656. }
  134657. declare module BABYLON {
  134658. /**
  134659. * Class used to host RGBD texture specific utilities
  134660. */
  134661. export class RGBDTextureTools {
  134662. /**
  134663. * Expand the RGBD Texture from RGBD to Half Float if possible.
  134664. * @param texture the texture to expand.
  134665. */
  134666. static ExpandRGBDTexture(texture: Texture): void;
  134667. }
  134668. }
  134669. declare module BABYLON {
  134670. /**
  134671. * Class used to host texture specific utilities
  134672. */
  134673. export class BRDFTextureTools {
  134674. /**
  134675. * Prevents texture cache collision
  134676. */
  134677. private static _instanceNumber;
  134678. /**
  134679. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  134680. * @param scene defines the hosting scene
  134681. * @returns the environment BRDF texture
  134682. */
  134683. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  134684. private static _environmentBRDFBase64Texture;
  134685. }
  134686. }
  134687. declare module BABYLON {
  134688. /**
  134689. * @hidden
  134690. */
  134691. export interface IMaterialClearCoatDefines {
  134692. CLEARCOAT: boolean;
  134693. CLEARCOAT_DEFAULTIOR: boolean;
  134694. CLEARCOAT_TEXTURE: boolean;
  134695. CLEARCOAT_TEXTUREDIRECTUV: number;
  134696. CLEARCOAT_BUMP: boolean;
  134697. CLEARCOAT_BUMPDIRECTUV: number;
  134698. CLEARCOAT_TINT: boolean;
  134699. CLEARCOAT_TINT_TEXTURE: boolean;
  134700. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  134701. /** @hidden */
  134702. _areTexturesDirty: boolean;
  134703. }
  134704. /**
  134705. * Define the code related to the clear coat parameters of the pbr material.
  134706. */
  134707. export class PBRClearCoatConfiguration {
  134708. /**
  134709. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  134710. * The default fits with a polyurethane material.
  134711. */
  134712. private static readonly _DefaultIndexOfRefraction;
  134713. private _isEnabled;
  134714. /**
  134715. * Defines if the clear coat is enabled in the material.
  134716. */
  134717. isEnabled: boolean;
  134718. /**
  134719. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  134720. */
  134721. intensity: number;
  134722. /**
  134723. * Defines the clear coat layer roughness.
  134724. */
  134725. roughness: number;
  134726. private _indexOfRefraction;
  134727. /**
  134728. * Defines the index of refraction of the clear coat.
  134729. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  134730. * The default fits with a polyurethane material.
  134731. * Changing the default value is more performance intensive.
  134732. */
  134733. indexOfRefraction: number;
  134734. private _texture;
  134735. /**
  134736. * Stores the clear coat values in a texture.
  134737. */
  134738. texture: Nullable<BaseTexture>;
  134739. private _bumpTexture;
  134740. /**
  134741. * Define the clear coat specific bump texture.
  134742. */
  134743. bumpTexture: Nullable<BaseTexture>;
  134744. private _isTintEnabled;
  134745. /**
  134746. * Defines if the clear coat tint is enabled in the material.
  134747. */
  134748. isTintEnabled: boolean;
  134749. /**
  134750. * Defines the clear coat tint of the material.
  134751. * This is only use if tint is enabled
  134752. */
  134753. tintColor: Color3;
  134754. /**
  134755. * Defines the distance at which the tint color should be found in the
  134756. * clear coat media.
  134757. * This is only use if tint is enabled
  134758. */
  134759. tintColorAtDistance: number;
  134760. /**
  134761. * Defines the clear coat layer thickness.
  134762. * This is only use if tint is enabled
  134763. */
  134764. tintThickness: number;
  134765. private _tintTexture;
  134766. /**
  134767. * Stores the clear tint values in a texture.
  134768. * rgb is tint
  134769. * a is a thickness factor
  134770. */
  134771. tintTexture: Nullable<BaseTexture>;
  134772. /** @hidden */
  134773. private _internalMarkAllSubMeshesAsTexturesDirty;
  134774. /** @hidden */
  134775. _markAllSubMeshesAsTexturesDirty(): void;
  134776. /**
  134777. * Instantiate a new istance of clear coat configuration.
  134778. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134779. */
  134780. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  134781. /**
  134782. * Gets wehter the submesh is ready to be used or not.
  134783. * @param defines the list of "defines" to update.
  134784. * @param scene defines the scene the material belongs to.
  134785. * @param engine defines the engine the material belongs to.
  134786. * @param disableBumpMap defines wether the material disables bump or not.
  134787. * @returns - boolean indicating that the submesh is ready or not.
  134788. */
  134789. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  134790. /**
  134791. * Checks to see if a texture is used in the material.
  134792. * @param defines the list of "defines" to update.
  134793. * @param scene defines the scene to the material belongs to.
  134794. */
  134795. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  134796. /**
  134797. * Binds the material data.
  134798. * @param uniformBuffer defines the Uniform buffer to fill in.
  134799. * @param scene defines the scene the material belongs to.
  134800. * @param engine defines the engine the material belongs to.
  134801. * @param disableBumpMap defines wether the material disables bump or not.
  134802. * @param isFrozen defines wether the material is frozen or not.
  134803. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  134804. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  134805. */
  134806. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  134807. /**
  134808. * Checks to see if a texture is used in the material.
  134809. * @param texture - Base texture to use.
  134810. * @returns - Boolean specifying if a texture is used in the material.
  134811. */
  134812. hasTexture(texture: BaseTexture): boolean;
  134813. /**
  134814. * Returns an array of the actively used textures.
  134815. * @param activeTextures Array of BaseTextures
  134816. */
  134817. getActiveTextures(activeTextures: BaseTexture[]): void;
  134818. /**
  134819. * Returns the animatable textures.
  134820. * @param animatables Array of animatable textures.
  134821. */
  134822. getAnimatables(animatables: IAnimatable[]): void;
  134823. /**
  134824. * Disposes the resources of the material.
  134825. * @param forceDisposeTextures - Forces the disposal of all textures.
  134826. */
  134827. dispose(forceDisposeTextures?: boolean): void;
  134828. /**
  134829. * Get the current class name of the texture useful for serialization or dynamic coding.
  134830. * @returns "PBRClearCoatConfiguration"
  134831. */
  134832. getClassName(): string;
  134833. /**
  134834. * Add fallbacks to the effect fallbacks list.
  134835. * @param defines defines the Base texture to use.
  134836. * @param fallbacks defines the current fallback list.
  134837. * @param currentRank defines the current fallback rank.
  134838. * @returns the new fallback rank.
  134839. */
  134840. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134841. /**
  134842. * Add the required uniforms to the current list.
  134843. * @param uniforms defines the current uniform list.
  134844. */
  134845. static AddUniforms(uniforms: string[]): void;
  134846. /**
  134847. * Add the required samplers to the current list.
  134848. * @param samplers defines the current sampler list.
  134849. */
  134850. static AddSamplers(samplers: string[]): void;
  134851. /**
  134852. * Add the required uniforms to the current buffer.
  134853. * @param uniformBuffer defines the current uniform buffer.
  134854. */
  134855. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134856. /**
  134857. * Makes a duplicate of the current configuration into another one.
  134858. * @param clearCoatConfiguration define the config where to copy the info
  134859. */
  134860. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  134861. /**
  134862. * Serializes this clear coat configuration.
  134863. * @returns - An object with the serialized config.
  134864. */
  134865. serialize(): any;
  134866. /**
  134867. * Parses a anisotropy Configuration from a serialized object.
  134868. * @param source - Serialized object.
  134869. * @param scene Defines the scene we are parsing for
  134870. * @param rootUrl Defines the rootUrl to load from
  134871. */
  134872. parse(source: any, scene: Scene, rootUrl: string): void;
  134873. }
  134874. }
  134875. declare module BABYLON {
  134876. /**
  134877. * @hidden
  134878. */
  134879. export interface IMaterialAnisotropicDefines {
  134880. ANISOTROPIC: boolean;
  134881. ANISOTROPIC_TEXTURE: boolean;
  134882. ANISOTROPIC_TEXTUREDIRECTUV: number;
  134883. MAINUV1: boolean;
  134884. _areTexturesDirty: boolean;
  134885. _needUVs: boolean;
  134886. }
  134887. /**
  134888. * Define the code related to the anisotropic parameters of the pbr material.
  134889. */
  134890. export class PBRAnisotropicConfiguration {
  134891. private _isEnabled;
  134892. /**
  134893. * Defines if the anisotropy is enabled in the material.
  134894. */
  134895. isEnabled: boolean;
  134896. /**
  134897. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  134898. */
  134899. intensity: number;
  134900. /**
  134901. * Defines if the effect is along the tangents, bitangents or in between.
  134902. * By default, the effect is "strectching" the highlights along the tangents.
  134903. */
  134904. direction: Vector2;
  134905. private _texture;
  134906. /**
  134907. * Stores the anisotropy values in a texture.
  134908. * rg is direction (like normal from -1 to 1)
  134909. * b is a intensity
  134910. */
  134911. texture: Nullable<BaseTexture>;
  134912. /** @hidden */
  134913. private _internalMarkAllSubMeshesAsTexturesDirty;
  134914. /** @hidden */
  134915. _markAllSubMeshesAsTexturesDirty(): void;
  134916. /**
  134917. * Instantiate a new istance of anisotropy configuration.
  134918. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134919. */
  134920. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  134921. /**
  134922. * Specifies that the submesh is ready to be used.
  134923. * @param defines the list of "defines" to update.
  134924. * @param scene defines the scene the material belongs to.
  134925. * @returns - boolean indicating that the submesh is ready or not.
  134926. */
  134927. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  134928. /**
  134929. * Checks to see if a texture is used in the material.
  134930. * @param defines the list of "defines" to update.
  134931. * @param mesh the mesh we are preparing the defines for.
  134932. * @param scene defines the scene the material belongs to.
  134933. */
  134934. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  134935. /**
  134936. * Binds the material data.
  134937. * @param uniformBuffer defines the Uniform buffer to fill in.
  134938. * @param scene defines the scene the material belongs to.
  134939. * @param isFrozen defines wether the material is frozen or not.
  134940. */
  134941. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  134942. /**
  134943. * Checks to see if a texture is used in the material.
  134944. * @param texture - Base texture to use.
  134945. * @returns - Boolean specifying if a texture is used in the material.
  134946. */
  134947. hasTexture(texture: BaseTexture): boolean;
  134948. /**
  134949. * Returns an array of the actively used textures.
  134950. * @param activeTextures Array of BaseTextures
  134951. */
  134952. getActiveTextures(activeTextures: BaseTexture[]): void;
  134953. /**
  134954. * Returns the animatable textures.
  134955. * @param animatables Array of animatable textures.
  134956. */
  134957. getAnimatables(animatables: IAnimatable[]): void;
  134958. /**
  134959. * Disposes the resources of the material.
  134960. * @param forceDisposeTextures - Forces the disposal of all textures.
  134961. */
  134962. dispose(forceDisposeTextures?: boolean): void;
  134963. /**
  134964. * Get the current class name of the texture useful for serialization or dynamic coding.
  134965. * @returns "PBRAnisotropicConfiguration"
  134966. */
  134967. getClassName(): string;
  134968. /**
  134969. * Add fallbacks to the effect fallbacks list.
  134970. * @param defines defines the Base texture to use.
  134971. * @param fallbacks defines the current fallback list.
  134972. * @param currentRank defines the current fallback rank.
  134973. * @returns the new fallback rank.
  134974. */
  134975. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134976. /**
  134977. * Add the required uniforms to the current list.
  134978. * @param uniforms defines the current uniform list.
  134979. */
  134980. static AddUniforms(uniforms: string[]): void;
  134981. /**
  134982. * Add the required uniforms to the current buffer.
  134983. * @param uniformBuffer defines the current uniform buffer.
  134984. */
  134985. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134986. /**
  134987. * Add the required samplers to the current list.
  134988. * @param samplers defines the current sampler list.
  134989. */
  134990. static AddSamplers(samplers: string[]): void;
  134991. /**
  134992. * Makes a duplicate of the current configuration into another one.
  134993. * @param anisotropicConfiguration define the config where to copy the info
  134994. */
  134995. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  134996. /**
  134997. * Serializes this anisotropy configuration.
  134998. * @returns - An object with the serialized config.
  134999. */
  135000. serialize(): any;
  135001. /**
  135002. * Parses a anisotropy Configuration from a serialized object.
  135003. * @param source - Serialized object.
  135004. * @param scene Defines the scene we are parsing for
  135005. * @param rootUrl Defines the rootUrl to load from
  135006. */
  135007. parse(source: any, scene: Scene, rootUrl: string): void;
  135008. }
  135009. }
  135010. declare module BABYLON {
  135011. /**
  135012. * @hidden
  135013. */
  135014. export interface IMaterialBRDFDefines {
  135015. BRDF_V_HEIGHT_CORRELATED: boolean;
  135016. MS_BRDF_ENERGY_CONSERVATION: boolean;
  135017. SPHERICAL_HARMONICS: boolean;
  135018. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  135019. /** @hidden */
  135020. _areMiscDirty: boolean;
  135021. }
  135022. /**
  135023. * Define the code related to the BRDF parameters of the pbr material.
  135024. */
  135025. export class PBRBRDFConfiguration {
  135026. /**
  135027. * Default value used for the energy conservation.
  135028. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135029. */
  135030. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  135031. /**
  135032. * Default value used for the Smith Visibility Height Correlated mode.
  135033. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135034. */
  135035. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  135036. /**
  135037. * Default value used for the IBL diffuse part.
  135038. * This can help switching back to the polynomials mode globally which is a tiny bit
  135039. * less GPU intensive at the drawback of a lower quality.
  135040. */
  135041. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  135042. /**
  135043. * Default value used for activating energy conservation for the specular workflow.
  135044. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  135045. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  135046. */
  135047. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  135048. private _useEnergyConservation;
  135049. /**
  135050. * Defines if the material uses energy conservation.
  135051. */
  135052. useEnergyConservation: boolean;
  135053. private _useSmithVisibilityHeightCorrelated;
  135054. /**
  135055. * LEGACY Mode set to false
  135056. * Defines if the material uses height smith correlated visibility term.
  135057. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  135058. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  135059. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  135060. * Not relying on height correlated will also disable energy conservation.
  135061. */
  135062. useSmithVisibilityHeightCorrelated: boolean;
  135063. private _useSphericalHarmonics;
  135064. /**
  135065. * LEGACY Mode set to false
  135066. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  135067. * diffuse part of the IBL.
  135068. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  135069. * to the ground truth.
  135070. */
  135071. useSphericalHarmonics: boolean;
  135072. private _useSpecularGlossinessInputEnergyConservation;
  135073. /**
  135074. * Defines if the material uses energy conservation, when the specular workflow is active.
  135075. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  135076. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  135077. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  135078. */
  135079. useSpecularGlossinessInputEnergyConservation: boolean;
  135080. /** @hidden */
  135081. private _internalMarkAllSubMeshesAsMiscDirty;
  135082. /** @hidden */
  135083. _markAllSubMeshesAsMiscDirty(): void;
  135084. /**
  135085. * Instantiate a new istance of clear coat configuration.
  135086. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  135087. */
  135088. constructor(markAllSubMeshesAsMiscDirty: () => void);
  135089. /**
  135090. * Checks to see if a texture is used in the material.
  135091. * @param defines the list of "defines" to update.
  135092. */
  135093. prepareDefines(defines: IMaterialBRDFDefines): void;
  135094. /**
  135095. * Get the current class name of the texture useful for serialization or dynamic coding.
  135096. * @returns "PBRClearCoatConfiguration"
  135097. */
  135098. getClassName(): string;
  135099. /**
  135100. * Makes a duplicate of the current configuration into another one.
  135101. * @param brdfConfiguration define the config where to copy the info
  135102. */
  135103. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  135104. /**
  135105. * Serializes this BRDF configuration.
  135106. * @returns - An object with the serialized config.
  135107. */
  135108. serialize(): any;
  135109. /**
  135110. * Parses a anisotropy Configuration from a serialized object.
  135111. * @param source - Serialized object.
  135112. * @param scene Defines the scene we are parsing for
  135113. * @param rootUrl Defines the rootUrl to load from
  135114. */
  135115. parse(source: any, scene: Scene, rootUrl: string): void;
  135116. }
  135117. }
  135118. declare module BABYLON {
  135119. /**
  135120. * @hidden
  135121. */
  135122. export interface IMaterialSheenDefines {
  135123. SHEEN: boolean;
  135124. SHEEN_TEXTURE: boolean;
  135125. SHEEN_TEXTUREDIRECTUV: number;
  135126. SHEEN_LINKWITHALBEDO: boolean;
  135127. SHEEN_ROUGHNESS: boolean;
  135128. SHEEN_ALBEDOSCALING: boolean;
  135129. /** @hidden */
  135130. _areTexturesDirty: boolean;
  135131. }
  135132. /**
  135133. * Define the code related to the Sheen parameters of the pbr material.
  135134. */
  135135. export class PBRSheenConfiguration {
  135136. private _isEnabled;
  135137. /**
  135138. * Defines if the material uses sheen.
  135139. */
  135140. isEnabled: boolean;
  135141. private _linkSheenWithAlbedo;
  135142. /**
  135143. * Defines if the sheen is linked to the sheen color.
  135144. */
  135145. linkSheenWithAlbedo: boolean;
  135146. /**
  135147. * Defines the sheen intensity.
  135148. */
  135149. intensity: number;
  135150. /**
  135151. * Defines the sheen color.
  135152. */
  135153. color: Color3;
  135154. private _texture;
  135155. /**
  135156. * Stores the sheen tint values in a texture.
  135157. * rgb is tint
  135158. * a is a intensity or roughness if roughness has been defined
  135159. */
  135160. texture: Nullable<BaseTexture>;
  135161. private _roughness;
  135162. /**
  135163. * Defines the sheen roughness.
  135164. * It is not taken into account if linkSheenWithAlbedo is true.
  135165. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  135166. */
  135167. roughness: Nullable<number>;
  135168. private _albedoScaling;
  135169. /**
  135170. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  135171. * It allows the strength of the sheen effect to not depend on the base color of the material,
  135172. * making it easier to setup and tweak the effect
  135173. */
  135174. albedoScaling: boolean;
  135175. /** @hidden */
  135176. private _internalMarkAllSubMeshesAsTexturesDirty;
  135177. /** @hidden */
  135178. _markAllSubMeshesAsTexturesDirty(): void;
  135179. /**
  135180. * Instantiate a new istance of clear coat configuration.
  135181. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135182. */
  135183. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135184. /**
  135185. * Specifies that the submesh is ready to be used.
  135186. * @param defines the list of "defines" to update.
  135187. * @param scene defines the scene the material belongs to.
  135188. * @returns - boolean indicating that the submesh is ready or not.
  135189. */
  135190. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  135191. /**
  135192. * Checks to see if a texture is used in the material.
  135193. * @param defines the list of "defines" to update.
  135194. * @param scene defines the scene the material belongs to.
  135195. */
  135196. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  135197. /**
  135198. * Binds the material data.
  135199. * @param uniformBuffer defines the Uniform buffer to fill in.
  135200. * @param scene defines the scene the material belongs to.
  135201. * @param isFrozen defines wether the material is frozen or not.
  135202. */
  135203. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135204. /**
  135205. * Checks to see if a texture is used in the material.
  135206. * @param texture - Base texture to use.
  135207. * @returns - Boolean specifying if a texture is used in the material.
  135208. */
  135209. hasTexture(texture: BaseTexture): boolean;
  135210. /**
  135211. * Returns an array of the actively used textures.
  135212. * @param activeTextures Array of BaseTextures
  135213. */
  135214. getActiveTextures(activeTextures: BaseTexture[]): void;
  135215. /**
  135216. * Returns the animatable textures.
  135217. * @param animatables Array of animatable textures.
  135218. */
  135219. getAnimatables(animatables: IAnimatable[]): void;
  135220. /**
  135221. * Disposes the resources of the material.
  135222. * @param forceDisposeTextures - Forces the disposal of all textures.
  135223. */
  135224. dispose(forceDisposeTextures?: boolean): void;
  135225. /**
  135226. * Get the current class name of the texture useful for serialization or dynamic coding.
  135227. * @returns "PBRSheenConfiguration"
  135228. */
  135229. getClassName(): string;
  135230. /**
  135231. * Add fallbacks to the effect fallbacks list.
  135232. * @param defines defines the Base texture to use.
  135233. * @param fallbacks defines the current fallback list.
  135234. * @param currentRank defines the current fallback rank.
  135235. * @returns the new fallback rank.
  135236. */
  135237. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135238. /**
  135239. * Add the required uniforms to the current list.
  135240. * @param uniforms defines the current uniform list.
  135241. */
  135242. static AddUniforms(uniforms: string[]): void;
  135243. /**
  135244. * Add the required uniforms to the current buffer.
  135245. * @param uniformBuffer defines the current uniform buffer.
  135246. */
  135247. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135248. /**
  135249. * Add the required samplers to the current list.
  135250. * @param samplers defines the current sampler list.
  135251. */
  135252. static AddSamplers(samplers: string[]): void;
  135253. /**
  135254. * Makes a duplicate of the current configuration into another one.
  135255. * @param sheenConfiguration define the config where to copy the info
  135256. */
  135257. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  135258. /**
  135259. * Serializes this BRDF configuration.
  135260. * @returns - An object with the serialized config.
  135261. */
  135262. serialize(): any;
  135263. /**
  135264. * Parses a anisotropy Configuration from a serialized object.
  135265. * @param source - Serialized object.
  135266. * @param scene Defines the scene we are parsing for
  135267. * @param rootUrl Defines the rootUrl to load from
  135268. */
  135269. parse(source: any, scene: Scene, rootUrl: string): void;
  135270. }
  135271. }
  135272. declare module BABYLON {
  135273. /**
  135274. * @hidden
  135275. */
  135276. export interface IMaterialSubSurfaceDefines {
  135277. SUBSURFACE: boolean;
  135278. SS_REFRACTION: boolean;
  135279. SS_TRANSLUCENCY: boolean;
  135280. SS_SCATTERING: boolean;
  135281. SS_THICKNESSANDMASK_TEXTURE: boolean;
  135282. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  135283. SS_REFRACTIONMAP_3D: boolean;
  135284. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  135285. SS_LODINREFRACTIONALPHA: boolean;
  135286. SS_GAMMAREFRACTION: boolean;
  135287. SS_RGBDREFRACTION: boolean;
  135288. SS_LINEARSPECULARREFRACTION: boolean;
  135289. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  135290. SS_ALBEDOFORREFRACTIONTINT: boolean;
  135291. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  135292. /** @hidden */
  135293. _areTexturesDirty: boolean;
  135294. }
  135295. /**
  135296. * Define the code related to the sub surface parameters of the pbr material.
  135297. */
  135298. export class PBRSubSurfaceConfiguration {
  135299. private _isRefractionEnabled;
  135300. /**
  135301. * Defines if the refraction is enabled in the material.
  135302. */
  135303. isRefractionEnabled: boolean;
  135304. private _isTranslucencyEnabled;
  135305. /**
  135306. * Defines if the translucency is enabled in the material.
  135307. */
  135308. isTranslucencyEnabled: boolean;
  135309. private _isScatteringEnabled;
  135310. /**
  135311. * Defines if the sub surface scattering is enabled in the material.
  135312. */
  135313. isScatteringEnabled: boolean;
  135314. private _scatteringDiffusionProfileIndex;
  135315. /**
  135316. * Diffusion profile for subsurface scattering.
  135317. * Useful for better scattering in the skins or foliages.
  135318. */
  135319. get scatteringDiffusionProfile(): Nullable<Color3>;
  135320. set scatteringDiffusionProfile(c: Nullable<Color3>);
  135321. /**
  135322. * Defines the refraction intensity of the material.
  135323. * The refraction when enabled replaces the Diffuse part of the material.
  135324. * The intensity helps transitionning between diffuse and refraction.
  135325. */
  135326. refractionIntensity: number;
  135327. /**
  135328. * Defines the translucency intensity of the material.
  135329. * When translucency has been enabled, this defines how much of the "translucency"
  135330. * is addded to the diffuse part of the material.
  135331. */
  135332. translucencyIntensity: number;
  135333. /**
  135334. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  135335. */
  135336. useAlbedoToTintRefraction: boolean;
  135337. private _thicknessTexture;
  135338. /**
  135339. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  135340. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  135341. * 0 would mean minimumThickness
  135342. * 1 would mean maximumThickness
  135343. * The other channels might be use as a mask to vary the different effects intensity.
  135344. */
  135345. thicknessTexture: Nullable<BaseTexture>;
  135346. private _refractionTexture;
  135347. /**
  135348. * Defines the texture to use for refraction.
  135349. */
  135350. refractionTexture: Nullable<BaseTexture>;
  135351. private _indexOfRefraction;
  135352. /**
  135353. * Index of refraction of the material base layer.
  135354. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135355. *
  135356. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  135357. *
  135358. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  135359. */
  135360. indexOfRefraction: number;
  135361. private _volumeIndexOfRefraction;
  135362. /**
  135363. * Index of refraction of the material's volume.
  135364. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135365. *
  135366. * This ONLY impacts refraction. If not provided or given a non-valid value,
  135367. * the volume will use the same IOR as the surface.
  135368. */
  135369. get volumeIndexOfRefraction(): number;
  135370. set volumeIndexOfRefraction(value: number);
  135371. private _invertRefractionY;
  135372. /**
  135373. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  135374. */
  135375. invertRefractionY: boolean;
  135376. private _linkRefractionWithTransparency;
  135377. /**
  135378. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  135379. * Materials half opaque for instance using refraction could benefit from this control.
  135380. */
  135381. linkRefractionWithTransparency: boolean;
  135382. /**
  135383. * Defines the minimum thickness stored in the thickness map.
  135384. * If no thickness map is defined, this value will be used to simulate thickness.
  135385. */
  135386. minimumThickness: number;
  135387. /**
  135388. * Defines the maximum thickness stored in the thickness map.
  135389. */
  135390. maximumThickness: number;
  135391. /**
  135392. * Defines the volume tint of the material.
  135393. * This is used for both translucency and scattering.
  135394. */
  135395. tintColor: Color3;
  135396. /**
  135397. * Defines the distance at which the tint color should be found in the media.
  135398. * This is used for refraction only.
  135399. */
  135400. tintColorAtDistance: number;
  135401. /**
  135402. * Defines how far each channel transmit through the media.
  135403. * It is defined as a color to simplify it selection.
  135404. */
  135405. diffusionDistance: Color3;
  135406. private _useMaskFromThicknessTexture;
  135407. /**
  135408. * Stores the intensity of the different subsurface effects in the thickness texture.
  135409. * * the green channel is the translucency intensity.
  135410. * * the blue channel is the scattering intensity.
  135411. * * the alpha channel is the refraction intensity.
  135412. */
  135413. useMaskFromThicknessTexture: boolean;
  135414. private _scene;
  135415. /** @hidden */
  135416. private _internalMarkAllSubMeshesAsTexturesDirty;
  135417. private _internalMarkScenePrePassDirty;
  135418. /** @hidden */
  135419. _markAllSubMeshesAsTexturesDirty(): void;
  135420. /** @hidden */
  135421. _markScenePrePassDirty(): void;
  135422. /**
  135423. * Instantiate a new istance of sub surface configuration.
  135424. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135425. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  135426. * @param scene The scene
  135427. */
  135428. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  135429. /**
  135430. * Gets wehter the submesh is ready to be used or not.
  135431. * @param defines the list of "defines" to update.
  135432. * @param scene defines the scene the material belongs to.
  135433. * @returns - boolean indicating that the submesh is ready or not.
  135434. */
  135435. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  135436. /**
  135437. * Checks to see if a texture is used in the material.
  135438. * @param defines the list of "defines" to update.
  135439. * @param scene defines the scene to the material belongs to.
  135440. */
  135441. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  135442. /**
  135443. * Binds the material data.
  135444. * @param uniformBuffer defines the Uniform buffer to fill in.
  135445. * @param scene defines the scene the material belongs to.
  135446. * @param engine defines the engine the material belongs to.
  135447. * @param isFrozen defines whether the material is frozen or not.
  135448. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  135449. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  135450. */
  135451. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  135452. /**
  135453. * Unbinds the material from the mesh.
  135454. * @param activeEffect defines the effect that should be unbound from.
  135455. * @returns true if unbound, otherwise false
  135456. */
  135457. unbind(activeEffect: Effect): boolean;
  135458. /**
  135459. * Returns the texture used for refraction or null if none is used.
  135460. * @param scene defines the scene the material belongs to.
  135461. * @returns - Refraction texture if present. If no refraction texture and refraction
  135462. * is linked with transparency, returns environment texture. Otherwise, returns null.
  135463. */
  135464. private _getRefractionTexture;
  135465. /**
  135466. * Returns true if alpha blending should be disabled.
  135467. */
  135468. get disableAlphaBlending(): boolean;
  135469. /**
  135470. * Fills the list of render target textures.
  135471. * @param renderTargets the list of render targets to update
  135472. */
  135473. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  135474. /**
  135475. * Checks to see if a texture is used in the material.
  135476. * @param texture - Base texture to use.
  135477. * @returns - Boolean specifying if a texture is used in the material.
  135478. */
  135479. hasTexture(texture: BaseTexture): boolean;
  135480. /**
  135481. * Gets a boolean indicating that current material needs to register RTT
  135482. * @returns true if this uses a render target otherwise false.
  135483. */
  135484. hasRenderTargetTextures(): boolean;
  135485. /**
  135486. * Returns an array of the actively used textures.
  135487. * @param activeTextures Array of BaseTextures
  135488. */
  135489. getActiveTextures(activeTextures: BaseTexture[]): void;
  135490. /**
  135491. * Returns the animatable textures.
  135492. * @param animatables Array of animatable textures.
  135493. */
  135494. getAnimatables(animatables: IAnimatable[]): void;
  135495. /**
  135496. * Disposes the resources of the material.
  135497. * @param forceDisposeTextures - Forces the disposal of all textures.
  135498. */
  135499. dispose(forceDisposeTextures?: boolean): void;
  135500. /**
  135501. * Get the current class name of the texture useful for serialization or dynamic coding.
  135502. * @returns "PBRSubSurfaceConfiguration"
  135503. */
  135504. getClassName(): string;
  135505. /**
  135506. * Add fallbacks to the effect fallbacks list.
  135507. * @param defines defines the Base texture to use.
  135508. * @param fallbacks defines the current fallback list.
  135509. * @param currentRank defines the current fallback rank.
  135510. * @returns the new fallback rank.
  135511. */
  135512. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135513. /**
  135514. * Add the required uniforms to the current list.
  135515. * @param uniforms defines the current uniform list.
  135516. */
  135517. static AddUniforms(uniforms: string[]): void;
  135518. /**
  135519. * Add the required samplers to the current list.
  135520. * @param samplers defines the current sampler list.
  135521. */
  135522. static AddSamplers(samplers: string[]): void;
  135523. /**
  135524. * Add the required uniforms to the current buffer.
  135525. * @param uniformBuffer defines the current uniform buffer.
  135526. */
  135527. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135528. /**
  135529. * Makes a duplicate of the current configuration into another one.
  135530. * @param configuration define the config where to copy the info
  135531. */
  135532. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  135533. /**
  135534. * Serializes this Sub Surface configuration.
  135535. * @returns - An object with the serialized config.
  135536. */
  135537. serialize(): any;
  135538. /**
  135539. * Parses a anisotropy Configuration from a serialized object.
  135540. * @param source - Serialized object.
  135541. * @param scene Defines the scene we are parsing for
  135542. * @param rootUrl Defines the rootUrl to load from
  135543. */
  135544. parse(source: any, scene: Scene, rootUrl: string): void;
  135545. }
  135546. }
  135547. declare module BABYLON {
  135548. /** @hidden */
  135549. export var pbrFragmentDeclaration: {
  135550. name: string;
  135551. shader: string;
  135552. };
  135553. }
  135554. declare module BABYLON {
  135555. /** @hidden */
  135556. export var pbrUboDeclaration: {
  135557. name: string;
  135558. shader: string;
  135559. };
  135560. }
  135561. declare module BABYLON {
  135562. /** @hidden */
  135563. export var pbrFragmentExtraDeclaration: {
  135564. name: string;
  135565. shader: string;
  135566. };
  135567. }
  135568. declare module BABYLON {
  135569. /** @hidden */
  135570. export var pbrFragmentSamplersDeclaration: {
  135571. name: string;
  135572. shader: string;
  135573. };
  135574. }
  135575. declare module BABYLON {
  135576. /** @hidden */
  135577. export var importanceSampling: {
  135578. name: string;
  135579. shader: string;
  135580. };
  135581. }
  135582. declare module BABYLON {
  135583. /** @hidden */
  135584. export var pbrHelperFunctions: {
  135585. name: string;
  135586. shader: string;
  135587. };
  135588. }
  135589. declare module BABYLON {
  135590. /** @hidden */
  135591. export var harmonicsFunctions: {
  135592. name: string;
  135593. shader: string;
  135594. };
  135595. }
  135596. declare module BABYLON {
  135597. /** @hidden */
  135598. export var pbrDirectLightingSetupFunctions: {
  135599. name: string;
  135600. shader: string;
  135601. };
  135602. }
  135603. declare module BABYLON {
  135604. /** @hidden */
  135605. export var pbrDirectLightingFalloffFunctions: {
  135606. name: string;
  135607. shader: string;
  135608. };
  135609. }
  135610. declare module BABYLON {
  135611. /** @hidden */
  135612. export var pbrBRDFFunctions: {
  135613. name: string;
  135614. shader: string;
  135615. };
  135616. }
  135617. declare module BABYLON {
  135618. /** @hidden */
  135619. export var hdrFilteringFunctions: {
  135620. name: string;
  135621. shader: string;
  135622. };
  135623. }
  135624. declare module BABYLON {
  135625. /** @hidden */
  135626. export var pbrDirectLightingFunctions: {
  135627. name: string;
  135628. shader: string;
  135629. };
  135630. }
  135631. declare module BABYLON {
  135632. /** @hidden */
  135633. export var pbrIBLFunctions: {
  135634. name: string;
  135635. shader: string;
  135636. };
  135637. }
  135638. declare module BABYLON {
  135639. /** @hidden */
  135640. export var pbrBlockAlbedoOpacity: {
  135641. name: string;
  135642. shader: string;
  135643. };
  135644. }
  135645. declare module BABYLON {
  135646. /** @hidden */
  135647. export var pbrBlockReflectivity: {
  135648. name: string;
  135649. shader: string;
  135650. };
  135651. }
  135652. declare module BABYLON {
  135653. /** @hidden */
  135654. export var pbrBlockAmbientOcclusion: {
  135655. name: string;
  135656. shader: string;
  135657. };
  135658. }
  135659. declare module BABYLON {
  135660. /** @hidden */
  135661. export var pbrBlockAlphaFresnel: {
  135662. name: string;
  135663. shader: string;
  135664. };
  135665. }
  135666. declare module BABYLON {
  135667. /** @hidden */
  135668. export var pbrBlockAnisotropic: {
  135669. name: string;
  135670. shader: string;
  135671. };
  135672. }
  135673. declare module BABYLON {
  135674. /** @hidden */
  135675. export var pbrBlockReflection: {
  135676. name: string;
  135677. shader: string;
  135678. };
  135679. }
  135680. declare module BABYLON {
  135681. /** @hidden */
  135682. export var pbrBlockSheen: {
  135683. name: string;
  135684. shader: string;
  135685. };
  135686. }
  135687. declare module BABYLON {
  135688. /** @hidden */
  135689. export var pbrBlockClearcoat: {
  135690. name: string;
  135691. shader: string;
  135692. };
  135693. }
  135694. declare module BABYLON {
  135695. /** @hidden */
  135696. export var pbrBlockSubSurface: {
  135697. name: string;
  135698. shader: string;
  135699. };
  135700. }
  135701. declare module BABYLON {
  135702. /** @hidden */
  135703. export var pbrBlockNormalGeometric: {
  135704. name: string;
  135705. shader: string;
  135706. };
  135707. }
  135708. declare module BABYLON {
  135709. /** @hidden */
  135710. export var pbrBlockNormalFinal: {
  135711. name: string;
  135712. shader: string;
  135713. };
  135714. }
  135715. declare module BABYLON {
  135716. /** @hidden */
  135717. export var pbrBlockLightmapInit: {
  135718. name: string;
  135719. shader: string;
  135720. };
  135721. }
  135722. declare module BABYLON {
  135723. /** @hidden */
  135724. export var pbrBlockGeometryInfo: {
  135725. name: string;
  135726. shader: string;
  135727. };
  135728. }
  135729. declare module BABYLON {
  135730. /** @hidden */
  135731. export var pbrBlockReflectance0: {
  135732. name: string;
  135733. shader: string;
  135734. };
  135735. }
  135736. declare module BABYLON {
  135737. /** @hidden */
  135738. export var pbrBlockReflectance: {
  135739. name: string;
  135740. shader: string;
  135741. };
  135742. }
  135743. declare module BABYLON {
  135744. /** @hidden */
  135745. export var pbrBlockDirectLighting: {
  135746. name: string;
  135747. shader: string;
  135748. };
  135749. }
  135750. declare module BABYLON {
  135751. /** @hidden */
  135752. export var pbrBlockFinalLitComponents: {
  135753. name: string;
  135754. shader: string;
  135755. };
  135756. }
  135757. declare module BABYLON {
  135758. /** @hidden */
  135759. export var pbrBlockFinalUnlitComponents: {
  135760. name: string;
  135761. shader: string;
  135762. };
  135763. }
  135764. declare module BABYLON {
  135765. /** @hidden */
  135766. export var pbrBlockFinalColorComposition: {
  135767. name: string;
  135768. shader: string;
  135769. };
  135770. }
  135771. declare module BABYLON {
  135772. /** @hidden */
  135773. export var pbrBlockImageProcessing: {
  135774. name: string;
  135775. shader: string;
  135776. };
  135777. }
  135778. declare module BABYLON {
  135779. /** @hidden */
  135780. export var pbrDebug: {
  135781. name: string;
  135782. shader: string;
  135783. };
  135784. }
  135785. declare module BABYLON {
  135786. /** @hidden */
  135787. export var pbrPixelShader: {
  135788. name: string;
  135789. shader: string;
  135790. };
  135791. }
  135792. declare module BABYLON {
  135793. /** @hidden */
  135794. export var pbrVertexDeclaration: {
  135795. name: string;
  135796. shader: string;
  135797. };
  135798. }
  135799. declare module BABYLON {
  135800. /** @hidden */
  135801. export var pbrVertexShader: {
  135802. name: string;
  135803. shader: string;
  135804. };
  135805. }
  135806. declare module BABYLON {
  135807. /**
  135808. * Manages the defines for the PBR Material.
  135809. * @hidden
  135810. */
  135811. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  135812. PBR: boolean;
  135813. NUM_SAMPLES: string;
  135814. REALTIME_FILTERING: boolean;
  135815. MAINUV1: boolean;
  135816. MAINUV2: boolean;
  135817. UV1: boolean;
  135818. UV2: boolean;
  135819. ALBEDO: boolean;
  135820. GAMMAALBEDO: boolean;
  135821. ALBEDODIRECTUV: number;
  135822. VERTEXCOLOR: boolean;
  135823. DETAIL: boolean;
  135824. DETAILDIRECTUV: number;
  135825. DETAIL_NORMALBLENDMETHOD: number;
  135826. AMBIENT: boolean;
  135827. AMBIENTDIRECTUV: number;
  135828. AMBIENTINGRAYSCALE: boolean;
  135829. OPACITY: boolean;
  135830. VERTEXALPHA: boolean;
  135831. OPACITYDIRECTUV: number;
  135832. OPACITYRGB: boolean;
  135833. ALPHATEST: boolean;
  135834. DEPTHPREPASS: boolean;
  135835. ALPHABLEND: boolean;
  135836. ALPHAFROMALBEDO: boolean;
  135837. ALPHATESTVALUE: string;
  135838. SPECULAROVERALPHA: boolean;
  135839. RADIANCEOVERALPHA: boolean;
  135840. ALPHAFRESNEL: boolean;
  135841. LINEARALPHAFRESNEL: boolean;
  135842. PREMULTIPLYALPHA: boolean;
  135843. EMISSIVE: boolean;
  135844. EMISSIVEDIRECTUV: number;
  135845. REFLECTIVITY: boolean;
  135846. REFLECTIVITYDIRECTUV: number;
  135847. SPECULARTERM: boolean;
  135848. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  135849. MICROSURFACEAUTOMATIC: boolean;
  135850. LODBASEDMICROSFURACE: boolean;
  135851. MICROSURFACEMAP: boolean;
  135852. MICROSURFACEMAPDIRECTUV: number;
  135853. METALLICWORKFLOW: boolean;
  135854. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  135855. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  135856. METALLNESSSTOREINMETALMAPBLUE: boolean;
  135857. AOSTOREINMETALMAPRED: boolean;
  135858. METALLIC_REFLECTANCE: boolean;
  135859. METALLIC_REFLECTANCEDIRECTUV: number;
  135860. ENVIRONMENTBRDF: boolean;
  135861. ENVIRONMENTBRDF_RGBD: boolean;
  135862. NORMAL: boolean;
  135863. TANGENT: boolean;
  135864. BUMP: boolean;
  135865. BUMPDIRECTUV: number;
  135866. OBJECTSPACE_NORMALMAP: boolean;
  135867. PARALLAX: boolean;
  135868. PARALLAXOCCLUSION: boolean;
  135869. NORMALXYSCALE: boolean;
  135870. LIGHTMAP: boolean;
  135871. LIGHTMAPDIRECTUV: number;
  135872. USELIGHTMAPASSHADOWMAP: boolean;
  135873. GAMMALIGHTMAP: boolean;
  135874. RGBDLIGHTMAP: boolean;
  135875. REFLECTION: boolean;
  135876. REFLECTIONMAP_3D: boolean;
  135877. REFLECTIONMAP_SPHERICAL: boolean;
  135878. REFLECTIONMAP_PLANAR: boolean;
  135879. REFLECTIONMAP_CUBIC: boolean;
  135880. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  135881. REFLECTIONMAP_PROJECTION: boolean;
  135882. REFLECTIONMAP_SKYBOX: boolean;
  135883. REFLECTIONMAP_EXPLICIT: boolean;
  135884. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  135885. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  135886. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  135887. INVERTCUBICMAP: boolean;
  135888. USESPHERICALFROMREFLECTIONMAP: boolean;
  135889. USEIRRADIANCEMAP: boolean;
  135890. SPHERICAL_HARMONICS: boolean;
  135891. USESPHERICALINVERTEX: boolean;
  135892. REFLECTIONMAP_OPPOSITEZ: boolean;
  135893. LODINREFLECTIONALPHA: boolean;
  135894. GAMMAREFLECTION: boolean;
  135895. RGBDREFLECTION: boolean;
  135896. LINEARSPECULARREFLECTION: boolean;
  135897. RADIANCEOCCLUSION: boolean;
  135898. HORIZONOCCLUSION: boolean;
  135899. INSTANCES: boolean;
  135900. THIN_INSTANCES: boolean;
  135901. PREPASS: boolean;
  135902. SCENE_MRT_COUNT: number;
  135903. NUM_BONE_INFLUENCERS: number;
  135904. BonesPerMesh: number;
  135905. BONETEXTURE: boolean;
  135906. NONUNIFORMSCALING: boolean;
  135907. MORPHTARGETS: boolean;
  135908. MORPHTARGETS_NORMAL: boolean;
  135909. MORPHTARGETS_TANGENT: boolean;
  135910. MORPHTARGETS_UV: boolean;
  135911. NUM_MORPH_INFLUENCERS: number;
  135912. IMAGEPROCESSING: boolean;
  135913. VIGNETTE: boolean;
  135914. VIGNETTEBLENDMODEMULTIPLY: boolean;
  135915. VIGNETTEBLENDMODEOPAQUE: boolean;
  135916. TONEMAPPING: boolean;
  135917. TONEMAPPING_ACES: boolean;
  135918. CONTRAST: boolean;
  135919. COLORCURVES: boolean;
  135920. COLORGRADING: boolean;
  135921. COLORGRADING3D: boolean;
  135922. SAMPLER3DGREENDEPTH: boolean;
  135923. SAMPLER3DBGRMAP: boolean;
  135924. IMAGEPROCESSINGPOSTPROCESS: boolean;
  135925. EXPOSURE: boolean;
  135926. MULTIVIEW: boolean;
  135927. USEPHYSICALLIGHTFALLOFF: boolean;
  135928. USEGLTFLIGHTFALLOFF: boolean;
  135929. TWOSIDEDLIGHTING: boolean;
  135930. SHADOWFLOAT: boolean;
  135931. CLIPPLANE: boolean;
  135932. CLIPPLANE2: boolean;
  135933. CLIPPLANE3: boolean;
  135934. CLIPPLANE4: boolean;
  135935. CLIPPLANE5: boolean;
  135936. CLIPPLANE6: boolean;
  135937. POINTSIZE: boolean;
  135938. FOG: boolean;
  135939. LOGARITHMICDEPTH: boolean;
  135940. FORCENORMALFORWARD: boolean;
  135941. SPECULARAA: boolean;
  135942. CLEARCOAT: boolean;
  135943. CLEARCOAT_DEFAULTIOR: boolean;
  135944. CLEARCOAT_TEXTURE: boolean;
  135945. CLEARCOAT_TEXTUREDIRECTUV: number;
  135946. CLEARCOAT_BUMP: boolean;
  135947. CLEARCOAT_BUMPDIRECTUV: number;
  135948. CLEARCOAT_TINT: boolean;
  135949. CLEARCOAT_TINT_TEXTURE: boolean;
  135950. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  135951. ANISOTROPIC: boolean;
  135952. ANISOTROPIC_TEXTURE: boolean;
  135953. ANISOTROPIC_TEXTUREDIRECTUV: number;
  135954. BRDF_V_HEIGHT_CORRELATED: boolean;
  135955. MS_BRDF_ENERGY_CONSERVATION: boolean;
  135956. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  135957. SHEEN: boolean;
  135958. SHEEN_TEXTURE: boolean;
  135959. SHEEN_TEXTUREDIRECTUV: number;
  135960. SHEEN_LINKWITHALBEDO: boolean;
  135961. SHEEN_ROUGHNESS: boolean;
  135962. SHEEN_ALBEDOSCALING: boolean;
  135963. SUBSURFACE: boolean;
  135964. SS_REFRACTION: boolean;
  135965. SS_TRANSLUCENCY: boolean;
  135966. SS_SCATTERING: boolean;
  135967. SS_THICKNESSANDMASK_TEXTURE: boolean;
  135968. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  135969. SS_REFRACTIONMAP_3D: boolean;
  135970. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  135971. SS_LODINREFRACTIONALPHA: boolean;
  135972. SS_GAMMAREFRACTION: boolean;
  135973. SS_RGBDREFRACTION: boolean;
  135974. SS_LINEARSPECULARREFRACTION: boolean;
  135975. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  135976. SS_ALBEDOFORREFRACTIONTINT: boolean;
  135977. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  135978. UNLIT: boolean;
  135979. DEBUGMODE: number;
  135980. /**
  135981. * Initializes the PBR Material defines.
  135982. */
  135983. constructor();
  135984. /**
  135985. * Resets the PBR Material defines.
  135986. */
  135987. reset(): void;
  135988. }
  135989. /**
  135990. * The Physically based material base class of BJS.
  135991. *
  135992. * This offers the main features of a standard PBR material.
  135993. * For more information, please refer to the documentation :
  135994. * https://doc.babylonjs.com/how_to/physically_based_rendering
  135995. */
  135996. export abstract class PBRBaseMaterial extends PushMaterial {
  135997. /**
  135998. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  135999. */
  136000. static readonly PBRMATERIAL_OPAQUE: number;
  136001. /**
  136002. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136003. */
  136004. static readonly PBRMATERIAL_ALPHATEST: number;
  136005. /**
  136006. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136007. */
  136008. static readonly PBRMATERIAL_ALPHABLEND: number;
  136009. /**
  136010. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136011. * They are also discarded below the alpha cutoff threshold to improve performances.
  136012. */
  136013. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  136014. /**
  136015. * Defines the default value of how much AO map is occluding the analytical lights
  136016. * (point spot...).
  136017. */
  136018. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  136019. /**
  136020. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  136021. */
  136022. static readonly LIGHTFALLOFF_PHYSICAL: number;
  136023. /**
  136024. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  136025. * to enhance interoperability with other engines.
  136026. */
  136027. static readonly LIGHTFALLOFF_GLTF: number;
  136028. /**
  136029. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  136030. * to enhance interoperability with other materials.
  136031. */
  136032. static readonly LIGHTFALLOFF_STANDARD: number;
  136033. /**
  136034. * Intensity of the direct lights e.g. the four lights available in your scene.
  136035. * This impacts both the direct diffuse and specular highlights.
  136036. */
  136037. protected _directIntensity: number;
  136038. /**
  136039. * Intensity of the emissive part of the material.
  136040. * This helps controlling the emissive effect without modifying the emissive color.
  136041. */
  136042. protected _emissiveIntensity: number;
  136043. /**
  136044. * Intensity of the environment e.g. how much the environment will light the object
  136045. * either through harmonics for rough material or through the refelction for shiny ones.
  136046. */
  136047. protected _environmentIntensity: number;
  136048. /**
  136049. * This is a special control allowing the reduction of the specular highlights coming from the
  136050. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  136051. */
  136052. protected _specularIntensity: number;
  136053. /**
  136054. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  136055. */
  136056. private _lightingInfos;
  136057. /**
  136058. * Debug Control allowing disabling the bump map on this material.
  136059. */
  136060. protected _disableBumpMap: boolean;
  136061. /**
  136062. * AKA Diffuse Texture in standard nomenclature.
  136063. */
  136064. protected _albedoTexture: Nullable<BaseTexture>;
  136065. /**
  136066. * AKA Occlusion Texture in other nomenclature.
  136067. */
  136068. protected _ambientTexture: Nullable<BaseTexture>;
  136069. /**
  136070. * AKA Occlusion Texture Intensity in other nomenclature.
  136071. */
  136072. protected _ambientTextureStrength: number;
  136073. /**
  136074. * Defines how much the AO map is occluding the analytical lights (point spot...).
  136075. * 1 means it completely occludes it
  136076. * 0 mean it has no impact
  136077. */
  136078. protected _ambientTextureImpactOnAnalyticalLights: number;
  136079. /**
  136080. * Stores the alpha values in a texture.
  136081. */
  136082. protected _opacityTexture: Nullable<BaseTexture>;
  136083. /**
  136084. * Stores the reflection values in a texture.
  136085. */
  136086. protected _reflectionTexture: Nullable<BaseTexture>;
  136087. /**
  136088. * Stores the emissive values in a texture.
  136089. */
  136090. protected _emissiveTexture: Nullable<BaseTexture>;
  136091. /**
  136092. * AKA Specular texture in other nomenclature.
  136093. */
  136094. protected _reflectivityTexture: Nullable<BaseTexture>;
  136095. /**
  136096. * Used to switch from specular/glossiness to metallic/roughness workflow.
  136097. */
  136098. protected _metallicTexture: Nullable<BaseTexture>;
  136099. /**
  136100. * Specifies the metallic scalar of the metallic/roughness workflow.
  136101. * Can also be used to scale the metalness values of the metallic texture.
  136102. */
  136103. protected _metallic: Nullable<number>;
  136104. /**
  136105. * Specifies the roughness scalar of the metallic/roughness workflow.
  136106. * Can also be used to scale the roughness values of the metallic texture.
  136107. */
  136108. protected _roughness: Nullable<number>;
  136109. /**
  136110. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  136111. * By default the indexOfrefraction is used to compute F0;
  136112. *
  136113. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  136114. *
  136115. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  136116. * F90 = metallicReflectanceColor;
  136117. */
  136118. protected _metallicF0Factor: number;
  136119. /**
  136120. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  136121. * By default the F90 is always 1;
  136122. *
  136123. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  136124. *
  136125. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  136126. * F90 = metallicReflectanceColor;
  136127. */
  136128. protected _metallicReflectanceColor: Color3;
  136129. /**
  136130. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  136131. * This is multiply against the scalar values defined in the material.
  136132. */
  136133. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  136134. /**
  136135. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  136136. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  136137. */
  136138. protected _microSurfaceTexture: Nullable<BaseTexture>;
  136139. /**
  136140. * Stores surface normal data used to displace a mesh in a texture.
  136141. */
  136142. protected _bumpTexture: Nullable<BaseTexture>;
  136143. /**
  136144. * Stores the pre-calculated light information of a mesh in a texture.
  136145. */
  136146. protected _lightmapTexture: Nullable<BaseTexture>;
  136147. /**
  136148. * The color of a material in ambient lighting.
  136149. */
  136150. protected _ambientColor: Color3;
  136151. /**
  136152. * AKA Diffuse Color in other nomenclature.
  136153. */
  136154. protected _albedoColor: Color3;
  136155. /**
  136156. * AKA Specular Color in other nomenclature.
  136157. */
  136158. protected _reflectivityColor: Color3;
  136159. /**
  136160. * The color applied when light is reflected from a material.
  136161. */
  136162. protected _reflectionColor: Color3;
  136163. /**
  136164. * The color applied when light is emitted from a material.
  136165. */
  136166. protected _emissiveColor: Color3;
  136167. /**
  136168. * AKA Glossiness in other nomenclature.
  136169. */
  136170. protected _microSurface: number;
  136171. /**
  136172. * Specifies that the material will use the light map as a show map.
  136173. */
  136174. protected _useLightmapAsShadowmap: boolean;
  136175. /**
  136176. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  136177. * makes the reflect vector face the model (under horizon).
  136178. */
  136179. protected _useHorizonOcclusion: boolean;
  136180. /**
  136181. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  136182. * too much the area relying on ambient texture to define their ambient occlusion.
  136183. */
  136184. protected _useRadianceOcclusion: boolean;
  136185. /**
  136186. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  136187. */
  136188. protected _useAlphaFromAlbedoTexture: boolean;
  136189. /**
  136190. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  136191. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  136192. */
  136193. protected _useSpecularOverAlpha: boolean;
  136194. /**
  136195. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  136196. */
  136197. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  136198. /**
  136199. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  136200. */
  136201. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  136202. /**
  136203. * Specifies if the metallic texture contains the roughness information in its green channel.
  136204. */
  136205. protected _useRoughnessFromMetallicTextureGreen: boolean;
  136206. /**
  136207. * Specifies if the metallic texture contains the metallness information in its blue channel.
  136208. */
  136209. protected _useMetallnessFromMetallicTextureBlue: boolean;
  136210. /**
  136211. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  136212. */
  136213. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  136214. /**
  136215. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  136216. */
  136217. protected _useAmbientInGrayScale: boolean;
  136218. /**
  136219. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  136220. * The material will try to infer what glossiness each pixel should be.
  136221. */
  136222. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  136223. /**
  136224. * Defines the falloff type used in this material.
  136225. * It by default is Physical.
  136226. */
  136227. protected _lightFalloff: number;
  136228. /**
  136229. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  136230. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  136231. */
  136232. protected _useRadianceOverAlpha: boolean;
  136233. /**
  136234. * Allows using an object space normal map (instead of tangent space).
  136235. */
  136236. protected _useObjectSpaceNormalMap: boolean;
  136237. /**
  136238. * Allows using the bump map in parallax mode.
  136239. */
  136240. protected _useParallax: boolean;
  136241. /**
  136242. * Allows using the bump map in parallax occlusion mode.
  136243. */
  136244. protected _useParallaxOcclusion: boolean;
  136245. /**
  136246. * Controls the scale bias of the parallax mode.
  136247. */
  136248. protected _parallaxScaleBias: number;
  136249. /**
  136250. * If sets to true, disables all the lights affecting the material.
  136251. */
  136252. protected _disableLighting: boolean;
  136253. /**
  136254. * Number of Simultaneous lights allowed on the material.
  136255. */
  136256. protected _maxSimultaneousLights: number;
  136257. /**
  136258. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  136259. */
  136260. protected _invertNormalMapX: boolean;
  136261. /**
  136262. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  136263. */
  136264. protected _invertNormalMapY: boolean;
  136265. /**
  136266. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  136267. */
  136268. protected _twoSidedLighting: boolean;
  136269. /**
  136270. * Defines the alpha limits in alpha test mode.
  136271. */
  136272. protected _alphaCutOff: number;
  136273. /**
  136274. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  136275. */
  136276. protected _forceAlphaTest: boolean;
  136277. /**
  136278. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136279. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  136280. */
  136281. protected _useAlphaFresnel: boolean;
  136282. /**
  136283. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136284. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  136285. */
  136286. protected _useLinearAlphaFresnel: boolean;
  136287. /**
  136288. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  136289. * from cos thetav and roughness:
  136290. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  136291. */
  136292. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  136293. /**
  136294. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  136295. */
  136296. protected _forceIrradianceInFragment: boolean;
  136297. private _realTimeFiltering;
  136298. /**
  136299. * Enables realtime filtering on the texture.
  136300. */
  136301. get realTimeFiltering(): boolean;
  136302. set realTimeFiltering(b: boolean);
  136303. private _realTimeFilteringQuality;
  136304. /**
  136305. * Quality switch for realtime filtering
  136306. */
  136307. get realTimeFilteringQuality(): number;
  136308. set realTimeFilteringQuality(n: number);
  136309. /**
  136310. * Can this material render to several textures at once
  136311. */
  136312. get canRenderToMRT(): boolean;
  136313. /**
  136314. * Force normal to face away from face.
  136315. */
  136316. protected _forceNormalForward: boolean;
  136317. /**
  136318. * Enables specular anti aliasing in the PBR shader.
  136319. * It will both interacts on the Geometry for analytical and IBL lighting.
  136320. * It also prefilter the roughness map based on the bump values.
  136321. */
  136322. protected _enableSpecularAntiAliasing: boolean;
  136323. /**
  136324. * Default configuration related to image processing available in the PBR Material.
  136325. */
  136326. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  136327. /**
  136328. * Keep track of the image processing observer to allow dispose and replace.
  136329. */
  136330. private _imageProcessingObserver;
  136331. /**
  136332. * Attaches a new image processing configuration to the PBR Material.
  136333. * @param configuration
  136334. */
  136335. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  136336. /**
  136337. * Stores the available render targets.
  136338. */
  136339. private _renderTargets;
  136340. /**
  136341. * Sets the global ambient color for the material used in lighting calculations.
  136342. */
  136343. private _globalAmbientColor;
  136344. /**
  136345. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  136346. */
  136347. private _useLogarithmicDepth;
  136348. /**
  136349. * If set to true, no lighting calculations will be applied.
  136350. */
  136351. private _unlit;
  136352. private _debugMode;
  136353. /**
  136354. * @hidden
  136355. * This is reserved for the inspector.
  136356. * Defines the material debug mode.
  136357. * It helps seeing only some components of the material while troubleshooting.
  136358. */
  136359. debugMode: number;
  136360. /**
  136361. * @hidden
  136362. * This is reserved for the inspector.
  136363. * Specify from where on screen the debug mode should start.
  136364. * The value goes from -1 (full screen) to 1 (not visible)
  136365. * It helps with side by side comparison against the final render
  136366. * This defaults to -1
  136367. */
  136368. private debugLimit;
  136369. /**
  136370. * @hidden
  136371. * This is reserved for the inspector.
  136372. * As the default viewing range might not be enough (if the ambient is really small for instance)
  136373. * You can use the factor to better multiply the final value.
  136374. */
  136375. private debugFactor;
  136376. /**
  136377. * Defines the clear coat layer parameters for the material.
  136378. */
  136379. readonly clearCoat: PBRClearCoatConfiguration;
  136380. /**
  136381. * Defines the anisotropic parameters for the material.
  136382. */
  136383. readonly anisotropy: PBRAnisotropicConfiguration;
  136384. /**
  136385. * Defines the BRDF parameters for the material.
  136386. */
  136387. readonly brdf: PBRBRDFConfiguration;
  136388. /**
  136389. * Defines the Sheen parameters for the material.
  136390. */
  136391. readonly sheen: PBRSheenConfiguration;
  136392. /**
  136393. * Defines the SubSurface parameters for the material.
  136394. */
  136395. readonly subSurface: PBRSubSurfaceConfiguration;
  136396. /**
  136397. * Defines the detail map parameters for the material.
  136398. */
  136399. readonly detailMap: DetailMapConfiguration;
  136400. protected _rebuildInParallel: boolean;
  136401. /**
  136402. * Instantiates a new PBRMaterial instance.
  136403. *
  136404. * @param name The material name
  136405. * @param scene The scene the material will be use in.
  136406. */
  136407. constructor(name: string, scene: Scene);
  136408. /**
  136409. * Gets a boolean indicating that current material needs to register RTT
  136410. */
  136411. get hasRenderTargetTextures(): boolean;
  136412. /**
  136413. * Gets the name of the material class.
  136414. */
  136415. getClassName(): string;
  136416. /**
  136417. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  136418. */
  136419. get useLogarithmicDepth(): boolean;
  136420. /**
  136421. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  136422. */
  136423. set useLogarithmicDepth(value: boolean);
  136424. /**
  136425. * Returns true if alpha blending should be disabled.
  136426. */
  136427. protected get _disableAlphaBlending(): boolean;
  136428. /**
  136429. * Specifies whether or not this material should be rendered in alpha blend mode.
  136430. */
  136431. needAlphaBlending(): boolean;
  136432. /**
  136433. * Specifies whether or not this material should be rendered in alpha test mode.
  136434. */
  136435. needAlphaTesting(): boolean;
  136436. /**
  136437. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  136438. */
  136439. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  136440. /**
  136441. * Gets the texture used for the alpha test.
  136442. */
  136443. getAlphaTestTexture(): Nullable<BaseTexture>;
  136444. /**
  136445. * Specifies that the submesh is ready to be used.
  136446. * @param mesh - BJS mesh.
  136447. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  136448. * @param useInstances - Specifies that instances should be used.
  136449. * @returns - boolean indicating that the submesh is ready or not.
  136450. */
  136451. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  136452. /**
  136453. * Specifies if the material uses metallic roughness workflow.
  136454. * @returns boolean specifiying if the material uses metallic roughness workflow.
  136455. */
  136456. isMetallicWorkflow(): boolean;
  136457. private _prepareEffect;
  136458. private _prepareDefines;
  136459. /**
  136460. * Force shader compilation
  136461. */
  136462. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  136463. /**
  136464. * Initializes the uniform buffer layout for the shader.
  136465. */
  136466. buildUniformLayout(): void;
  136467. /**
  136468. * Unbinds the material from the mesh
  136469. */
  136470. unbind(): void;
  136471. /**
  136472. * Binds the submesh data.
  136473. * @param world - The world matrix.
  136474. * @param mesh - The BJS mesh.
  136475. * @param subMesh - A submesh of the BJS mesh.
  136476. */
  136477. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  136478. /**
  136479. * Returns the animatable textures.
  136480. * @returns - Array of animatable textures.
  136481. */
  136482. getAnimatables(): IAnimatable[];
  136483. /**
  136484. * Returns the texture used for reflections.
  136485. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  136486. */
  136487. private _getReflectionTexture;
  136488. /**
  136489. * Returns an array of the actively used textures.
  136490. * @returns - Array of BaseTextures
  136491. */
  136492. getActiveTextures(): BaseTexture[];
  136493. /**
  136494. * Checks to see if a texture is used in the material.
  136495. * @param texture - Base texture to use.
  136496. * @returns - Boolean specifying if a texture is used in the material.
  136497. */
  136498. hasTexture(texture: BaseTexture): boolean;
  136499. /**
  136500. * Sets the required values to the prepass renderer.
  136501. * @param prePassRenderer defines the prepass renderer to setup
  136502. */
  136503. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  136504. /**
  136505. * Disposes the resources of the material.
  136506. * @param forceDisposeEffect - Forces the disposal of effects.
  136507. * @param forceDisposeTextures - Forces the disposal of all textures.
  136508. */
  136509. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  136510. }
  136511. }
  136512. declare module BABYLON {
  136513. /**
  136514. * The Physically based material of BJS.
  136515. *
  136516. * This offers the main features of a standard PBR material.
  136517. * For more information, please refer to the documentation :
  136518. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136519. */
  136520. export class PBRMaterial extends PBRBaseMaterial {
  136521. /**
  136522. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136523. */
  136524. static readonly PBRMATERIAL_OPAQUE: number;
  136525. /**
  136526. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136527. */
  136528. static readonly PBRMATERIAL_ALPHATEST: number;
  136529. /**
  136530. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136531. */
  136532. static readonly PBRMATERIAL_ALPHABLEND: number;
  136533. /**
  136534. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136535. * They are also discarded below the alpha cutoff threshold to improve performances.
  136536. */
  136537. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  136538. /**
  136539. * Defines the default value of how much AO map is occluding the analytical lights
  136540. * (point spot...).
  136541. */
  136542. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  136543. /**
  136544. * Intensity of the direct lights e.g. the four lights available in your scene.
  136545. * This impacts both the direct diffuse and specular highlights.
  136546. */
  136547. directIntensity: number;
  136548. /**
  136549. * Intensity of the emissive part of the material.
  136550. * This helps controlling the emissive effect without modifying the emissive color.
  136551. */
  136552. emissiveIntensity: number;
  136553. /**
  136554. * Intensity of the environment e.g. how much the environment will light the object
  136555. * either through harmonics for rough material or through the refelction for shiny ones.
  136556. */
  136557. environmentIntensity: number;
  136558. /**
  136559. * This is a special control allowing the reduction of the specular highlights coming from the
  136560. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  136561. */
  136562. specularIntensity: number;
  136563. /**
  136564. * Debug Control allowing disabling the bump map on this material.
  136565. */
  136566. disableBumpMap: boolean;
  136567. /**
  136568. * AKA Diffuse Texture in standard nomenclature.
  136569. */
  136570. albedoTexture: BaseTexture;
  136571. /**
  136572. * AKA Occlusion Texture in other nomenclature.
  136573. */
  136574. ambientTexture: BaseTexture;
  136575. /**
  136576. * AKA Occlusion Texture Intensity in other nomenclature.
  136577. */
  136578. ambientTextureStrength: number;
  136579. /**
  136580. * Defines how much the AO map is occluding the analytical lights (point spot...).
  136581. * 1 means it completely occludes it
  136582. * 0 mean it has no impact
  136583. */
  136584. ambientTextureImpactOnAnalyticalLights: number;
  136585. /**
  136586. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  136587. */
  136588. opacityTexture: BaseTexture;
  136589. /**
  136590. * Stores the reflection values in a texture.
  136591. */
  136592. reflectionTexture: Nullable<BaseTexture>;
  136593. /**
  136594. * Stores the emissive values in a texture.
  136595. */
  136596. emissiveTexture: BaseTexture;
  136597. /**
  136598. * AKA Specular texture in other nomenclature.
  136599. */
  136600. reflectivityTexture: BaseTexture;
  136601. /**
  136602. * Used to switch from specular/glossiness to metallic/roughness workflow.
  136603. */
  136604. metallicTexture: BaseTexture;
  136605. /**
  136606. * Specifies the metallic scalar of the metallic/roughness workflow.
  136607. * Can also be used to scale the metalness values of the metallic texture.
  136608. */
  136609. metallic: Nullable<number>;
  136610. /**
  136611. * Specifies the roughness scalar of the metallic/roughness workflow.
  136612. * Can also be used to scale the roughness values of the metallic texture.
  136613. */
  136614. roughness: Nullable<number>;
  136615. /**
  136616. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  136617. * By default the indexOfrefraction is used to compute F0;
  136618. *
  136619. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  136620. *
  136621. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  136622. * F90 = metallicReflectanceColor;
  136623. */
  136624. metallicF0Factor: number;
  136625. /**
  136626. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  136627. * By default the F90 is always 1;
  136628. *
  136629. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  136630. *
  136631. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  136632. * F90 = metallicReflectanceColor;
  136633. */
  136634. metallicReflectanceColor: Color3;
  136635. /**
  136636. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  136637. * This is multiply against the scalar values defined in the material.
  136638. */
  136639. metallicReflectanceTexture: Nullable<BaseTexture>;
  136640. /**
  136641. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  136642. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  136643. */
  136644. microSurfaceTexture: BaseTexture;
  136645. /**
  136646. * Stores surface normal data used to displace a mesh in a texture.
  136647. */
  136648. bumpTexture: BaseTexture;
  136649. /**
  136650. * Stores the pre-calculated light information of a mesh in a texture.
  136651. */
  136652. lightmapTexture: BaseTexture;
  136653. /**
  136654. * Stores the refracted light information in a texture.
  136655. */
  136656. get refractionTexture(): Nullable<BaseTexture>;
  136657. set refractionTexture(value: Nullable<BaseTexture>);
  136658. /**
  136659. * The color of a material in ambient lighting.
  136660. */
  136661. ambientColor: Color3;
  136662. /**
  136663. * AKA Diffuse Color in other nomenclature.
  136664. */
  136665. albedoColor: Color3;
  136666. /**
  136667. * AKA Specular Color in other nomenclature.
  136668. */
  136669. reflectivityColor: Color3;
  136670. /**
  136671. * The color reflected from the material.
  136672. */
  136673. reflectionColor: Color3;
  136674. /**
  136675. * The color emitted from the material.
  136676. */
  136677. emissiveColor: Color3;
  136678. /**
  136679. * AKA Glossiness in other nomenclature.
  136680. */
  136681. microSurface: number;
  136682. /**
  136683. * Index of refraction of the material base layer.
  136684. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136685. *
  136686. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  136687. *
  136688. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  136689. */
  136690. get indexOfRefraction(): number;
  136691. set indexOfRefraction(value: number);
  136692. /**
  136693. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  136694. */
  136695. get invertRefractionY(): boolean;
  136696. set invertRefractionY(value: boolean);
  136697. /**
  136698. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  136699. * Materials half opaque for instance using refraction could benefit from this control.
  136700. */
  136701. get linkRefractionWithTransparency(): boolean;
  136702. set linkRefractionWithTransparency(value: boolean);
  136703. /**
  136704. * If true, the light map contains occlusion information instead of lighting info.
  136705. */
  136706. useLightmapAsShadowmap: boolean;
  136707. /**
  136708. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  136709. */
  136710. useAlphaFromAlbedoTexture: boolean;
  136711. /**
  136712. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  136713. */
  136714. forceAlphaTest: boolean;
  136715. /**
  136716. * Defines the alpha limits in alpha test mode.
  136717. */
  136718. alphaCutOff: number;
  136719. /**
  136720. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  136721. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  136722. */
  136723. useSpecularOverAlpha: boolean;
  136724. /**
  136725. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  136726. */
  136727. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  136728. /**
  136729. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  136730. */
  136731. useRoughnessFromMetallicTextureAlpha: boolean;
  136732. /**
  136733. * Specifies if the metallic texture contains the roughness information in its green channel.
  136734. */
  136735. useRoughnessFromMetallicTextureGreen: boolean;
  136736. /**
  136737. * Specifies if the metallic texture contains the metallness information in its blue channel.
  136738. */
  136739. useMetallnessFromMetallicTextureBlue: boolean;
  136740. /**
  136741. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  136742. */
  136743. useAmbientOcclusionFromMetallicTextureRed: boolean;
  136744. /**
  136745. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  136746. */
  136747. useAmbientInGrayScale: boolean;
  136748. /**
  136749. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  136750. * The material will try to infer what glossiness each pixel should be.
  136751. */
  136752. useAutoMicroSurfaceFromReflectivityMap: boolean;
  136753. /**
  136754. * BJS is using an harcoded light falloff based on a manually sets up range.
  136755. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  136756. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  136757. */
  136758. get usePhysicalLightFalloff(): boolean;
  136759. /**
  136760. * BJS is using an harcoded light falloff based on a manually sets up range.
  136761. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  136762. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  136763. */
  136764. set usePhysicalLightFalloff(value: boolean);
  136765. /**
  136766. * In order to support the falloff compatibility with gltf, a special mode has been added
  136767. * to reproduce the gltf light falloff.
  136768. */
  136769. get useGLTFLightFalloff(): boolean;
  136770. /**
  136771. * In order to support the falloff compatibility with gltf, a special mode has been added
  136772. * to reproduce the gltf light falloff.
  136773. */
  136774. set useGLTFLightFalloff(value: boolean);
  136775. /**
  136776. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  136777. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  136778. */
  136779. useRadianceOverAlpha: boolean;
  136780. /**
  136781. * Allows using an object space normal map (instead of tangent space).
  136782. */
  136783. useObjectSpaceNormalMap: boolean;
  136784. /**
  136785. * Allows using the bump map in parallax mode.
  136786. */
  136787. useParallax: boolean;
  136788. /**
  136789. * Allows using the bump map in parallax occlusion mode.
  136790. */
  136791. useParallaxOcclusion: boolean;
  136792. /**
  136793. * Controls the scale bias of the parallax mode.
  136794. */
  136795. parallaxScaleBias: number;
  136796. /**
  136797. * If sets to true, disables all the lights affecting the material.
  136798. */
  136799. disableLighting: boolean;
  136800. /**
  136801. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  136802. */
  136803. forceIrradianceInFragment: boolean;
  136804. /**
  136805. * Number of Simultaneous lights allowed on the material.
  136806. */
  136807. maxSimultaneousLights: number;
  136808. /**
  136809. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  136810. */
  136811. invertNormalMapX: boolean;
  136812. /**
  136813. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  136814. */
  136815. invertNormalMapY: boolean;
  136816. /**
  136817. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  136818. */
  136819. twoSidedLighting: boolean;
  136820. /**
  136821. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136822. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  136823. */
  136824. useAlphaFresnel: boolean;
  136825. /**
  136826. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136827. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  136828. */
  136829. useLinearAlphaFresnel: boolean;
  136830. /**
  136831. * Let user defines the brdf lookup texture used for IBL.
  136832. * A default 8bit version is embedded but you could point at :
  136833. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  136834. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  136835. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  136836. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  136837. */
  136838. environmentBRDFTexture: Nullable<BaseTexture>;
  136839. /**
  136840. * Force normal to face away from face.
  136841. */
  136842. forceNormalForward: boolean;
  136843. /**
  136844. * Enables specular anti aliasing in the PBR shader.
  136845. * It will both interacts on the Geometry for analytical and IBL lighting.
  136846. * It also prefilter the roughness map based on the bump values.
  136847. */
  136848. enableSpecularAntiAliasing: boolean;
  136849. /**
  136850. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  136851. * makes the reflect vector face the model (under horizon).
  136852. */
  136853. useHorizonOcclusion: boolean;
  136854. /**
  136855. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  136856. * too much the area relying on ambient texture to define their ambient occlusion.
  136857. */
  136858. useRadianceOcclusion: boolean;
  136859. /**
  136860. * If set to true, no lighting calculations will be applied.
  136861. */
  136862. unlit: boolean;
  136863. /**
  136864. * Gets the image processing configuration used either in this material.
  136865. */
  136866. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  136867. /**
  136868. * Sets the Default image processing configuration used either in the this material.
  136869. *
  136870. * If sets to null, the scene one is in use.
  136871. */
  136872. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  136873. /**
  136874. * Gets wether the color curves effect is enabled.
  136875. */
  136876. get cameraColorCurvesEnabled(): boolean;
  136877. /**
  136878. * Sets wether the color curves effect is enabled.
  136879. */
  136880. set cameraColorCurvesEnabled(value: boolean);
  136881. /**
  136882. * Gets wether the color grading effect is enabled.
  136883. */
  136884. get cameraColorGradingEnabled(): boolean;
  136885. /**
  136886. * Gets wether the color grading effect is enabled.
  136887. */
  136888. set cameraColorGradingEnabled(value: boolean);
  136889. /**
  136890. * Gets wether tonemapping is enabled or not.
  136891. */
  136892. get cameraToneMappingEnabled(): boolean;
  136893. /**
  136894. * Sets wether tonemapping is enabled or not
  136895. */
  136896. set cameraToneMappingEnabled(value: boolean);
  136897. /**
  136898. * The camera exposure used on this material.
  136899. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  136900. * This corresponds to a photographic exposure.
  136901. */
  136902. get cameraExposure(): number;
  136903. /**
  136904. * The camera exposure used on this material.
  136905. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  136906. * This corresponds to a photographic exposure.
  136907. */
  136908. set cameraExposure(value: number);
  136909. /**
  136910. * Gets The camera contrast used on this material.
  136911. */
  136912. get cameraContrast(): number;
  136913. /**
  136914. * Sets The camera contrast used on this material.
  136915. */
  136916. set cameraContrast(value: number);
  136917. /**
  136918. * Gets the Color Grading 2D Lookup Texture.
  136919. */
  136920. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  136921. /**
  136922. * Sets the Color Grading 2D Lookup Texture.
  136923. */
  136924. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  136925. /**
  136926. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  136927. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  136928. * 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;
  136929. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  136930. */
  136931. get cameraColorCurves(): Nullable<ColorCurves>;
  136932. /**
  136933. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  136934. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  136935. * 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;
  136936. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  136937. */
  136938. set cameraColorCurves(value: Nullable<ColorCurves>);
  136939. /**
  136940. * Instantiates a new PBRMaterial instance.
  136941. *
  136942. * @param name The material name
  136943. * @param scene The scene the material will be use in.
  136944. */
  136945. constructor(name: string, scene: Scene);
  136946. /**
  136947. * Returns the name of this material class.
  136948. */
  136949. getClassName(): string;
  136950. /**
  136951. * Makes a duplicate of the current material.
  136952. * @param name - name to use for the new material.
  136953. */
  136954. clone(name: string): PBRMaterial;
  136955. /**
  136956. * Serializes this PBR Material.
  136957. * @returns - An object with the serialized material.
  136958. */
  136959. serialize(): any;
  136960. /**
  136961. * Parses a PBR Material from a serialized object.
  136962. * @param source - Serialized object.
  136963. * @param scene - BJS scene instance.
  136964. * @param rootUrl - url for the scene object
  136965. * @returns - PBRMaterial
  136966. */
  136967. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  136968. }
  136969. }
  136970. declare module BABYLON {
  136971. /**
  136972. * Direct draw surface info
  136973. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  136974. */
  136975. export interface DDSInfo {
  136976. /**
  136977. * Width of the texture
  136978. */
  136979. width: number;
  136980. /**
  136981. * Width of the texture
  136982. */
  136983. height: number;
  136984. /**
  136985. * Number of Mipmaps for the texture
  136986. * @see https://en.wikipedia.org/wiki/Mipmap
  136987. */
  136988. mipmapCount: number;
  136989. /**
  136990. * If the textures format is a known fourCC format
  136991. * @see https://www.fourcc.org/
  136992. */
  136993. isFourCC: boolean;
  136994. /**
  136995. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  136996. */
  136997. isRGB: boolean;
  136998. /**
  136999. * If the texture is a lumincance format
  137000. */
  137001. isLuminance: boolean;
  137002. /**
  137003. * If this is a cube texture
  137004. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  137005. */
  137006. isCube: boolean;
  137007. /**
  137008. * If the texture is a compressed format eg. FOURCC_DXT1
  137009. */
  137010. isCompressed: boolean;
  137011. /**
  137012. * The dxgiFormat of the texture
  137013. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  137014. */
  137015. dxgiFormat: number;
  137016. /**
  137017. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  137018. */
  137019. textureType: number;
  137020. /**
  137021. * Sphericle polynomial created for the dds texture
  137022. */
  137023. sphericalPolynomial?: SphericalPolynomial;
  137024. }
  137025. /**
  137026. * Class used to provide DDS decompression tools
  137027. */
  137028. export class DDSTools {
  137029. /**
  137030. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  137031. */
  137032. static StoreLODInAlphaChannel: boolean;
  137033. /**
  137034. * Gets DDS information from an array buffer
  137035. * @param data defines the array buffer view to read data from
  137036. * @returns the DDS information
  137037. */
  137038. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  137039. private static _FloatView;
  137040. private static _Int32View;
  137041. private static _ToHalfFloat;
  137042. private static _FromHalfFloat;
  137043. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  137044. private static _GetHalfFloatRGBAArrayBuffer;
  137045. private static _GetFloatRGBAArrayBuffer;
  137046. private static _GetFloatAsUIntRGBAArrayBuffer;
  137047. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  137048. private static _GetRGBAArrayBuffer;
  137049. private static _ExtractLongWordOrder;
  137050. private static _GetRGBArrayBuffer;
  137051. private static _GetLuminanceArrayBuffer;
  137052. /**
  137053. * Uploads DDS Levels to a Babylon Texture
  137054. * @hidden
  137055. */
  137056. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  137057. }
  137058. interface ThinEngine {
  137059. /**
  137060. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  137061. * @param rootUrl defines the url where the file to load is located
  137062. * @param scene defines the current scene
  137063. * @param lodScale defines scale to apply to the mip map selection
  137064. * @param lodOffset defines offset to apply to the mip map selection
  137065. * @param onLoad defines an optional callback raised when the texture is loaded
  137066. * @param onError defines an optional callback raised if there is an issue to load the texture
  137067. * @param format defines the format of the data
  137068. * @param forcedExtension defines the extension to use to pick the right loader
  137069. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  137070. * @returns the cube texture as an InternalTexture
  137071. */
  137072. 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;
  137073. }
  137074. }
  137075. declare module BABYLON {
  137076. /**
  137077. * Implementation of the DDS Texture Loader.
  137078. * @hidden
  137079. */
  137080. export class _DDSTextureLoader implements IInternalTextureLoader {
  137081. /**
  137082. * Defines wether the loader supports cascade loading the different faces.
  137083. */
  137084. readonly supportCascades: boolean;
  137085. /**
  137086. * This returns if the loader support the current file information.
  137087. * @param extension defines the file extension of the file being loaded
  137088. * @returns true if the loader can load the specified file
  137089. */
  137090. canLoad(extension: string): boolean;
  137091. /**
  137092. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137093. * @param data contains the texture data
  137094. * @param texture defines the BabylonJS internal texture
  137095. * @param createPolynomials will be true if polynomials have been requested
  137096. * @param onLoad defines the callback to trigger once the texture is ready
  137097. * @param onError defines the callback to trigger in case of error
  137098. */
  137099. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137100. /**
  137101. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137102. * @param data contains the texture data
  137103. * @param texture defines the BabylonJS internal texture
  137104. * @param callback defines the method to call once ready to upload
  137105. */
  137106. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137107. }
  137108. }
  137109. declare module BABYLON {
  137110. /**
  137111. * Implementation of the ENV Texture Loader.
  137112. * @hidden
  137113. */
  137114. export class _ENVTextureLoader implements IInternalTextureLoader {
  137115. /**
  137116. * Defines wether the loader supports cascade loading the different faces.
  137117. */
  137118. readonly supportCascades: boolean;
  137119. /**
  137120. * This returns if the loader support the current file information.
  137121. * @param extension defines the file extension of the file being loaded
  137122. * @returns true if the loader can load the specified file
  137123. */
  137124. canLoad(extension: string): boolean;
  137125. /**
  137126. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137127. * @param data contains the texture data
  137128. * @param texture defines the BabylonJS internal texture
  137129. * @param createPolynomials will be true if polynomials have been requested
  137130. * @param onLoad defines the callback to trigger once the texture is ready
  137131. * @param onError defines the callback to trigger in case of error
  137132. */
  137133. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137134. /**
  137135. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137136. * @param data contains the texture data
  137137. * @param texture defines the BabylonJS internal texture
  137138. * @param callback defines the method to call once ready to upload
  137139. */
  137140. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137141. }
  137142. }
  137143. declare module BABYLON {
  137144. /**
  137145. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  137146. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  137147. */
  137148. export class KhronosTextureContainer {
  137149. /** contents of the KTX container file */
  137150. data: ArrayBufferView;
  137151. private static HEADER_LEN;
  137152. private static COMPRESSED_2D;
  137153. private static COMPRESSED_3D;
  137154. private static TEX_2D;
  137155. private static TEX_3D;
  137156. /**
  137157. * Gets the openGL type
  137158. */
  137159. glType: number;
  137160. /**
  137161. * Gets the openGL type size
  137162. */
  137163. glTypeSize: number;
  137164. /**
  137165. * Gets the openGL format
  137166. */
  137167. glFormat: number;
  137168. /**
  137169. * Gets the openGL internal format
  137170. */
  137171. glInternalFormat: number;
  137172. /**
  137173. * Gets the base internal format
  137174. */
  137175. glBaseInternalFormat: number;
  137176. /**
  137177. * Gets image width in pixel
  137178. */
  137179. pixelWidth: number;
  137180. /**
  137181. * Gets image height in pixel
  137182. */
  137183. pixelHeight: number;
  137184. /**
  137185. * Gets image depth in pixels
  137186. */
  137187. pixelDepth: number;
  137188. /**
  137189. * Gets the number of array elements
  137190. */
  137191. numberOfArrayElements: number;
  137192. /**
  137193. * Gets the number of faces
  137194. */
  137195. numberOfFaces: number;
  137196. /**
  137197. * Gets the number of mipmap levels
  137198. */
  137199. numberOfMipmapLevels: number;
  137200. /**
  137201. * Gets the bytes of key value data
  137202. */
  137203. bytesOfKeyValueData: number;
  137204. /**
  137205. * Gets the load type
  137206. */
  137207. loadType: number;
  137208. /**
  137209. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  137210. */
  137211. isInvalid: boolean;
  137212. /**
  137213. * Creates a new KhronosTextureContainer
  137214. * @param data contents of the KTX container file
  137215. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  137216. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  137217. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  137218. */
  137219. constructor(
  137220. /** contents of the KTX container file */
  137221. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  137222. /**
  137223. * Uploads KTX content to a Babylon Texture.
  137224. * It is assumed that the texture has already been created & is currently bound
  137225. * @hidden
  137226. */
  137227. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  137228. private _upload2DCompressedLevels;
  137229. /**
  137230. * Checks if the given data starts with a KTX file identifier.
  137231. * @param data the data to check
  137232. * @returns true if the data is a KTX file or false otherwise
  137233. */
  137234. static IsValid(data: ArrayBufferView): boolean;
  137235. }
  137236. }
  137237. declare module BABYLON {
  137238. /**
  137239. * Class for loading KTX2 files
  137240. * !!! Experimental Extension Subject to Changes !!!
  137241. * @hidden
  137242. */
  137243. export class KhronosTextureContainer2 {
  137244. private static _ModulePromise;
  137245. private static _TranscodeFormat;
  137246. constructor(engine: ThinEngine);
  137247. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  137248. private _determineTranscodeFormat;
  137249. /**
  137250. * Checks if the given data starts with a KTX2 file identifier.
  137251. * @param data the data to check
  137252. * @returns true if the data is a KTX2 file or false otherwise
  137253. */
  137254. static IsValid(data: ArrayBufferView): boolean;
  137255. }
  137256. }
  137257. declare module BABYLON {
  137258. /**
  137259. * Implementation of the KTX Texture Loader.
  137260. * @hidden
  137261. */
  137262. export class _KTXTextureLoader implements IInternalTextureLoader {
  137263. /**
  137264. * Defines wether the loader supports cascade loading the different faces.
  137265. */
  137266. readonly supportCascades: boolean;
  137267. /**
  137268. * This returns if the loader support the current file information.
  137269. * @param extension defines the file extension of the file being loaded
  137270. * @param mimeType defines the optional mime type of the file being loaded
  137271. * @returns true if the loader can load the specified file
  137272. */
  137273. canLoad(extension: string, mimeType?: string): boolean;
  137274. /**
  137275. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137276. * @param data contains the texture data
  137277. * @param texture defines the BabylonJS internal texture
  137278. * @param createPolynomials will be true if polynomials have been requested
  137279. * @param onLoad defines the callback to trigger once the texture is ready
  137280. * @param onError defines the callback to trigger in case of error
  137281. */
  137282. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137283. /**
  137284. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137285. * @param data contains the texture data
  137286. * @param texture defines the BabylonJS internal texture
  137287. * @param callback defines the method to call once ready to upload
  137288. */
  137289. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  137290. }
  137291. }
  137292. declare module BABYLON {
  137293. /** @hidden */
  137294. export var _forceSceneHelpersToBundle: boolean;
  137295. interface Scene {
  137296. /**
  137297. * Creates a default light for the scene.
  137298. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  137299. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  137300. */
  137301. createDefaultLight(replace?: boolean): void;
  137302. /**
  137303. * Creates a default camera for the scene.
  137304. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  137305. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  137306. * @param replace has default false, when true replaces the active camera in the scene
  137307. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  137308. */
  137309. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  137310. /**
  137311. * Creates a default camera and a default light.
  137312. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  137313. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  137314. * @param replace has the default false, when true replaces the active camera/light in the scene
  137315. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  137316. */
  137317. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  137318. /**
  137319. * Creates a new sky box
  137320. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  137321. * @param environmentTexture defines the texture to use as environment texture
  137322. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  137323. * @param scale defines the overall scale of the skybox
  137324. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  137325. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  137326. * @returns a new mesh holding the sky box
  137327. */
  137328. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  137329. /**
  137330. * Creates a new environment
  137331. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  137332. * @param options defines the options you can use to configure the environment
  137333. * @returns the new EnvironmentHelper
  137334. */
  137335. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  137336. /**
  137337. * Creates a new VREXperienceHelper
  137338. * @see https://doc.babylonjs.com/how_to/webvr_helper
  137339. * @param webVROptions defines the options used to create the new VREXperienceHelper
  137340. * @returns a new VREXperienceHelper
  137341. */
  137342. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  137343. /**
  137344. * Creates a new WebXRDefaultExperience
  137345. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  137346. * @param options experience options
  137347. * @returns a promise for a new WebXRDefaultExperience
  137348. */
  137349. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  137350. }
  137351. }
  137352. declare module BABYLON {
  137353. /**
  137354. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  137355. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  137356. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  137357. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  137358. */
  137359. export class VideoDome extends TextureDome<VideoTexture> {
  137360. /**
  137361. * Define the video source as a Monoscopic panoramic 360 video.
  137362. */
  137363. static readonly MODE_MONOSCOPIC: number;
  137364. /**
  137365. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  137366. */
  137367. static readonly MODE_TOPBOTTOM: number;
  137368. /**
  137369. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  137370. */
  137371. static readonly MODE_SIDEBYSIDE: number;
  137372. /**
  137373. * Get the video texture associated with this video dome
  137374. */
  137375. get videoTexture(): VideoTexture;
  137376. /**
  137377. * Get the video mode of this dome
  137378. */
  137379. get videoMode(): number;
  137380. /**
  137381. * Set the video mode of this dome.
  137382. * @see textureMode
  137383. */
  137384. set videoMode(value: number);
  137385. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  137386. }
  137387. }
  137388. declare module BABYLON {
  137389. /**
  137390. * This class can be used to get instrumentation data from a Babylon engine
  137391. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  137392. */
  137393. export class EngineInstrumentation implements IDisposable {
  137394. /**
  137395. * Define the instrumented engine.
  137396. */
  137397. engine: Engine;
  137398. private _captureGPUFrameTime;
  137399. private _gpuFrameTimeToken;
  137400. private _gpuFrameTime;
  137401. private _captureShaderCompilationTime;
  137402. private _shaderCompilationTime;
  137403. private _onBeginFrameObserver;
  137404. private _onEndFrameObserver;
  137405. private _onBeforeShaderCompilationObserver;
  137406. private _onAfterShaderCompilationObserver;
  137407. /**
  137408. * Gets the perf counter used for GPU frame time
  137409. */
  137410. get gpuFrameTimeCounter(): PerfCounter;
  137411. /**
  137412. * Gets the GPU frame time capture status
  137413. */
  137414. get captureGPUFrameTime(): boolean;
  137415. /**
  137416. * Enable or disable the GPU frame time capture
  137417. */
  137418. set captureGPUFrameTime(value: boolean);
  137419. /**
  137420. * Gets the perf counter used for shader compilation time
  137421. */
  137422. get shaderCompilationTimeCounter(): PerfCounter;
  137423. /**
  137424. * Gets the shader compilation time capture status
  137425. */
  137426. get captureShaderCompilationTime(): boolean;
  137427. /**
  137428. * Enable or disable the shader compilation time capture
  137429. */
  137430. set captureShaderCompilationTime(value: boolean);
  137431. /**
  137432. * Instantiates a new engine instrumentation.
  137433. * This class can be used to get instrumentation data from a Babylon engine
  137434. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  137435. * @param engine Defines the engine to instrument
  137436. */
  137437. constructor(
  137438. /**
  137439. * Define the instrumented engine.
  137440. */
  137441. engine: Engine);
  137442. /**
  137443. * Dispose and release associated resources.
  137444. */
  137445. dispose(): void;
  137446. }
  137447. }
  137448. declare module BABYLON {
  137449. /**
  137450. * This class can be used to get instrumentation data from a Babylon engine
  137451. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  137452. */
  137453. export class SceneInstrumentation implements IDisposable {
  137454. /**
  137455. * Defines the scene to instrument
  137456. */
  137457. scene: Scene;
  137458. private _captureActiveMeshesEvaluationTime;
  137459. private _activeMeshesEvaluationTime;
  137460. private _captureRenderTargetsRenderTime;
  137461. private _renderTargetsRenderTime;
  137462. private _captureFrameTime;
  137463. private _frameTime;
  137464. private _captureRenderTime;
  137465. private _renderTime;
  137466. private _captureInterFrameTime;
  137467. private _interFrameTime;
  137468. private _captureParticlesRenderTime;
  137469. private _particlesRenderTime;
  137470. private _captureSpritesRenderTime;
  137471. private _spritesRenderTime;
  137472. private _capturePhysicsTime;
  137473. private _physicsTime;
  137474. private _captureAnimationsTime;
  137475. private _animationsTime;
  137476. private _captureCameraRenderTime;
  137477. private _cameraRenderTime;
  137478. private _onBeforeActiveMeshesEvaluationObserver;
  137479. private _onAfterActiveMeshesEvaluationObserver;
  137480. private _onBeforeRenderTargetsRenderObserver;
  137481. private _onAfterRenderTargetsRenderObserver;
  137482. private _onAfterRenderObserver;
  137483. private _onBeforeDrawPhaseObserver;
  137484. private _onAfterDrawPhaseObserver;
  137485. private _onBeforeAnimationsObserver;
  137486. private _onBeforeParticlesRenderingObserver;
  137487. private _onAfterParticlesRenderingObserver;
  137488. private _onBeforeSpritesRenderingObserver;
  137489. private _onAfterSpritesRenderingObserver;
  137490. private _onBeforePhysicsObserver;
  137491. private _onAfterPhysicsObserver;
  137492. private _onAfterAnimationsObserver;
  137493. private _onBeforeCameraRenderObserver;
  137494. private _onAfterCameraRenderObserver;
  137495. /**
  137496. * Gets the perf counter used for active meshes evaluation time
  137497. */
  137498. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  137499. /**
  137500. * Gets the active meshes evaluation time capture status
  137501. */
  137502. get captureActiveMeshesEvaluationTime(): boolean;
  137503. /**
  137504. * Enable or disable the active meshes evaluation time capture
  137505. */
  137506. set captureActiveMeshesEvaluationTime(value: boolean);
  137507. /**
  137508. * Gets the perf counter used for render targets render time
  137509. */
  137510. get renderTargetsRenderTimeCounter(): PerfCounter;
  137511. /**
  137512. * Gets the render targets render time capture status
  137513. */
  137514. get captureRenderTargetsRenderTime(): boolean;
  137515. /**
  137516. * Enable or disable the render targets render time capture
  137517. */
  137518. set captureRenderTargetsRenderTime(value: boolean);
  137519. /**
  137520. * Gets the perf counter used for particles render time
  137521. */
  137522. get particlesRenderTimeCounter(): PerfCounter;
  137523. /**
  137524. * Gets the particles render time capture status
  137525. */
  137526. get captureParticlesRenderTime(): boolean;
  137527. /**
  137528. * Enable or disable the particles render time capture
  137529. */
  137530. set captureParticlesRenderTime(value: boolean);
  137531. /**
  137532. * Gets the perf counter used for sprites render time
  137533. */
  137534. get spritesRenderTimeCounter(): PerfCounter;
  137535. /**
  137536. * Gets the sprites render time capture status
  137537. */
  137538. get captureSpritesRenderTime(): boolean;
  137539. /**
  137540. * Enable or disable the sprites render time capture
  137541. */
  137542. set captureSpritesRenderTime(value: boolean);
  137543. /**
  137544. * Gets the perf counter used for physics time
  137545. */
  137546. get physicsTimeCounter(): PerfCounter;
  137547. /**
  137548. * Gets the physics time capture status
  137549. */
  137550. get capturePhysicsTime(): boolean;
  137551. /**
  137552. * Enable or disable the physics time capture
  137553. */
  137554. set capturePhysicsTime(value: boolean);
  137555. /**
  137556. * Gets the perf counter used for animations time
  137557. */
  137558. get animationsTimeCounter(): PerfCounter;
  137559. /**
  137560. * Gets the animations time capture status
  137561. */
  137562. get captureAnimationsTime(): boolean;
  137563. /**
  137564. * Enable or disable the animations time capture
  137565. */
  137566. set captureAnimationsTime(value: boolean);
  137567. /**
  137568. * Gets the perf counter used for frame time capture
  137569. */
  137570. get frameTimeCounter(): PerfCounter;
  137571. /**
  137572. * Gets the frame time capture status
  137573. */
  137574. get captureFrameTime(): boolean;
  137575. /**
  137576. * Enable or disable the frame time capture
  137577. */
  137578. set captureFrameTime(value: boolean);
  137579. /**
  137580. * Gets the perf counter used for inter-frames time capture
  137581. */
  137582. get interFrameTimeCounter(): PerfCounter;
  137583. /**
  137584. * Gets the inter-frames time capture status
  137585. */
  137586. get captureInterFrameTime(): boolean;
  137587. /**
  137588. * Enable or disable the inter-frames time capture
  137589. */
  137590. set captureInterFrameTime(value: boolean);
  137591. /**
  137592. * Gets the perf counter used for render time capture
  137593. */
  137594. get renderTimeCounter(): PerfCounter;
  137595. /**
  137596. * Gets the render time capture status
  137597. */
  137598. get captureRenderTime(): boolean;
  137599. /**
  137600. * Enable or disable the render time capture
  137601. */
  137602. set captureRenderTime(value: boolean);
  137603. /**
  137604. * Gets the perf counter used for camera render time capture
  137605. */
  137606. get cameraRenderTimeCounter(): PerfCounter;
  137607. /**
  137608. * Gets the camera render time capture status
  137609. */
  137610. get captureCameraRenderTime(): boolean;
  137611. /**
  137612. * Enable or disable the camera render time capture
  137613. */
  137614. set captureCameraRenderTime(value: boolean);
  137615. /**
  137616. * Gets the perf counter used for draw calls
  137617. */
  137618. get drawCallsCounter(): PerfCounter;
  137619. /**
  137620. * Instantiates a new scene instrumentation.
  137621. * This class can be used to get instrumentation data from a Babylon engine
  137622. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  137623. * @param scene Defines the scene to instrument
  137624. */
  137625. constructor(
  137626. /**
  137627. * Defines the scene to instrument
  137628. */
  137629. scene: Scene);
  137630. /**
  137631. * Dispose and release associated resources.
  137632. */
  137633. dispose(): void;
  137634. }
  137635. }
  137636. declare module BABYLON {
  137637. /** @hidden */
  137638. export var glowMapGenerationPixelShader: {
  137639. name: string;
  137640. shader: string;
  137641. };
  137642. }
  137643. declare module BABYLON {
  137644. /** @hidden */
  137645. export var glowMapGenerationVertexShader: {
  137646. name: string;
  137647. shader: string;
  137648. };
  137649. }
  137650. declare module BABYLON {
  137651. /**
  137652. * Effect layer options. This helps customizing the behaviour
  137653. * of the effect layer.
  137654. */
  137655. export interface IEffectLayerOptions {
  137656. /**
  137657. * Multiplication factor apply to the canvas size to compute the render target size
  137658. * used to generated the objects (the smaller the faster).
  137659. */
  137660. mainTextureRatio: number;
  137661. /**
  137662. * Enforces a fixed size texture to ensure effect stability across devices.
  137663. */
  137664. mainTextureFixedSize?: number;
  137665. /**
  137666. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  137667. */
  137668. alphaBlendingMode: number;
  137669. /**
  137670. * The camera attached to the layer.
  137671. */
  137672. camera: Nullable<Camera>;
  137673. /**
  137674. * The rendering group to draw the layer in.
  137675. */
  137676. renderingGroupId: number;
  137677. }
  137678. /**
  137679. * The effect layer Helps adding post process effect blended with the main pass.
  137680. *
  137681. * This can be for instance use to generate glow or higlight effects on the scene.
  137682. *
  137683. * The effect layer class can not be used directly and is intented to inherited from to be
  137684. * customized per effects.
  137685. */
  137686. export abstract class EffectLayer {
  137687. private _vertexBuffers;
  137688. private _indexBuffer;
  137689. private _cachedDefines;
  137690. private _effectLayerMapGenerationEffect;
  137691. private _effectLayerOptions;
  137692. private _mergeEffect;
  137693. protected _scene: Scene;
  137694. protected _engine: Engine;
  137695. protected _maxSize: number;
  137696. protected _mainTextureDesiredSize: ISize;
  137697. protected _mainTexture: RenderTargetTexture;
  137698. protected _shouldRender: boolean;
  137699. protected _postProcesses: PostProcess[];
  137700. protected _textures: BaseTexture[];
  137701. protected _emissiveTextureAndColor: {
  137702. texture: Nullable<BaseTexture>;
  137703. color: Color4;
  137704. };
  137705. /**
  137706. * The name of the layer
  137707. */
  137708. name: string;
  137709. /**
  137710. * The clear color of the texture used to generate the glow map.
  137711. */
  137712. neutralColor: Color4;
  137713. /**
  137714. * Specifies whether the highlight layer is enabled or not.
  137715. */
  137716. isEnabled: boolean;
  137717. /**
  137718. * Gets the camera attached to the layer.
  137719. */
  137720. get camera(): Nullable<Camera>;
  137721. /**
  137722. * Gets the rendering group id the layer should render in.
  137723. */
  137724. get renderingGroupId(): number;
  137725. set renderingGroupId(renderingGroupId: number);
  137726. /**
  137727. * An event triggered when the effect layer has been disposed.
  137728. */
  137729. onDisposeObservable: Observable<EffectLayer>;
  137730. /**
  137731. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  137732. */
  137733. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  137734. /**
  137735. * An event triggered when the generated texture is being merged in the scene.
  137736. */
  137737. onBeforeComposeObservable: Observable<EffectLayer>;
  137738. /**
  137739. * An event triggered when the mesh is rendered into the effect render target.
  137740. */
  137741. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  137742. /**
  137743. * An event triggered after the mesh has been rendered into the effect render target.
  137744. */
  137745. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  137746. /**
  137747. * An event triggered when the generated texture has been merged in the scene.
  137748. */
  137749. onAfterComposeObservable: Observable<EffectLayer>;
  137750. /**
  137751. * An event triggered when the efffect layer changes its size.
  137752. */
  137753. onSizeChangedObservable: Observable<EffectLayer>;
  137754. /** @hidden */
  137755. static _SceneComponentInitialization: (scene: Scene) => void;
  137756. /**
  137757. * Instantiates a new effect Layer and references it in the scene.
  137758. * @param name The name of the layer
  137759. * @param scene The scene to use the layer in
  137760. */
  137761. constructor(
  137762. /** The Friendly of the effect in the scene */
  137763. name: string, scene: Scene);
  137764. /**
  137765. * Get the effect name of the layer.
  137766. * @return The effect name
  137767. */
  137768. abstract getEffectName(): string;
  137769. /**
  137770. * Checks for the readiness of the element composing the layer.
  137771. * @param subMesh the mesh to check for
  137772. * @param useInstances specify whether or not to use instances to render the mesh
  137773. * @return true if ready otherwise, false
  137774. */
  137775. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137776. /**
  137777. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  137778. * @returns true if the effect requires stencil during the main canvas render pass.
  137779. */
  137780. abstract needStencil(): boolean;
  137781. /**
  137782. * Create the merge effect. This is the shader use to blit the information back
  137783. * to the main canvas at the end of the scene rendering.
  137784. * @returns The effect containing the shader used to merge the effect on the main canvas
  137785. */
  137786. protected abstract _createMergeEffect(): Effect;
  137787. /**
  137788. * Creates the render target textures and post processes used in the effect layer.
  137789. */
  137790. protected abstract _createTextureAndPostProcesses(): void;
  137791. /**
  137792. * Implementation specific of rendering the generating effect on the main canvas.
  137793. * @param effect The effect used to render through
  137794. */
  137795. protected abstract _internalRender(effect: Effect): void;
  137796. /**
  137797. * Sets the required values for both the emissive texture and and the main color.
  137798. */
  137799. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137800. /**
  137801. * Free any resources and references associated to a mesh.
  137802. * Internal use
  137803. * @param mesh The mesh to free.
  137804. */
  137805. abstract _disposeMesh(mesh: Mesh): void;
  137806. /**
  137807. * Serializes this layer (Glow or Highlight for example)
  137808. * @returns a serialized layer object
  137809. */
  137810. abstract serialize?(): any;
  137811. /**
  137812. * Initializes the effect layer with the required options.
  137813. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  137814. */
  137815. protected _init(options: Partial<IEffectLayerOptions>): void;
  137816. /**
  137817. * Generates the index buffer of the full screen quad blending to the main canvas.
  137818. */
  137819. private _generateIndexBuffer;
  137820. /**
  137821. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  137822. */
  137823. private _generateVertexBuffer;
  137824. /**
  137825. * Sets the main texture desired size which is the closest power of two
  137826. * of the engine canvas size.
  137827. */
  137828. private _setMainTextureSize;
  137829. /**
  137830. * Creates the main texture for the effect layer.
  137831. */
  137832. protected _createMainTexture(): void;
  137833. /**
  137834. * Adds specific effects defines.
  137835. * @param defines The defines to add specifics to.
  137836. */
  137837. protected _addCustomEffectDefines(defines: string[]): void;
  137838. /**
  137839. * Checks for the readiness of the element composing the layer.
  137840. * @param subMesh the mesh to check for
  137841. * @param useInstances specify whether or not to use instances to render the mesh
  137842. * @param emissiveTexture the associated emissive texture used to generate the glow
  137843. * @return true if ready otherwise, false
  137844. */
  137845. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  137846. /**
  137847. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  137848. */
  137849. render(): void;
  137850. /**
  137851. * Determine if a given mesh will be used in the current effect.
  137852. * @param mesh mesh to test
  137853. * @returns true if the mesh will be used
  137854. */
  137855. hasMesh(mesh: AbstractMesh): boolean;
  137856. /**
  137857. * Returns true if the layer contains information to display, otherwise false.
  137858. * @returns true if the glow layer should be rendered
  137859. */
  137860. shouldRender(): boolean;
  137861. /**
  137862. * Returns true if the mesh should render, otherwise false.
  137863. * @param mesh The mesh to render
  137864. * @returns true if it should render otherwise false
  137865. */
  137866. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  137867. /**
  137868. * Returns true if the mesh can be rendered, otherwise false.
  137869. * @param mesh The mesh to render
  137870. * @param material The material used on the mesh
  137871. * @returns true if it can be rendered otherwise false
  137872. */
  137873. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137874. /**
  137875. * Returns true if the mesh should render, otherwise false.
  137876. * @param mesh The mesh to render
  137877. * @returns true if it should render otherwise false
  137878. */
  137879. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  137880. /**
  137881. * Renders the submesh passed in parameter to the generation map.
  137882. */
  137883. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  137884. /**
  137885. * Defines whether the current material of the mesh should be use to render the effect.
  137886. * @param mesh defines the current mesh to render
  137887. */
  137888. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  137889. /**
  137890. * Rebuild the required buffers.
  137891. * @hidden Internal use only.
  137892. */
  137893. _rebuild(): void;
  137894. /**
  137895. * Dispose only the render target textures and post process.
  137896. */
  137897. private _disposeTextureAndPostProcesses;
  137898. /**
  137899. * Dispose the highlight layer and free resources.
  137900. */
  137901. dispose(): void;
  137902. /**
  137903. * Gets the class name of the effect layer
  137904. * @returns the string with the class name of the effect layer
  137905. */
  137906. getClassName(): string;
  137907. /**
  137908. * Creates an effect layer from parsed effect layer data
  137909. * @param parsedEffectLayer defines effect layer data
  137910. * @param scene defines the current scene
  137911. * @param rootUrl defines the root URL containing the effect layer information
  137912. * @returns a parsed effect Layer
  137913. */
  137914. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  137915. }
  137916. }
  137917. declare module BABYLON {
  137918. interface AbstractScene {
  137919. /**
  137920. * The list of effect layers (highlights/glow) added to the scene
  137921. * @see https://doc.babylonjs.com/how_to/highlight_layer
  137922. * @see https://doc.babylonjs.com/how_to/glow_layer
  137923. */
  137924. effectLayers: Array<EffectLayer>;
  137925. /**
  137926. * Removes the given effect layer from this scene.
  137927. * @param toRemove defines the effect layer to remove
  137928. * @returns the index of the removed effect layer
  137929. */
  137930. removeEffectLayer(toRemove: EffectLayer): number;
  137931. /**
  137932. * Adds the given effect layer to this scene
  137933. * @param newEffectLayer defines the effect layer to add
  137934. */
  137935. addEffectLayer(newEffectLayer: EffectLayer): void;
  137936. }
  137937. /**
  137938. * Defines the layer scene component responsible to manage any effect layers
  137939. * in a given scene.
  137940. */
  137941. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  137942. /**
  137943. * The component name helpfull to identify the component in the list of scene components.
  137944. */
  137945. readonly name: string;
  137946. /**
  137947. * The scene the component belongs to.
  137948. */
  137949. scene: Scene;
  137950. private _engine;
  137951. private _renderEffects;
  137952. private _needStencil;
  137953. private _previousStencilState;
  137954. /**
  137955. * Creates a new instance of the component for the given scene
  137956. * @param scene Defines the scene to register the component in
  137957. */
  137958. constructor(scene: Scene);
  137959. /**
  137960. * Registers the component in a given scene
  137961. */
  137962. register(): void;
  137963. /**
  137964. * Rebuilds the elements related to this component in case of
  137965. * context lost for instance.
  137966. */
  137967. rebuild(): void;
  137968. /**
  137969. * Serializes the component data to the specified json object
  137970. * @param serializationObject The object to serialize to
  137971. */
  137972. serialize(serializationObject: any): void;
  137973. /**
  137974. * Adds all the elements from the container to the scene
  137975. * @param container the container holding the elements
  137976. */
  137977. addFromContainer(container: AbstractScene): void;
  137978. /**
  137979. * Removes all the elements in the container from the scene
  137980. * @param container contains the elements to remove
  137981. * @param dispose if the removed element should be disposed (default: false)
  137982. */
  137983. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137984. /**
  137985. * Disposes the component and the associated ressources.
  137986. */
  137987. dispose(): void;
  137988. private _isReadyForMesh;
  137989. private _renderMainTexture;
  137990. private _setStencil;
  137991. private _setStencilBack;
  137992. private _draw;
  137993. private _drawCamera;
  137994. private _drawRenderingGroup;
  137995. }
  137996. }
  137997. declare module BABYLON {
  137998. /** @hidden */
  137999. export var glowMapMergePixelShader: {
  138000. name: string;
  138001. shader: string;
  138002. };
  138003. }
  138004. declare module BABYLON {
  138005. /** @hidden */
  138006. export var glowMapMergeVertexShader: {
  138007. name: string;
  138008. shader: string;
  138009. };
  138010. }
  138011. declare module BABYLON {
  138012. interface AbstractScene {
  138013. /**
  138014. * Return a the first highlight layer of the scene with a given name.
  138015. * @param name The name of the highlight layer to look for.
  138016. * @return The highlight layer if found otherwise null.
  138017. */
  138018. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  138019. }
  138020. /**
  138021. * Glow layer options. This helps customizing the behaviour
  138022. * of the glow layer.
  138023. */
  138024. export interface IGlowLayerOptions {
  138025. /**
  138026. * Multiplication factor apply to the canvas size to compute the render target size
  138027. * used to generated the glowing objects (the smaller the faster).
  138028. */
  138029. mainTextureRatio: number;
  138030. /**
  138031. * Enforces a fixed size texture to ensure resize independant blur.
  138032. */
  138033. mainTextureFixedSize?: number;
  138034. /**
  138035. * How big is the kernel of the blur texture.
  138036. */
  138037. blurKernelSize: number;
  138038. /**
  138039. * The camera attached to the layer.
  138040. */
  138041. camera: Nullable<Camera>;
  138042. /**
  138043. * Enable MSAA by chosing the number of samples.
  138044. */
  138045. mainTextureSamples?: number;
  138046. /**
  138047. * The rendering group to draw the layer in.
  138048. */
  138049. renderingGroupId: number;
  138050. }
  138051. /**
  138052. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  138053. *
  138054. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  138055. *
  138056. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  138057. */
  138058. export class GlowLayer extends EffectLayer {
  138059. /**
  138060. * Effect Name of the layer.
  138061. */
  138062. static readonly EffectName: string;
  138063. /**
  138064. * The default blur kernel size used for the glow.
  138065. */
  138066. static DefaultBlurKernelSize: number;
  138067. /**
  138068. * The default texture size ratio used for the glow.
  138069. */
  138070. static DefaultTextureRatio: number;
  138071. /**
  138072. * Sets the kernel size of the blur.
  138073. */
  138074. set blurKernelSize(value: number);
  138075. /**
  138076. * Gets the kernel size of the blur.
  138077. */
  138078. get blurKernelSize(): number;
  138079. /**
  138080. * Sets the glow intensity.
  138081. */
  138082. set intensity(value: number);
  138083. /**
  138084. * Gets the glow intensity.
  138085. */
  138086. get intensity(): number;
  138087. private _options;
  138088. private _intensity;
  138089. private _horizontalBlurPostprocess1;
  138090. private _verticalBlurPostprocess1;
  138091. private _horizontalBlurPostprocess2;
  138092. private _verticalBlurPostprocess2;
  138093. private _blurTexture1;
  138094. private _blurTexture2;
  138095. private _postProcesses1;
  138096. private _postProcesses2;
  138097. private _includedOnlyMeshes;
  138098. private _excludedMeshes;
  138099. private _meshesUsingTheirOwnMaterials;
  138100. /**
  138101. * Callback used to let the user override the color selection on a per mesh basis
  138102. */
  138103. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  138104. /**
  138105. * Callback used to let the user override the texture selection on a per mesh basis
  138106. */
  138107. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  138108. /**
  138109. * Instantiates a new glow Layer and references it to the scene.
  138110. * @param name The name of the layer
  138111. * @param scene The scene to use the layer in
  138112. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  138113. */
  138114. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  138115. /**
  138116. * Get the effect name of the layer.
  138117. * @return The effect name
  138118. */
  138119. getEffectName(): string;
  138120. /**
  138121. * Create the merge effect. This is the shader use to blit the information back
  138122. * to the main canvas at the end of the scene rendering.
  138123. */
  138124. protected _createMergeEffect(): Effect;
  138125. /**
  138126. * Creates the render target textures and post processes used in the glow layer.
  138127. */
  138128. protected _createTextureAndPostProcesses(): void;
  138129. /**
  138130. * Checks for the readiness of the element composing the layer.
  138131. * @param subMesh the mesh to check for
  138132. * @param useInstances specify wether or not to use instances to render the mesh
  138133. * @param emissiveTexture the associated emissive texture used to generate the glow
  138134. * @return true if ready otherwise, false
  138135. */
  138136. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138137. /**
  138138. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138139. */
  138140. needStencil(): boolean;
  138141. /**
  138142. * Returns true if the mesh can be rendered, otherwise false.
  138143. * @param mesh The mesh to render
  138144. * @param material The material used on the mesh
  138145. * @returns true if it can be rendered otherwise false
  138146. */
  138147. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138148. /**
  138149. * Implementation specific of rendering the generating effect on the main canvas.
  138150. * @param effect The effect used to render through
  138151. */
  138152. protected _internalRender(effect: Effect): void;
  138153. /**
  138154. * Sets the required values for both the emissive texture and and the main color.
  138155. */
  138156. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138157. /**
  138158. * Returns true if the mesh should render, otherwise false.
  138159. * @param mesh The mesh to render
  138160. * @returns true if it should render otherwise false
  138161. */
  138162. protected _shouldRenderMesh(mesh: Mesh): boolean;
  138163. /**
  138164. * Adds specific effects defines.
  138165. * @param defines The defines to add specifics to.
  138166. */
  138167. protected _addCustomEffectDefines(defines: string[]): void;
  138168. /**
  138169. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  138170. * @param mesh The mesh to exclude from the glow layer
  138171. */
  138172. addExcludedMesh(mesh: Mesh): void;
  138173. /**
  138174. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  138175. * @param mesh The mesh to remove
  138176. */
  138177. removeExcludedMesh(mesh: Mesh): void;
  138178. /**
  138179. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  138180. * @param mesh The mesh to include in the glow layer
  138181. */
  138182. addIncludedOnlyMesh(mesh: Mesh): void;
  138183. /**
  138184. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  138185. * @param mesh The mesh to remove
  138186. */
  138187. removeIncludedOnlyMesh(mesh: Mesh): void;
  138188. /**
  138189. * Determine if a given mesh will be used in the glow layer
  138190. * @param mesh The mesh to test
  138191. * @returns true if the mesh will be highlighted by the current glow layer
  138192. */
  138193. hasMesh(mesh: AbstractMesh): boolean;
  138194. /**
  138195. * Defines whether the current material of the mesh should be use to render the effect.
  138196. * @param mesh defines the current mesh to render
  138197. */
  138198. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138199. /**
  138200. * Add a mesh to be rendered through its own material and not with emissive only.
  138201. * @param mesh The mesh for which we need to use its material
  138202. */
  138203. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  138204. /**
  138205. * Remove a mesh from being rendered through its own material and not with emissive only.
  138206. * @param mesh The mesh for which we need to not use its material
  138207. */
  138208. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  138209. /**
  138210. * Free any resources and references associated to a mesh.
  138211. * Internal use
  138212. * @param mesh The mesh to free.
  138213. * @hidden
  138214. */
  138215. _disposeMesh(mesh: Mesh): void;
  138216. /**
  138217. * Gets the class name of the effect layer
  138218. * @returns the string with the class name of the effect layer
  138219. */
  138220. getClassName(): string;
  138221. /**
  138222. * Serializes this glow layer
  138223. * @returns a serialized glow layer object
  138224. */
  138225. serialize(): any;
  138226. /**
  138227. * Creates a Glow Layer from parsed glow layer data
  138228. * @param parsedGlowLayer defines glow layer data
  138229. * @param scene defines the current scene
  138230. * @param rootUrl defines the root URL containing the glow layer information
  138231. * @returns a parsed Glow Layer
  138232. */
  138233. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  138234. }
  138235. }
  138236. declare module BABYLON {
  138237. /** @hidden */
  138238. export var glowBlurPostProcessPixelShader: {
  138239. name: string;
  138240. shader: string;
  138241. };
  138242. }
  138243. declare module BABYLON {
  138244. interface AbstractScene {
  138245. /**
  138246. * Return a the first highlight layer of the scene with a given name.
  138247. * @param name The name of the highlight layer to look for.
  138248. * @return The highlight layer if found otherwise null.
  138249. */
  138250. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  138251. }
  138252. /**
  138253. * Highlight layer options. This helps customizing the behaviour
  138254. * of the highlight layer.
  138255. */
  138256. export interface IHighlightLayerOptions {
  138257. /**
  138258. * Multiplication factor apply to the canvas size to compute the render target size
  138259. * used to generated the glowing objects (the smaller the faster).
  138260. */
  138261. mainTextureRatio: number;
  138262. /**
  138263. * Enforces a fixed size texture to ensure resize independant blur.
  138264. */
  138265. mainTextureFixedSize?: number;
  138266. /**
  138267. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  138268. * of the picture to blur (the smaller the faster).
  138269. */
  138270. blurTextureSizeRatio: number;
  138271. /**
  138272. * How big in texel of the blur texture is the vertical blur.
  138273. */
  138274. blurVerticalSize: number;
  138275. /**
  138276. * How big in texel of the blur texture is the horizontal blur.
  138277. */
  138278. blurHorizontalSize: number;
  138279. /**
  138280. * Alpha blending mode used to apply the blur. Default is combine.
  138281. */
  138282. alphaBlendingMode: number;
  138283. /**
  138284. * The camera attached to the layer.
  138285. */
  138286. camera: Nullable<Camera>;
  138287. /**
  138288. * Should we display highlight as a solid stroke?
  138289. */
  138290. isStroke?: boolean;
  138291. /**
  138292. * The rendering group to draw the layer in.
  138293. */
  138294. renderingGroupId: number;
  138295. }
  138296. /**
  138297. * The highlight layer Helps adding a glow effect around a mesh.
  138298. *
  138299. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  138300. * glowy meshes to your scene.
  138301. *
  138302. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  138303. */
  138304. export class HighlightLayer extends EffectLayer {
  138305. name: string;
  138306. /**
  138307. * Effect Name of the highlight layer.
  138308. */
  138309. static readonly EffectName: string;
  138310. /**
  138311. * The neutral color used during the preparation of the glow effect.
  138312. * This is black by default as the blend operation is a blend operation.
  138313. */
  138314. static NeutralColor: Color4;
  138315. /**
  138316. * Stencil value used for glowing meshes.
  138317. */
  138318. static GlowingMeshStencilReference: number;
  138319. /**
  138320. * Stencil value used for the other meshes in the scene.
  138321. */
  138322. static NormalMeshStencilReference: number;
  138323. /**
  138324. * Specifies whether or not the inner glow is ACTIVE in the layer.
  138325. */
  138326. innerGlow: boolean;
  138327. /**
  138328. * Specifies whether or not the outer glow is ACTIVE in the layer.
  138329. */
  138330. outerGlow: boolean;
  138331. /**
  138332. * Specifies the horizontal size of the blur.
  138333. */
  138334. set blurHorizontalSize(value: number);
  138335. /**
  138336. * Specifies the vertical size of the blur.
  138337. */
  138338. set blurVerticalSize(value: number);
  138339. /**
  138340. * Gets the horizontal size of the blur.
  138341. */
  138342. get blurHorizontalSize(): number;
  138343. /**
  138344. * Gets the vertical size of the blur.
  138345. */
  138346. get blurVerticalSize(): number;
  138347. /**
  138348. * An event triggered when the highlight layer is being blurred.
  138349. */
  138350. onBeforeBlurObservable: Observable<HighlightLayer>;
  138351. /**
  138352. * An event triggered when the highlight layer has been blurred.
  138353. */
  138354. onAfterBlurObservable: Observable<HighlightLayer>;
  138355. private _instanceGlowingMeshStencilReference;
  138356. private _options;
  138357. private _downSamplePostprocess;
  138358. private _horizontalBlurPostprocess;
  138359. private _verticalBlurPostprocess;
  138360. private _blurTexture;
  138361. private _meshes;
  138362. private _excludedMeshes;
  138363. /**
  138364. * Instantiates a new highlight Layer and references it to the scene..
  138365. * @param name The name of the layer
  138366. * @param scene The scene to use the layer in
  138367. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  138368. */
  138369. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  138370. /**
  138371. * Get the effect name of the layer.
  138372. * @return The effect name
  138373. */
  138374. getEffectName(): string;
  138375. /**
  138376. * Create the merge effect. This is the shader use to blit the information back
  138377. * to the main canvas at the end of the scene rendering.
  138378. */
  138379. protected _createMergeEffect(): Effect;
  138380. /**
  138381. * Creates the render target textures and post processes used in the highlight layer.
  138382. */
  138383. protected _createTextureAndPostProcesses(): void;
  138384. /**
  138385. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  138386. */
  138387. needStencil(): boolean;
  138388. /**
  138389. * Checks for the readiness of the element composing the layer.
  138390. * @param subMesh the mesh to check for
  138391. * @param useInstances specify wether or not to use instances to render the mesh
  138392. * @param emissiveTexture the associated emissive texture used to generate the glow
  138393. * @return true if ready otherwise, false
  138394. */
  138395. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138396. /**
  138397. * Implementation specific of rendering the generating effect on the main canvas.
  138398. * @param effect The effect used to render through
  138399. */
  138400. protected _internalRender(effect: Effect): void;
  138401. /**
  138402. * Returns true if the layer contains information to display, otherwise false.
  138403. */
  138404. shouldRender(): boolean;
  138405. /**
  138406. * Returns true if the mesh should render, otherwise false.
  138407. * @param mesh The mesh to render
  138408. * @returns true if it should render otherwise false
  138409. */
  138410. protected _shouldRenderMesh(mesh: Mesh): boolean;
  138411. /**
  138412. * Returns true if the mesh can be rendered, otherwise false.
  138413. * @param mesh The mesh to render
  138414. * @param material The material used on the mesh
  138415. * @returns true if it can be rendered otherwise false
  138416. */
  138417. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138418. /**
  138419. * Adds specific effects defines.
  138420. * @param defines The defines to add specifics to.
  138421. */
  138422. protected _addCustomEffectDefines(defines: string[]): void;
  138423. /**
  138424. * Sets the required values for both the emissive texture and and the main color.
  138425. */
  138426. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138427. /**
  138428. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  138429. * @param mesh The mesh to exclude from the highlight layer
  138430. */
  138431. addExcludedMesh(mesh: Mesh): void;
  138432. /**
  138433. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  138434. * @param mesh The mesh to highlight
  138435. */
  138436. removeExcludedMesh(mesh: Mesh): void;
  138437. /**
  138438. * Determine if a given mesh will be highlighted by the current HighlightLayer
  138439. * @param mesh mesh to test
  138440. * @returns true if the mesh will be highlighted by the current HighlightLayer
  138441. */
  138442. hasMesh(mesh: AbstractMesh): boolean;
  138443. /**
  138444. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  138445. * @param mesh The mesh to highlight
  138446. * @param color The color of the highlight
  138447. * @param glowEmissiveOnly Extract the glow from the emissive texture
  138448. */
  138449. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  138450. /**
  138451. * Remove a mesh from the highlight layer in order to make it stop glowing.
  138452. * @param mesh The mesh to highlight
  138453. */
  138454. removeMesh(mesh: Mesh): void;
  138455. /**
  138456. * Remove all the meshes currently referenced in the highlight layer
  138457. */
  138458. removeAllMeshes(): void;
  138459. /**
  138460. * Force the stencil to the normal expected value for none glowing parts
  138461. */
  138462. private _defaultStencilReference;
  138463. /**
  138464. * Free any resources and references associated to a mesh.
  138465. * Internal use
  138466. * @param mesh The mesh to free.
  138467. * @hidden
  138468. */
  138469. _disposeMesh(mesh: Mesh): void;
  138470. /**
  138471. * Dispose the highlight layer and free resources.
  138472. */
  138473. dispose(): void;
  138474. /**
  138475. * Gets the class name of the effect layer
  138476. * @returns the string with the class name of the effect layer
  138477. */
  138478. getClassName(): string;
  138479. /**
  138480. * Serializes this Highlight layer
  138481. * @returns a serialized Highlight layer object
  138482. */
  138483. serialize(): any;
  138484. /**
  138485. * Creates a Highlight layer from parsed Highlight layer data
  138486. * @param parsedHightlightLayer defines the Highlight layer data
  138487. * @param scene defines the current scene
  138488. * @param rootUrl defines the root URL containing the Highlight layer information
  138489. * @returns a parsed Highlight layer
  138490. */
  138491. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  138492. }
  138493. }
  138494. declare module BABYLON {
  138495. interface AbstractScene {
  138496. /**
  138497. * The list of layers (background and foreground) of the scene
  138498. */
  138499. layers: Array<Layer>;
  138500. }
  138501. /**
  138502. * Defines the layer scene component responsible to manage any layers
  138503. * in a given scene.
  138504. */
  138505. export class LayerSceneComponent implements ISceneComponent {
  138506. /**
  138507. * The component name helpfull to identify the component in the list of scene components.
  138508. */
  138509. readonly name: string;
  138510. /**
  138511. * The scene the component belongs to.
  138512. */
  138513. scene: Scene;
  138514. private _engine;
  138515. /**
  138516. * Creates a new instance of the component for the given scene
  138517. * @param scene Defines the scene to register the component in
  138518. */
  138519. constructor(scene: Scene);
  138520. /**
  138521. * Registers the component in a given scene
  138522. */
  138523. register(): void;
  138524. /**
  138525. * Rebuilds the elements related to this component in case of
  138526. * context lost for instance.
  138527. */
  138528. rebuild(): void;
  138529. /**
  138530. * Disposes the component and the associated ressources.
  138531. */
  138532. dispose(): void;
  138533. private _draw;
  138534. private _drawCameraPredicate;
  138535. private _drawCameraBackground;
  138536. private _drawCameraForeground;
  138537. private _drawRenderTargetPredicate;
  138538. private _drawRenderTargetBackground;
  138539. private _drawRenderTargetForeground;
  138540. /**
  138541. * Adds all the elements from the container to the scene
  138542. * @param container the container holding the elements
  138543. */
  138544. addFromContainer(container: AbstractScene): void;
  138545. /**
  138546. * Removes all the elements in the container from the scene
  138547. * @param container contains the elements to remove
  138548. * @param dispose if the removed element should be disposed (default: false)
  138549. */
  138550. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138551. }
  138552. }
  138553. declare module BABYLON {
  138554. /** @hidden */
  138555. export var layerPixelShader: {
  138556. name: string;
  138557. shader: string;
  138558. };
  138559. }
  138560. declare module BABYLON {
  138561. /** @hidden */
  138562. export var layerVertexShader: {
  138563. name: string;
  138564. shader: string;
  138565. };
  138566. }
  138567. declare module BABYLON {
  138568. /**
  138569. * This represents a full screen 2d layer.
  138570. * This can be useful to display a picture in the background of your scene for instance.
  138571. * @see https://www.babylonjs-playground.com/#08A2BS#1
  138572. */
  138573. export class Layer {
  138574. /**
  138575. * Define the name of the layer.
  138576. */
  138577. name: string;
  138578. /**
  138579. * Define the texture the layer should display.
  138580. */
  138581. texture: Nullable<Texture>;
  138582. /**
  138583. * Is the layer in background or foreground.
  138584. */
  138585. isBackground: boolean;
  138586. /**
  138587. * Define the color of the layer (instead of texture).
  138588. */
  138589. color: Color4;
  138590. /**
  138591. * Define the scale of the layer in order to zoom in out of the texture.
  138592. */
  138593. scale: Vector2;
  138594. /**
  138595. * Define an offset for the layer in order to shift the texture.
  138596. */
  138597. offset: Vector2;
  138598. /**
  138599. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  138600. */
  138601. alphaBlendingMode: number;
  138602. /**
  138603. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  138604. * Alpha test will not mix with the background color in case of transparency.
  138605. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  138606. */
  138607. alphaTest: boolean;
  138608. /**
  138609. * Define a mask to restrict the layer to only some of the scene cameras.
  138610. */
  138611. layerMask: number;
  138612. /**
  138613. * Define the list of render target the layer is visible into.
  138614. */
  138615. renderTargetTextures: RenderTargetTexture[];
  138616. /**
  138617. * Define if the layer is only used in renderTarget or if it also
  138618. * renders in the main frame buffer of the canvas.
  138619. */
  138620. renderOnlyInRenderTargetTextures: boolean;
  138621. private _scene;
  138622. private _vertexBuffers;
  138623. private _indexBuffer;
  138624. private _effect;
  138625. private _previousDefines;
  138626. /**
  138627. * An event triggered when the layer is disposed.
  138628. */
  138629. onDisposeObservable: Observable<Layer>;
  138630. private _onDisposeObserver;
  138631. /**
  138632. * Back compatibility with callback before the onDisposeObservable existed.
  138633. * The set callback will be triggered when the layer has been disposed.
  138634. */
  138635. set onDispose(callback: () => void);
  138636. /**
  138637. * An event triggered before rendering the scene
  138638. */
  138639. onBeforeRenderObservable: Observable<Layer>;
  138640. private _onBeforeRenderObserver;
  138641. /**
  138642. * Back compatibility with callback before the onBeforeRenderObservable existed.
  138643. * The set callback will be triggered just before rendering the layer.
  138644. */
  138645. set onBeforeRender(callback: () => void);
  138646. /**
  138647. * An event triggered after rendering the scene
  138648. */
  138649. onAfterRenderObservable: Observable<Layer>;
  138650. private _onAfterRenderObserver;
  138651. /**
  138652. * Back compatibility with callback before the onAfterRenderObservable existed.
  138653. * The set callback will be triggered just after rendering the layer.
  138654. */
  138655. set onAfterRender(callback: () => void);
  138656. /**
  138657. * Instantiates a new layer.
  138658. * This represents a full screen 2d layer.
  138659. * This can be useful to display a picture in the background of your scene for instance.
  138660. * @see https://www.babylonjs-playground.com/#08A2BS#1
  138661. * @param name Define the name of the layer in the scene
  138662. * @param imgUrl Define the url of the texture to display in the layer
  138663. * @param scene Define the scene the layer belongs to
  138664. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  138665. * @param color Defines a color for the layer
  138666. */
  138667. constructor(
  138668. /**
  138669. * Define the name of the layer.
  138670. */
  138671. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  138672. private _createIndexBuffer;
  138673. /** @hidden */
  138674. _rebuild(): void;
  138675. /**
  138676. * Renders the layer in the scene.
  138677. */
  138678. render(): void;
  138679. /**
  138680. * Disposes and releases the associated ressources.
  138681. */
  138682. dispose(): void;
  138683. }
  138684. }
  138685. declare module BABYLON {
  138686. /** @hidden */
  138687. export var lensFlarePixelShader: {
  138688. name: string;
  138689. shader: string;
  138690. };
  138691. }
  138692. declare module BABYLON {
  138693. /** @hidden */
  138694. export var lensFlareVertexShader: {
  138695. name: string;
  138696. shader: string;
  138697. };
  138698. }
  138699. declare module BABYLON {
  138700. /**
  138701. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  138702. * It is usually composed of several `lensFlare`.
  138703. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138704. */
  138705. export class LensFlareSystem {
  138706. /**
  138707. * Define the name of the lens flare system
  138708. */
  138709. name: string;
  138710. /**
  138711. * List of lens flares used in this system.
  138712. */
  138713. lensFlares: LensFlare[];
  138714. /**
  138715. * Define a limit from the border the lens flare can be visible.
  138716. */
  138717. borderLimit: number;
  138718. /**
  138719. * Define a viewport border we do not want to see the lens flare in.
  138720. */
  138721. viewportBorder: number;
  138722. /**
  138723. * Define a predicate which could limit the list of meshes able to occlude the effect.
  138724. */
  138725. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  138726. /**
  138727. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  138728. */
  138729. layerMask: number;
  138730. /**
  138731. * Define the id of the lens flare system in the scene.
  138732. * (equal to name by default)
  138733. */
  138734. id: string;
  138735. private _scene;
  138736. private _emitter;
  138737. private _vertexBuffers;
  138738. private _indexBuffer;
  138739. private _effect;
  138740. private _positionX;
  138741. private _positionY;
  138742. private _isEnabled;
  138743. /** @hidden */
  138744. static _SceneComponentInitialization: (scene: Scene) => void;
  138745. /**
  138746. * Instantiates a lens flare system.
  138747. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  138748. * It is usually composed of several `lensFlare`.
  138749. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138750. * @param name Define the name of the lens flare system in the scene
  138751. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  138752. * @param scene Define the scene the lens flare system belongs to
  138753. */
  138754. constructor(
  138755. /**
  138756. * Define the name of the lens flare system
  138757. */
  138758. name: string, emitter: any, scene: Scene);
  138759. /**
  138760. * Define if the lens flare system is enabled.
  138761. */
  138762. get isEnabled(): boolean;
  138763. set isEnabled(value: boolean);
  138764. /**
  138765. * Get the scene the effects belongs to.
  138766. * @returns the scene holding the lens flare system
  138767. */
  138768. getScene(): Scene;
  138769. /**
  138770. * Get the emitter of the lens flare system.
  138771. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  138772. * @returns the emitter of the lens flare system
  138773. */
  138774. getEmitter(): any;
  138775. /**
  138776. * Set the emitter of the lens flare system.
  138777. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  138778. * @param newEmitter Define the new emitter of the system
  138779. */
  138780. setEmitter(newEmitter: any): void;
  138781. /**
  138782. * Get the lens flare system emitter position.
  138783. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  138784. * @returns the position
  138785. */
  138786. getEmitterPosition(): Vector3;
  138787. /**
  138788. * @hidden
  138789. */
  138790. computeEffectivePosition(globalViewport: Viewport): boolean;
  138791. /** @hidden */
  138792. _isVisible(): boolean;
  138793. /**
  138794. * @hidden
  138795. */
  138796. render(): boolean;
  138797. /**
  138798. * Dispose and release the lens flare with its associated resources.
  138799. */
  138800. dispose(): void;
  138801. /**
  138802. * Parse a lens flare system from a JSON repressentation
  138803. * @param parsedLensFlareSystem Define the JSON to parse
  138804. * @param scene Define the scene the parsed system should be instantiated in
  138805. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  138806. * @returns the parsed system
  138807. */
  138808. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  138809. /**
  138810. * Serialize the current Lens Flare System into a JSON representation.
  138811. * @returns the serialized JSON
  138812. */
  138813. serialize(): any;
  138814. }
  138815. }
  138816. declare module BABYLON {
  138817. /**
  138818. * This represents one of the lens effect in a `lensFlareSystem`.
  138819. * It controls one of the indiviual texture used in the effect.
  138820. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138821. */
  138822. export class LensFlare {
  138823. /**
  138824. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  138825. */
  138826. size: number;
  138827. /**
  138828. * 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.
  138829. */
  138830. position: number;
  138831. /**
  138832. * Define the lens color.
  138833. */
  138834. color: Color3;
  138835. /**
  138836. * Define the lens texture.
  138837. */
  138838. texture: Nullable<Texture>;
  138839. /**
  138840. * Define the alpha mode to render this particular lens.
  138841. */
  138842. alphaMode: number;
  138843. private _system;
  138844. /**
  138845. * Creates a new Lens Flare.
  138846. * This represents one of the lens effect in a `lensFlareSystem`.
  138847. * It controls one of the indiviual texture used in the effect.
  138848. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138849. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  138850. * @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.
  138851. * @param color Define the lens color
  138852. * @param imgUrl Define the lens texture url
  138853. * @param system Define the `lensFlareSystem` this flare is part of
  138854. * @returns The newly created Lens Flare
  138855. */
  138856. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  138857. /**
  138858. * Instantiates a new Lens Flare.
  138859. * This represents one of the lens effect in a `lensFlareSystem`.
  138860. * It controls one of the indiviual texture used in the effect.
  138861. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138862. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  138863. * @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.
  138864. * @param color Define the lens color
  138865. * @param imgUrl Define the lens texture url
  138866. * @param system Define the `lensFlareSystem` this flare is part of
  138867. */
  138868. constructor(
  138869. /**
  138870. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  138871. */
  138872. size: number,
  138873. /**
  138874. * 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.
  138875. */
  138876. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  138877. /**
  138878. * Dispose and release the lens flare with its associated resources.
  138879. */
  138880. dispose(): void;
  138881. }
  138882. }
  138883. declare module BABYLON {
  138884. interface AbstractScene {
  138885. /**
  138886. * The list of lens flare system added to the scene
  138887. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138888. */
  138889. lensFlareSystems: Array<LensFlareSystem>;
  138890. /**
  138891. * Removes the given lens flare system from this scene.
  138892. * @param toRemove The lens flare system to remove
  138893. * @returns The index of the removed lens flare system
  138894. */
  138895. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  138896. /**
  138897. * Adds the given lens flare system to this scene
  138898. * @param newLensFlareSystem The lens flare system to add
  138899. */
  138900. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  138901. /**
  138902. * Gets a lens flare system using its name
  138903. * @param name defines the name to look for
  138904. * @returns the lens flare system or null if not found
  138905. */
  138906. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  138907. /**
  138908. * Gets a lens flare system using its id
  138909. * @param id defines the id to look for
  138910. * @returns the lens flare system or null if not found
  138911. */
  138912. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  138913. }
  138914. /**
  138915. * Defines the lens flare scene component responsible to manage any lens flares
  138916. * in a given scene.
  138917. */
  138918. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  138919. /**
  138920. * The component name helpfull to identify the component in the list of scene components.
  138921. */
  138922. readonly name: string;
  138923. /**
  138924. * The scene the component belongs to.
  138925. */
  138926. scene: Scene;
  138927. /**
  138928. * Creates a new instance of the component for the given scene
  138929. * @param scene Defines the scene to register the component in
  138930. */
  138931. constructor(scene: Scene);
  138932. /**
  138933. * Registers the component in a given scene
  138934. */
  138935. register(): void;
  138936. /**
  138937. * Rebuilds the elements related to this component in case of
  138938. * context lost for instance.
  138939. */
  138940. rebuild(): void;
  138941. /**
  138942. * Adds all the elements from the container to the scene
  138943. * @param container the container holding the elements
  138944. */
  138945. addFromContainer(container: AbstractScene): void;
  138946. /**
  138947. * Removes all the elements in the container from the scene
  138948. * @param container contains the elements to remove
  138949. * @param dispose if the removed element should be disposed (default: false)
  138950. */
  138951. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138952. /**
  138953. * Serializes the component data to the specified json object
  138954. * @param serializationObject The object to serialize to
  138955. */
  138956. serialize(serializationObject: any): void;
  138957. /**
  138958. * Disposes the component and the associated ressources.
  138959. */
  138960. dispose(): void;
  138961. private _draw;
  138962. }
  138963. }
  138964. declare module BABYLON {
  138965. /** @hidden */
  138966. export var depthPixelShader: {
  138967. name: string;
  138968. shader: string;
  138969. };
  138970. }
  138971. declare module BABYLON {
  138972. /** @hidden */
  138973. export var depthVertexShader: {
  138974. name: string;
  138975. shader: string;
  138976. };
  138977. }
  138978. declare module BABYLON {
  138979. /**
  138980. * This represents a depth renderer in Babylon.
  138981. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  138982. */
  138983. export class DepthRenderer {
  138984. private _scene;
  138985. private _depthMap;
  138986. private _effect;
  138987. private readonly _storeNonLinearDepth;
  138988. private readonly _clearColor;
  138989. /** Get if the depth renderer is using packed depth or not */
  138990. readonly isPacked: boolean;
  138991. private _cachedDefines;
  138992. private _camera;
  138993. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  138994. enabled: boolean;
  138995. /**
  138996. * Specifiess that the depth renderer will only be used within
  138997. * the camera it is created for.
  138998. * This can help forcing its rendering during the camera processing.
  138999. */
  139000. useOnlyInActiveCamera: boolean;
  139001. /** @hidden */
  139002. static _SceneComponentInitialization: (scene: Scene) => void;
  139003. /**
  139004. * Instantiates a depth renderer
  139005. * @param scene The scene the renderer belongs to
  139006. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  139007. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  139008. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139009. */
  139010. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  139011. /**
  139012. * Creates the depth rendering effect and checks if the effect is ready.
  139013. * @param subMesh The submesh to be used to render the depth map of
  139014. * @param useInstances If multiple world instances should be used
  139015. * @returns if the depth renderer is ready to render the depth map
  139016. */
  139017. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139018. /**
  139019. * Gets the texture which the depth map will be written to.
  139020. * @returns The depth map texture
  139021. */
  139022. getDepthMap(): RenderTargetTexture;
  139023. /**
  139024. * Disposes of the depth renderer.
  139025. */
  139026. dispose(): void;
  139027. }
  139028. }
  139029. declare module BABYLON {
  139030. /** @hidden */
  139031. export var minmaxReduxPixelShader: {
  139032. name: string;
  139033. shader: string;
  139034. };
  139035. }
  139036. declare module BABYLON {
  139037. /**
  139038. * This class computes a min/max reduction from a texture: it means it computes the minimum
  139039. * and maximum values from all values of the texture.
  139040. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  139041. * The source values are read from the red channel of the texture.
  139042. */
  139043. export class MinMaxReducer {
  139044. /**
  139045. * Observable triggered when the computation has been performed
  139046. */
  139047. onAfterReductionPerformed: Observable<{
  139048. min: number;
  139049. max: number;
  139050. }>;
  139051. protected _camera: Camera;
  139052. protected _sourceTexture: Nullable<RenderTargetTexture>;
  139053. protected _reductionSteps: Nullable<Array<PostProcess>>;
  139054. protected _postProcessManager: PostProcessManager;
  139055. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  139056. protected _forceFullscreenViewport: boolean;
  139057. /**
  139058. * Creates a min/max reducer
  139059. * @param camera The camera to use for the post processes
  139060. */
  139061. constructor(camera: Camera);
  139062. /**
  139063. * Gets the texture used to read the values from.
  139064. */
  139065. get sourceTexture(): Nullable<RenderTargetTexture>;
  139066. /**
  139067. * Sets the source texture to read the values from.
  139068. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  139069. * because in such textures '1' value must not be taken into account to compute the maximum
  139070. * as this value is used to clear the texture.
  139071. * Note that the computation is not activated by calling this function, you must call activate() for that!
  139072. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  139073. * @param depthRedux Indicates if the texture is a depth texture or not
  139074. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  139075. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  139076. */
  139077. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  139078. /**
  139079. * Defines the refresh rate of the computation.
  139080. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  139081. */
  139082. get refreshRate(): number;
  139083. set refreshRate(value: number);
  139084. protected _activated: boolean;
  139085. /**
  139086. * Gets the activation status of the reducer
  139087. */
  139088. get activated(): boolean;
  139089. /**
  139090. * Activates the reduction computation.
  139091. * When activated, the observers registered in onAfterReductionPerformed are
  139092. * called after the compuation is performed
  139093. */
  139094. activate(): void;
  139095. /**
  139096. * Deactivates the reduction computation.
  139097. */
  139098. deactivate(): void;
  139099. /**
  139100. * Disposes the min/max reducer
  139101. * @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.
  139102. */
  139103. dispose(disposeAll?: boolean): void;
  139104. }
  139105. }
  139106. declare module BABYLON {
  139107. /**
  139108. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  139109. */
  139110. export class DepthReducer extends MinMaxReducer {
  139111. private _depthRenderer;
  139112. private _depthRendererId;
  139113. /**
  139114. * Gets the depth renderer used for the computation.
  139115. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  139116. */
  139117. get depthRenderer(): Nullable<DepthRenderer>;
  139118. /**
  139119. * Creates a depth reducer
  139120. * @param camera The camera used to render the depth texture
  139121. */
  139122. constructor(camera: Camera);
  139123. /**
  139124. * Sets the depth renderer to use to generate the depth map
  139125. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  139126. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  139127. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  139128. */
  139129. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  139130. /** @hidden */
  139131. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  139132. /**
  139133. * Activates the reduction computation.
  139134. * When activated, the observers registered in onAfterReductionPerformed are
  139135. * called after the compuation is performed
  139136. */
  139137. activate(): void;
  139138. /**
  139139. * Deactivates the reduction computation.
  139140. */
  139141. deactivate(): void;
  139142. /**
  139143. * Disposes the depth reducer
  139144. * @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.
  139145. */
  139146. dispose(disposeAll?: boolean): void;
  139147. }
  139148. }
  139149. declare module BABYLON {
  139150. /**
  139151. * A CSM implementation allowing casting shadows on large scenes.
  139152. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  139153. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  139154. */
  139155. export class CascadedShadowGenerator extends ShadowGenerator {
  139156. private static readonly frustumCornersNDCSpace;
  139157. /**
  139158. * Name of the CSM class
  139159. */
  139160. static CLASSNAME: string;
  139161. /**
  139162. * Defines the default number of cascades used by the CSM.
  139163. */
  139164. static readonly DEFAULT_CASCADES_COUNT: number;
  139165. /**
  139166. * Defines the minimum number of cascades used by the CSM.
  139167. */
  139168. static readonly MIN_CASCADES_COUNT: number;
  139169. /**
  139170. * Defines the maximum number of cascades used by the CSM.
  139171. */
  139172. static readonly MAX_CASCADES_COUNT: number;
  139173. protected _validateFilter(filter: number): number;
  139174. /**
  139175. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  139176. */
  139177. penumbraDarkness: number;
  139178. private _numCascades;
  139179. /**
  139180. * Gets or set the number of cascades used by the CSM.
  139181. */
  139182. get numCascades(): number;
  139183. set numCascades(value: number);
  139184. /**
  139185. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  139186. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  139187. */
  139188. stabilizeCascades: boolean;
  139189. private _freezeShadowCastersBoundingInfo;
  139190. private _freezeShadowCastersBoundingInfoObservable;
  139191. /**
  139192. * Enables or disables the shadow casters bounding info computation.
  139193. * If your shadow casters don't move, you can disable this feature.
  139194. * If it is enabled, the bounding box computation is done every frame.
  139195. */
  139196. get freezeShadowCastersBoundingInfo(): boolean;
  139197. set freezeShadowCastersBoundingInfo(freeze: boolean);
  139198. private _scbiMin;
  139199. private _scbiMax;
  139200. protected _computeShadowCastersBoundingInfo(): void;
  139201. protected _shadowCastersBoundingInfo: BoundingInfo;
  139202. /**
  139203. * Gets or sets the shadow casters bounding info.
  139204. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  139205. * so that the system won't overwrite the bounds you provide
  139206. */
  139207. get shadowCastersBoundingInfo(): BoundingInfo;
  139208. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  139209. protected _breaksAreDirty: boolean;
  139210. protected _minDistance: number;
  139211. protected _maxDistance: number;
  139212. /**
  139213. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  139214. *
  139215. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  139216. * If you don't know these values, simply leave them to their defaults and don't call this function.
  139217. * @param min minimal distance for the breaks (default to 0.)
  139218. * @param max maximal distance for the breaks (default to 1.)
  139219. */
  139220. setMinMaxDistance(min: number, max: number): void;
  139221. /** Gets the minimal distance used in the cascade break computation */
  139222. get minDistance(): number;
  139223. /** Gets the maximal distance used in the cascade break computation */
  139224. get maxDistance(): number;
  139225. /**
  139226. * Gets the class name of that object
  139227. * @returns "CascadedShadowGenerator"
  139228. */
  139229. getClassName(): string;
  139230. private _cascadeMinExtents;
  139231. private _cascadeMaxExtents;
  139232. /**
  139233. * Gets a cascade minimum extents
  139234. * @param cascadeIndex index of the cascade
  139235. * @returns the minimum cascade extents
  139236. */
  139237. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  139238. /**
  139239. * Gets a cascade maximum extents
  139240. * @param cascadeIndex index of the cascade
  139241. * @returns the maximum cascade extents
  139242. */
  139243. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  139244. private _cascades;
  139245. private _currentLayer;
  139246. private _viewSpaceFrustumsZ;
  139247. private _viewMatrices;
  139248. private _projectionMatrices;
  139249. private _transformMatrices;
  139250. private _transformMatricesAsArray;
  139251. private _frustumLengths;
  139252. private _lightSizeUVCorrection;
  139253. private _depthCorrection;
  139254. private _frustumCornersWorldSpace;
  139255. private _frustumCenter;
  139256. private _shadowCameraPos;
  139257. private _shadowMaxZ;
  139258. /**
  139259. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  139260. * It defaults to camera.maxZ
  139261. */
  139262. get shadowMaxZ(): number;
  139263. /**
  139264. * Sets the shadow max z distance.
  139265. */
  139266. set shadowMaxZ(value: number);
  139267. protected _debug: boolean;
  139268. /**
  139269. * Gets or sets the debug flag.
  139270. * When enabled, the cascades are materialized by different colors on the screen.
  139271. */
  139272. get debug(): boolean;
  139273. set debug(dbg: boolean);
  139274. private _depthClamp;
  139275. /**
  139276. * Gets or sets the depth clamping value.
  139277. *
  139278. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  139279. * to account for the shadow casters far away.
  139280. *
  139281. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  139282. */
  139283. get depthClamp(): boolean;
  139284. set depthClamp(value: boolean);
  139285. private _cascadeBlendPercentage;
  139286. /**
  139287. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  139288. * It defaults to 0.1 (10% blending).
  139289. */
  139290. get cascadeBlendPercentage(): number;
  139291. set cascadeBlendPercentage(value: number);
  139292. private _lambda;
  139293. /**
  139294. * Gets or set the lambda parameter.
  139295. * This parameter is used to split the camera frustum and create the cascades.
  139296. * 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.
  139297. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  139298. */
  139299. get lambda(): number;
  139300. set lambda(value: number);
  139301. /**
  139302. * Gets the view matrix corresponding to a given cascade
  139303. * @param cascadeNum cascade to retrieve the view matrix from
  139304. * @returns the cascade view matrix
  139305. */
  139306. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  139307. /**
  139308. * Gets the projection matrix corresponding to a given cascade
  139309. * @param cascadeNum cascade to retrieve the projection matrix from
  139310. * @returns the cascade projection matrix
  139311. */
  139312. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  139313. /**
  139314. * Gets the transformation matrix corresponding to a given cascade
  139315. * @param cascadeNum cascade to retrieve the transformation matrix from
  139316. * @returns the cascade transformation matrix
  139317. */
  139318. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  139319. private _depthRenderer;
  139320. /**
  139321. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  139322. *
  139323. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  139324. *
  139325. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  139326. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  139327. * @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
  139328. */
  139329. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  139330. private _depthReducer;
  139331. private _autoCalcDepthBounds;
  139332. /**
  139333. * Gets or sets the autoCalcDepthBounds property.
  139334. *
  139335. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  139336. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  139337. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  139338. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  139339. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  139340. */
  139341. get autoCalcDepthBounds(): boolean;
  139342. set autoCalcDepthBounds(value: boolean);
  139343. /**
  139344. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  139345. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  139346. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  139347. * for setting the refresh rate on the renderer yourself!
  139348. */
  139349. get autoCalcDepthBoundsRefreshRate(): number;
  139350. set autoCalcDepthBoundsRefreshRate(value: number);
  139351. /**
  139352. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  139353. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  139354. * you change the camera near/far planes!
  139355. */
  139356. splitFrustum(): void;
  139357. private _splitFrustum;
  139358. private _computeMatrices;
  139359. private _computeFrustumInWorldSpace;
  139360. private _computeCascadeFrustum;
  139361. /**
  139362. * Support test.
  139363. */
  139364. static get IsSupported(): boolean;
  139365. /** @hidden */
  139366. static _SceneComponentInitialization: (scene: Scene) => void;
  139367. /**
  139368. * Creates a Cascaded Shadow Generator object.
  139369. * A ShadowGenerator is the required tool to use the shadows.
  139370. * Each directional light casting shadows needs to use its own ShadowGenerator.
  139371. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  139372. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  139373. * @param light The directional light object generating the shadows.
  139374. * @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.
  139375. */
  139376. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  139377. protected _initializeGenerator(): void;
  139378. protected _createTargetRenderTexture(): void;
  139379. protected _initializeShadowMap(): void;
  139380. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  139381. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  139382. /**
  139383. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  139384. * @param defines Defines of the material we want to update
  139385. * @param lightIndex Index of the light in the enabled light list of the material
  139386. */
  139387. prepareDefines(defines: any, lightIndex: number): void;
  139388. /**
  139389. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  139390. * defined in the generator but impacting the effect).
  139391. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  139392. * @param effect The effect we are binfing the information for
  139393. */
  139394. bindShadowLight(lightIndex: string, effect: Effect): void;
  139395. /**
  139396. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  139397. * (eq to view projection * shadow projection matrices)
  139398. * @returns The transform matrix used to create the shadow map
  139399. */
  139400. getTransformMatrix(): Matrix;
  139401. /**
  139402. * Disposes the ShadowGenerator.
  139403. * Returns nothing.
  139404. */
  139405. dispose(): void;
  139406. /**
  139407. * Serializes the shadow generator setup to a json object.
  139408. * @returns The serialized JSON object
  139409. */
  139410. serialize(): any;
  139411. /**
  139412. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  139413. * @param parsedShadowGenerator The JSON object to parse
  139414. * @param scene The scene to create the shadow map for
  139415. * @returns The parsed shadow generator
  139416. */
  139417. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  139418. }
  139419. }
  139420. declare module BABYLON {
  139421. /**
  139422. * Defines the shadow generator component responsible to manage any shadow generators
  139423. * in a given scene.
  139424. */
  139425. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  139426. /**
  139427. * The component name helpfull to identify the component in the list of scene components.
  139428. */
  139429. readonly name: string;
  139430. /**
  139431. * The scene the component belongs to.
  139432. */
  139433. scene: Scene;
  139434. /**
  139435. * Creates a new instance of the component for the given scene
  139436. * @param scene Defines the scene to register the component in
  139437. */
  139438. constructor(scene: Scene);
  139439. /**
  139440. * Registers the component in a given scene
  139441. */
  139442. register(): void;
  139443. /**
  139444. * Rebuilds the elements related to this component in case of
  139445. * context lost for instance.
  139446. */
  139447. rebuild(): void;
  139448. /**
  139449. * Serializes the component data to the specified json object
  139450. * @param serializationObject The object to serialize to
  139451. */
  139452. serialize(serializationObject: any): void;
  139453. /**
  139454. * Adds all the elements from the container to the scene
  139455. * @param container the container holding the elements
  139456. */
  139457. addFromContainer(container: AbstractScene): void;
  139458. /**
  139459. * Removes all the elements in the container from the scene
  139460. * @param container contains the elements to remove
  139461. * @param dispose if the removed element should be disposed (default: false)
  139462. */
  139463. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139464. /**
  139465. * Rebuilds the elements related to this component in case of
  139466. * context lost for instance.
  139467. */
  139468. dispose(): void;
  139469. private _gatherRenderTargets;
  139470. }
  139471. }
  139472. declare module BABYLON {
  139473. /**
  139474. * A point light is a light defined by an unique point in world space.
  139475. * The light is emitted in every direction from this point.
  139476. * A good example of a point light is a standard light bulb.
  139477. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139478. */
  139479. export class PointLight extends ShadowLight {
  139480. private _shadowAngle;
  139481. /**
  139482. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139483. * This specifies what angle the shadow will use to be created.
  139484. *
  139485. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  139486. */
  139487. get shadowAngle(): number;
  139488. /**
  139489. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139490. * This specifies what angle the shadow will use to be created.
  139491. *
  139492. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  139493. */
  139494. set shadowAngle(value: number);
  139495. /**
  139496. * Gets the direction if it has been set.
  139497. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139498. */
  139499. get direction(): Vector3;
  139500. /**
  139501. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139502. */
  139503. set direction(value: Vector3);
  139504. /**
  139505. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  139506. * A PointLight emits the light in every direction.
  139507. * It can cast shadows.
  139508. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  139509. * ```javascript
  139510. * var pointLight = new PointLight("pl", camera.position, scene);
  139511. * ```
  139512. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139513. * @param name The light friendly name
  139514. * @param position The position of the point light in the scene
  139515. * @param scene The scene the lights belongs to
  139516. */
  139517. constructor(name: string, position: Vector3, scene: Scene);
  139518. /**
  139519. * Returns the string "PointLight"
  139520. * @returns the class name
  139521. */
  139522. getClassName(): string;
  139523. /**
  139524. * Returns the integer 0.
  139525. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  139526. */
  139527. getTypeID(): number;
  139528. /**
  139529. * Specifies wether or not the shadowmap should be a cube texture.
  139530. * @returns true if the shadowmap needs to be a cube texture.
  139531. */
  139532. needCube(): boolean;
  139533. /**
  139534. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  139535. * @param faceIndex The index of the face we are computed the direction to generate shadow
  139536. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  139537. */
  139538. getShadowDirection(faceIndex?: number): Vector3;
  139539. /**
  139540. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  139541. * - fov = PI / 2
  139542. * - aspect ratio : 1.0
  139543. * - z-near and far equal to the active camera minZ and maxZ.
  139544. * Returns the PointLight.
  139545. */
  139546. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139547. protected _buildUniformLayout(): void;
  139548. /**
  139549. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  139550. * @param effect The effect to update
  139551. * @param lightIndex The index of the light in the effect to update
  139552. * @returns The point light
  139553. */
  139554. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  139555. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  139556. /**
  139557. * Prepares the list of defines specific to the light type.
  139558. * @param defines the list of defines
  139559. * @param lightIndex defines the index of the light for the effect
  139560. */
  139561. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  139562. }
  139563. }
  139564. declare module BABYLON {
  139565. /**
  139566. * Header information of HDR texture files.
  139567. */
  139568. export interface HDRInfo {
  139569. /**
  139570. * The height of the texture in pixels.
  139571. */
  139572. height: number;
  139573. /**
  139574. * The width of the texture in pixels.
  139575. */
  139576. width: number;
  139577. /**
  139578. * The index of the beginning of the data in the binary file.
  139579. */
  139580. dataPosition: number;
  139581. }
  139582. /**
  139583. * This groups tools to convert HDR texture to native colors array.
  139584. */
  139585. export class HDRTools {
  139586. private static Ldexp;
  139587. private static Rgbe2float;
  139588. private static readStringLine;
  139589. /**
  139590. * Reads header information from an RGBE texture stored in a native array.
  139591. * More information on this format are available here:
  139592. * https://en.wikipedia.org/wiki/RGBE_image_format
  139593. *
  139594. * @param uint8array The binary file stored in native array.
  139595. * @return The header information.
  139596. */
  139597. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  139598. /**
  139599. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  139600. * This RGBE texture needs to store the information as a panorama.
  139601. *
  139602. * More information on this format are available here:
  139603. * https://en.wikipedia.org/wiki/RGBE_image_format
  139604. *
  139605. * @param buffer The binary file stored in an array buffer.
  139606. * @param size The expected size of the extracted cubemap.
  139607. * @return The Cube Map information.
  139608. */
  139609. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  139610. /**
  139611. * Returns the pixels data extracted from an RGBE texture.
  139612. * This pixels will be stored left to right up to down in the R G B order in one array.
  139613. *
  139614. * More information on this format are available here:
  139615. * https://en.wikipedia.org/wiki/RGBE_image_format
  139616. *
  139617. * @param uint8array The binary file stored in an array buffer.
  139618. * @param hdrInfo The header information of the file.
  139619. * @return The pixels data in RGB right to left up to down order.
  139620. */
  139621. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  139622. private static RGBE_ReadPixels_RLE;
  139623. private static RGBE_ReadPixels_NOT_RLE;
  139624. }
  139625. }
  139626. declare module BABYLON {
  139627. /**
  139628. * Effect Render Options
  139629. */
  139630. export interface IEffectRendererOptions {
  139631. /**
  139632. * Defines the vertices positions.
  139633. */
  139634. positions?: number[];
  139635. /**
  139636. * Defines the indices.
  139637. */
  139638. indices?: number[];
  139639. }
  139640. /**
  139641. * Helper class to render one or more effects.
  139642. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  139643. */
  139644. export class EffectRenderer {
  139645. private engine;
  139646. private static _DefaultOptions;
  139647. private _vertexBuffers;
  139648. private _indexBuffer;
  139649. private _fullscreenViewport;
  139650. /**
  139651. * Creates an effect renderer
  139652. * @param engine the engine to use for rendering
  139653. * @param options defines the options of the effect renderer
  139654. */
  139655. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  139656. /**
  139657. * Sets the current viewport in normalized coordinates 0-1
  139658. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  139659. */
  139660. setViewport(viewport?: Viewport): void;
  139661. /**
  139662. * Binds the embedded attributes buffer to the effect.
  139663. * @param effect Defines the effect to bind the attributes for
  139664. */
  139665. bindBuffers(effect: Effect): void;
  139666. /**
  139667. * Sets the current effect wrapper to use during draw.
  139668. * The effect needs to be ready before calling this api.
  139669. * This also sets the default full screen position attribute.
  139670. * @param effectWrapper Defines the effect to draw with
  139671. */
  139672. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  139673. /**
  139674. * Restores engine states
  139675. */
  139676. restoreStates(): void;
  139677. /**
  139678. * Draws a full screen quad.
  139679. */
  139680. draw(): void;
  139681. private isRenderTargetTexture;
  139682. /**
  139683. * renders one or more effects to a specified texture
  139684. * @param effectWrapper the effect to renderer
  139685. * @param outputTexture texture to draw to, if null it will render to the screen.
  139686. */
  139687. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  139688. /**
  139689. * Disposes of the effect renderer
  139690. */
  139691. dispose(): void;
  139692. }
  139693. /**
  139694. * Options to create an EffectWrapper
  139695. */
  139696. interface EffectWrapperCreationOptions {
  139697. /**
  139698. * Engine to use to create the effect
  139699. */
  139700. engine: ThinEngine;
  139701. /**
  139702. * Fragment shader for the effect
  139703. */
  139704. fragmentShader: string;
  139705. /**
  139706. * Use the shader store instead of direct source code
  139707. */
  139708. useShaderStore?: boolean;
  139709. /**
  139710. * Vertex shader for the effect
  139711. */
  139712. vertexShader?: string;
  139713. /**
  139714. * Attributes to use in the shader
  139715. */
  139716. attributeNames?: Array<string>;
  139717. /**
  139718. * Uniforms to use in the shader
  139719. */
  139720. uniformNames?: Array<string>;
  139721. /**
  139722. * Texture sampler names to use in the shader
  139723. */
  139724. samplerNames?: Array<string>;
  139725. /**
  139726. * Defines to use in the shader
  139727. */
  139728. defines?: Array<string>;
  139729. /**
  139730. * Callback when effect is compiled
  139731. */
  139732. onCompiled?: Nullable<(effect: Effect) => void>;
  139733. /**
  139734. * The friendly name of the effect displayed in Spector.
  139735. */
  139736. name?: string;
  139737. }
  139738. /**
  139739. * Wraps an effect to be used for rendering
  139740. */
  139741. export class EffectWrapper {
  139742. /**
  139743. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  139744. */
  139745. onApplyObservable: Observable<{}>;
  139746. /**
  139747. * The underlying effect
  139748. */
  139749. effect: Effect;
  139750. /**
  139751. * Creates an effect to be renderer
  139752. * @param creationOptions options to create the effect
  139753. */
  139754. constructor(creationOptions: EffectWrapperCreationOptions);
  139755. /**
  139756. * Disposes of the effect wrapper
  139757. */
  139758. dispose(): void;
  139759. }
  139760. }
  139761. declare module BABYLON {
  139762. /** @hidden */
  139763. export var hdrFilteringVertexShader: {
  139764. name: string;
  139765. shader: string;
  139766. };
  139767. }
  139768. declare module BABYLON {
  139769. /** @hidden */
  139770. export var hdrFilteringPixelShader: {
  139771. name: string;
  139772. shader: string;
  139773. };
  139774. }
  139775. declare module BABYLON {
  139776. /**
  139777. * Options for texture filtering
  139778. */
  139779. interface IHDRFilteringOptions {
  139780. /**
  139781. * Scales pixel intensity for the input HDR map.
  139782. */
  139783. hdrScale?: number;
  139784. /**
  139785. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  139786. */
  139787. quality?: number;
  139788. }
  139789. /**
  139790. * Filters HDR maps to get correct renderings of PBR reflections
  139791. */
  139792. export class HDRFiltering {
  139793. private _engine;
  139794. private _effectRenderer;
  139795. private _effectWrapper;
  139796. private _lodGenerationOffset;
  139797. private _lodGenerationScale;
  139798. /**
  139799. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  139800. * you care about baking speed.
  139801. */
  139802. quality: number;
  139803. /**
  139804. * Scales pixel intensity for the input HDR map.
  139805. */
  139806. hdrScale: number;
  139807. /**
  139808. * Instantiates HDR filter for reflection maps
  139809. *
  139810. * @param engine Thin engine
  139811. * @param options Options
  139812. */
  139813. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  139814. private _createRenderTarget;
  139815. private _prefilterInternal;
  139816. private _createEffect;
  139817. /**
  139818. * Get a value indicating if the filter is ready to be used
  139819. * @param texture Texture to filter
  139820. * @returns true if the filter is ready
  139821. */
  139822. isReady(texture: BaseTexture): boolean;
  139823. /**
  139824. * Prefilters a cube texture to have mipmap levels representing roughness values.
  139825. * Prefiltering will be invoked at the end of next rendering pass.
  139826. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  139827. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  139828. * @param texture Texture to filter
  139829. * @param onFinished Callback when filtering is done
  139830. * @return Promise called when prefiltering is done
  139831. */
  139832. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  139833. }
  139834. }
  139835. declare module BABYLON {
  139836. /**
  139837. * This represents a texture coming from an HDR input.
  139838. *
  139839. * The only supported format is currently panorama picture stored in RGBE format.
  139840. * Example of such files can be found on HDRLib: http://hdrlib.com/
  139841. */
  139842. export class HDRCubeTexture extends BaseTexture {
  139843. private static _facesMapping;
  139844. private _generateHarmonics;
  139845. private _noMipmap;
  139846. private _prefilterOnLoad;
  139847. private _textureMatrix;
  139848. private _size;
  139849. private _onLoad;
  139850. private _onError;
  139851. /**
  139852. * The texture URL.
  139853. */
  139854. url: string;
  139855. /**
  139856. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  139857. */
  139858. coordinatesMode: number;
  139859. protected _isBlocking: boolean;
  139860. /**
  139861. * Sets wether or not the texture is blocking during loading.
  139862. */
  139863. set isBlocking(value: boolean);
  139864. /**
  139865. * Gets wether or not the texture is blocking during loading.
  139866. */
  139867. get isBlocking(): boolean;
  139868. protected _rotationY: number;
  139869. /**
  139870. * Sets texture matrix rotation angle around Y axis in radians.
  139871. */
  139872. set rotationY(value: number);
  139873. /**
  139874. * Gets texture matrix rotation angle around Y axis radians.
  139875. */
  139876. get rotationY(): number;
  139877. /**
  139878. * Gets or sets the center of the bounding box associated with the cube texture
  139879. * It must define where the camera used to render the texture was set
  139880. */
  139881. boundingBoxPosition: Vector3;
  139882. private _boundingBoxSize;
  139883. /**
  139884. * Gets or sets the size of the bounding box associated with the cube texture
  139885. * When defined, the cubemap will switch to local mode
  139886. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  139887. * @example https://www.babylonjs-playground.com/#RNASML
  139888. */
  139889. set boundingBoxSize(value: Vector3);
  139890. get boundingBoxSize(): Vector3;
  139891. /**
  139892. * Instantiates an HDRTexture from the following parameters.
  139893. *
  139894. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  139895. * @param sceneOrEngine The scene or engine the texture will be used in
  139896. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  139897. * @param noMipmap Forces to not generate the mipmap if true
  139898. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  139899. * @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)
  139900. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  139901. */
  139902. 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>);
  139903. /**
  139904. * Get the current class name of the texture useful for serialization or dynamic coding.
  139905. * @returns "HDRCubeTexture"
  139906. */
  139907. getClassName(): string;
  139908. /**
  139909. * Occurs when the file is raw .hdr file.
  139910. */
  139911. private loadTexture;
  139912. clone(): HDRCubeTexture;
  139913. delayLoad(): void;
  139914. /**
  139915. * Get the texture reflection matrix used to rotate/transform the reflection.
  139916. * @returns the reflection matrix
  139917. */
  139918. getReflectionTextureMatrix(): Matrix;
  139919. /**
  139920. * Set the texture reflection matrix used to rotate/transform the reflection.
  139921. * @param value Define the reflection matrix to set
  139922. */
  139923. setReflectionTextureMatrix(value: Matrix): void;
  139924. /**
  139925. * Parses a JSON representation of an HDR Texture in order to create the texture
  139926. * @param parsedTexture Define the JSON representation
  139927. * @param scene Define the scene the texture should be created in
  139928. * @param rootUrl Define the root url in case we need to load relative dependencies
  139929. * @returns the newly created texture after parsing
  139930. */
  139931. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  139932. serialize(): any;
  139933. }
  139934. }
  139935. declare module BABYLON {
  139936. /**
  139937. * Class used to control physics engine
  139938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  139939. */
  139940. export class PhysicsEngine implements IPhysicsEngine {
  139941. private _physicsPlugin;
  139942. /**
  139943. * Global value used to control the smallest number supported by the simulation
  139944. */
  139945. static Epsilon: number;
  139946. private _impostors;
  139947. private _joints;
  139948. private _subTimeStep;
  139949. /**
  139950. * Gets the gravity vector used by the simulation
  139951. */
  139952. gravity: Vector3;
  139953. /**
  139954. * Factory used to create the default physics plugin.
  139955. * @returns The default physics plugin
  139956. */
  139957. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  139958. /**
  139959. * Creates a new Physics Engine
  139960. * @param gravity defines the gravity vector used by the simulation
  139961. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  139962. */
  139963. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  139964. /**
  139965. * Sets the gravity vector used by the simulation
  139966. * @param gravity defines the gravity vector to use
  139967. */
  139968. setGravity(gravity: Vector3): void;
  139969. /**
  139970. * Set the time step of the physics engine.
  139971. * Default is 1/60.
  139972. * To slow it down, enter 1/600 for example.
  139973. * To speed it up, 1/30
  139974. * @param newTimeStep defines the new timestep to apply to this world.
  139975. */
  139976. setTimeStep(newTimeStep?: number): void;
  139977. /**
  139978. * Get the time step of the physics engine.
  139979. * @returns the current time step
  139980. */
  139981. getTimeStep(): number;
  139982. /**
  139983. * Set the sub time step of the physics engine.
  139984. * Default is 0 meaning there is no sub steps
  139985. * To increase physics resolution precision, set a small value (like 1 ms)
  139986. * @param subTimeStep defines the new sub timestep used for physics resolution.
  139987. */
  139988. setSubTimeStep(subTimeStep?: number): void;
  139989. /**
  139990. * Get the sub time step of the physics engine.
  139991. * @returns the current sub time step
  139992. */
  139993. getSubTimeStep(): number;
  139994. /**
  139995. * Release all resources
  139996. */
  139997. dispose(): void;
  139998. /**
  139999. * Gets the name of the current physics plugin
  140000. * @returns the name of the plugin
  140001. */
  140002. getPhysicsPluginName(): string;
  140003. /**
  140004. * Adding a new impostor for the impostor tracking.
  140005. * This will be done by the impostor itself.
  140006. * @param impostor the impostor to add
  140007. */
  140008. addImpostor(impostor: PhysicsImpostor): void;
  140009. /**
  140010. * Remove an impostor from the engine.
  140011. * This impostor and its mesh will not longer be updated by the physics engine.
  140012. * @param impostor the impostor to remove
  140013. */
  140014. removeImpostor(impostor: PhysicsImpostor): void;
  140015. /**
  140016. * Add a joint to the physics engine
  140017. * @param mainImpostor defines the main impostor to which the joint is added.
  140018. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  140019. * @param joint defines the joint that will connect both impostors.
  140020. */
  140021. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  140022. /**
  140023. * Removes a joint from the simulation
  140024. * @param mainImpostor defines the impostor used with the joint
  140025. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  140026. * @param joint defines the joint to remove
  140027. */
  140028. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  140029. /**
  140030. * Called by the scene. No need to call it.
  140031. * @param delta defines the timespam between frames
  140032. */
  140033. _step(delta: number): void;
  140034. /**
  140035. * Gets the current plugin used to run the simulation
  140036. * @returns current plugin
  140037. */
  140038. getPhysicsPlugin(): IPhysicsEnginePlugin;
  140039. /**
  140040. * Gets the list of physic impostors
  140041. * @returns an array of PhysicsImpostor
  140042. */
  140043. getImpostors(): Array<PhysicsImpostor>;
  140044. /**
  140045. * Gets the impostor for a physics enabled object
  140046. * @param object defines the object impersonated by the impostor
  140047. * @returns the PhysicsImpostor or null if not found
  140048. */
  140049. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  140050. /**
  140051. * Gets the impostor for a physics body object
  140052. * @param body defines physics body used by the impostor
  140053. * @returns the PhysicsImpostor or null if not found
  140054. */
  140055. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  140056. /**
  140057. * Does a raycast in the physics world
  140058. * @param from when should the ray start?
  140059. * @param to when should the ray end?
  140060. * @returns PhysicsRaycastResult
  140061. */
  140062. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140063. }
  140064. }
  140065. declare module BABYLON {
  140066. /** @hidden */
  140067. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  140068. private _useDeltaForWorldStep;
  140069. world: any;
  140070. name: string;
  140071. private _physicsMaterials;
  140072. private _fixedTimeStep;
  140073. private _cannonRaycastResult;
  140074. private _raycastResult;
  140075. private _physicsBodysToRemoveAfterStep;
  140076. private _firstFrame;
  140077. BJSCANNON: any;
  140078. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  140079. setGravity(gravity: Vector3): void;
  140080. setTimeStep(timeStep: number): void;
  140081. getTimeStep(): number;
  140082. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140083. private _removeMarkedPhysicsBodiesFromWorld;
  140084. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140085. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140086. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140087. private _processChildMeshes;
  140088. removePhysicsBody(impostor: PhysicsImpostor): void;
  140089. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140090. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140091. private _addMaterial;
  140092. private _checkWithEpsilon;
  140093. private _createShape;
  140094. private _createHeightmap;
  140095. private _minus90X;
  140096. private _plus90X;
  140097. private _tmpPosition;
  140098. private _tmpDeltaPosition;
  140099. private _tmpUnityRotation;
  140100. private _updatePhysicsBodyTransformation;
  140101. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140102. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140103. isSupported(): boolean;
  140104. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140105. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140106. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140107. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140108. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140109. getBodyMass(impostor: PhysicsImpostor): number;
  140110. getBodyFriction(impostor: PhysicsImpostor): number;
  140111. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140112. getBodyRestitution(impostor: PhysicsImpostor): number;
  140113. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140114. sleepBody(impostor: PhysicsImpostor): void;
  140115. wakeUpBody(impostor: PhysicsImpostor): void;
  140116. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  140117. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  140118. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  140119. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140120. getRadius(impostor: PhysicsImpostor): number;
  140121. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140122. dispose(): void;
  140123. private _extendNamespace;
  140124. /**
  140125. * Does a raycast in the physics world
  140126. * @param from when should the ray start?
  140127. * @param to when should the ray end?
  140128. * @returns PhysicsRaycastResult
  140129. */
  140130. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140131. }
  140132. }
  140133. declare module BABYLON {
  140134. /** @hidden */
  140135. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  140136. private _useDeltaForWorldStep;
  140137. world: any;
  140138. name: string;
  140139. BJSOIMO: any;
  140140. private _raycastResult;
  140141. private _fixedTimeStep;
  140142. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  140143. setGravity(gravity: Vector3): void;
  140144. setTimeStep(timeStep: number): void;
  140145. getTimeStep(): number;
  140146. private _tmpImpostorsArray;
  140147. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140148. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140149. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140150. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140151. private _tmpPositionVector;
  140152. removePhysicsBody(impostor: PhysicsImpostor): void;
  140153. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140154. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140155. isSupported(): boolean;
  140156. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140157. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140158. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140159. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140160. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140161. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140162. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140163. getBodyMass(impostor: PhysicsImpostor): number;
  140164. getBodyFriction(impostor: PhysicsImpostor): number;
  140165. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140166. getBodyRestitution(impostor: PhysicsImpostor): number;
  140167. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140168. sleepBody(impostor: PhysicsImpostor): void;
  140169. wakeUpBody(impostor: PhysicsImpostor): void;
  140170. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  140171. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  140172. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  140173. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140174. getRadius(impostor: PhysicsImpostor): number;
  140175. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140176. dispose(): void;
  140177. /**
  140178. * Does a raycast in the physics world
  140179. * @param from when should the ray start?
  140180. * @param to when should the ray end?
  140181. * @returns PhysicsRaycastResult
  140182. */
  140183. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140184. }
  140185. }
  140186. declare module BABYLON {
  140187. /**
  140188. * AmmoJS Physics plugin
  140189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140190. * @see https://github.com/kripken/ammo.js/
  140191. */
  140192. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  140193. private _useDeltaForWorldStep;
  140194. /**
  140195. * Reference to the Ammo library
  140196. */
  140197. bjsAMMO: any;
  140198. /**
  140199. * Created ammoJS world which physics bodies are added to
  140200. */
  140201. world: any;
  140202. /**
  140203. * Name of the plugin
  140204. */
  140205. name: string;
  140206. private _timeStep;
  140207. private _fixedTimeStep;
  140208. private _maxSteps;
  140209. private _tmpQuaternion;
  140210. private _tmpAmmoTransform;
  140211. private _tmpAmmoQuaternion;
  140212. private _tmpAmmoConcreteContactResultCallback;
  140213. private _collisionConfiguration;
  140214. private _dispatcher;
  140215. private _overlappingPairCache;
  140216. private _solver;
  140217. private _softBodySolver;
  140218. private _tmpAmmoVectorA;
  140219. private _tmpAmmoVectorB;
  140220. private _tmpAmmoVectorC;
  140221. private _tmpAmmoVectorD;
  140222. private _tmpContactCallbackResult;
  140223. private _tmpAmmoVectorRCA;
  140224. private _tmpAmmoVectorRCB;
  140225. private _raycastResult;
  140226. private static readonly DISABLE_COLLISION_FLAG;
  140227. private static readonly KINEMATIC_FLAG;
  140228. private static readonly DISABLE_DEACTIVATION_FLAG;
  140229. /**
  140230. * Initializes the ammoJS plugin
  140231. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  140232. * @param ammoInjection can be used to inject your own ammo reference
  140233. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  140234. */
  140235. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  140236. /**
  140237. * Sets the gravity of the physics world (m/(s^2))
  140238. * @param gravity Gravity to set
  140239. */
  140240. setGravity(gravity: Vector3): void;
  140241. /**
  140242. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  140243. * @param timeStep timestep to use in seconds
  140244. */
  140245. setTimeStep(timeStep: number): void;
  140246. /**
  140247. * 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)
  140248. * @param fixedTimeStep fixedTimeStep to use in seconds
  140249. */
  140250. setFixedTimeStep(fixedTimeStep: number): void;
  140251. /**
  140252. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  140253. * @param maxSteps the maximum number of steps by the physics engine per frame
  140254. */
  140255. setMaxSteps(maxSteps: number): void;
  140256. /**
  140257. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  140258. * @returns the current timestep in seconds
  140259. */
  140260. getTimeStep(): number;
  140261. /**
  140262. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  140263. */
  140264. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  140265. private _isImpostorInContact;
  140266. private _isImpostorPairInContact;
  140267. private _stepSimulation;
  140268. /**
  140269. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  140270. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  140271. * After the step the babylon meshes are set to the position of the physics imposters
  140272. * @param delta amount of time to step forward
  140273. * @param impostors array of imposters to update before/after the step
  140274. */
  140275. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140276. /**
  140277. * Update babylon mesh to match physics world object
  140278. * @param impostor imposter to match
  140279. */
  140280. private _afterSoftStep;
  140281. /**
  140282. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  140283. * @param impostor imposter to match
  140284. */
  140285. private _ropeStep;
  140286. /**
  140287. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  140288. * @param impostor imposter to match
  140289. */
  140290. private _softbodyOrClothStep;
  140291. private _tmpMatrix;
  140292. /**
  140293. * Applies an impulse on the imposter
  140294. * @param impostor imposter to apply impulse to
  140295. * @param force amount of force to be applied to the imposter
  140296. * @param contactPoint the location to apply the impulse on the imposter
  140297. */
  140298. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140299. /**
  140300. * Applies a force on the imposter
  140301. * @param impostor imposter to apply force
  140302. * @param force amount of force to be applied to the imposter
  140303. * @param contactPoint the location to apply the force on the imposter
  140304. */
  140305. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140306. /**
  140307. * Creates a physics body using the plugin
  140308. * @param impostor the imposter to create the physics body on
  140309. */
  140310. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140311. /**
  140312. * Removes the physics body from the imposter and disposes of the body's memory
  140313. * @param impostor imposter to remove the physics body from
  140314. */
  140315. removePhysicsBody(impostor: PhysicsImpostor): void;
  140316. /**
  140317. * Generates a joint
  140318. * @param impostorJoint the imposter joint to create the joint with
  140319. */
  140320. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140321. /**
  140322. * Removes a joint
  140323. * @param impostorJoint the imposter joint to remove the joint from
  140324. */
  140325. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140326. private _addMeshVerts;
  140327. /**
  140328. * Initialise the soft body vertices to match its object's (mesh) vertices
  140329. * Softbody vertices (nodes) are in world space and to match this
  140330. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  140331. * @param impostor to create the softbody for
  140332. */
  140333. private _softVertexData;
  140334. /**
  140335. * Create an impostor's soft body
  140336. * @param impostor to create the softbody for
  140337. */
  140338. private _createSoftbody;
  140339. /**
  140340. * Create cloth for an impostor
  140341. * @param impostor to create the softbody for
  140342. */
  140343. private _createCloth;
  140344. /**
  140345. * Create rope for an impostor
  140346. * @param impostor to create the softbody for
  140347. */
  140348. private _createRope;
  140349. /**
  140350. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  140351. * @param impostor to create the custom physics shape for
  140352. */
  140353. private _createCustom;
  140354. private _addHullVerts;
  140355. private _createShape;
  140356. /**
  140357. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  140358. * @param impostor imposter containing the physics body and babylon object
  140359. */
  140360. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140361. /**
  140362. * Sets the babylon object's position/rotation from the physics body's position/rotation
  140363. * @param impostor imposter containing the physics body and babylon object
  140364. * @param newPosition new position
  140365. * @param newRotation new rotation
  140366. */
  140367. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140368. /**
  140369. * If this plugin is supported
  140370. * @returns true if its supported
  140371. */
  140372. isSupported(): boolean;
  140373. /**
  140374. * Sets the linear velocity of the physics body
  140375. * @param impostor imposter to set the velocity on
  140376. * @param velocity velocity to set
  140377. */
  140378. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140379. /**
  140380. * Sets the angular velocity of the physics body
  140381. * @param impostor imposter to set the velocity on
  140382. * @param velocity velocity to set
  140383. */
  140384. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140385. /**
  140386. * gets the linear velocity
  140387. * @param impostor imposter to get linear velocity from
  140388. * @returns linear velocity
  140389. */
  140390. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140391. /**
  140392. * gets the angular velocity
  140393. * @param impostor imposter to get angular velocity from
  140394. * @returns angular velocity
  140395. */
  140396. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140397. /**
  140398. * Sets the mass of physics body
  140399. * @param impostor imposter to set the mass on
  140400. * @param mass mass to set
  140401. */
  140402. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140403. /**
  140404. * Gets the mass of the physics body
  140405. * @param impostor imposter to get the mass from
  140406. * @returns mass
  140407. */
  140408. getBodyMass(impostor: PhysicsImpostor): number;
  140409. /**
  140410. * Gets friction of the impostor
  140411. * @param impostor impostor to get friction from
  140412. * @returns friction value
  140413. */
  140414. getBodyFriction(impostor: PhysicsImpostor): number;
  140415. /**
  140416. * Sets friction of the impostor
  140417. * @param impostor impostor to set friction on
  140418. * @param friction friction value
  140419. */
  140420. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140421. /**
  140422. * Gets restitution of the impostor
  140423. * @param impostor impostor to get restitution from
  140424. * @returns restitution value
  140425. */
  140426. getBodyRestitution(impostor: PhysicsImpostor): number;
  140427. /**
  140428. * Sets resitution of the impostor
  140429. * @param impostor impostor to set resitution on
  140430. * @param restitution resitution value
  140431. */
  140432. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140433. /**
  140434. * Gets pressure inside the impostor
  140435. * @param impostor impostor to get pressure from
  140436. * @returns pressure value
  140437. */
  140438. getBodyPressure(impostor: PhysicsImpostor): number;
  140439. /**
  140440. * Sets pressure inside a soft body impostor
  140441. * Cloth and rope must remain 0 pressure
  140442. * @param impostor impostor to set pressure on
  140443. * @param pressure pressure value
  140444. */
  140445. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  140446. /**
  140447. * Gets stiffness of the impostor
  140448. * @param impostor impostor to get stiffness from
  140449. * @returns pressure value
  140450. */
  140451. getBodyStiffness(impostor: PhysicsImpostor): number;
  140452. /**
  140453. * Sets stiffness of the impostor
  140454. * @param impostor impostor to set stiffness on
  140455. * @param stiffness stiffness value from 0 to 1
  140456. */
  140457. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  140458. /**
  140459. * Gets velocityIterations of the impostor
  140460. * @param impostor impostor to get velocity iterations from
  140461. * @returns velocityIterations value
  140462. */
  140463. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  140464. /**
  140465. * Sets velocityIterations of the impostor
  140466. * @param impostor impostor to set velocity iterations on
  140467. * @param velocityIterations velocityIterations value
  140468. */
  140469. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  140470. /**
  140471. * Gets positionIterations of the impostor
  140472. * @param impostor impostor to get position iterations from
  140473. * @returns positionIterations value
  140474. */
  140475. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  140476. /**
  140477. * Sets positionIterations of the impostor
  140478. * @param impostor impostor to set position on
  140479. * @param positionIterations positionIterations value
  140480. */
  140481. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  140482. /**
  140483. * Append an anchor to a cloth object
  140484. * @param impostor is the cloth impostor to add anchor to
  140485. * @param otherImpostor is the rigid impostor to anchor to
  140486. * @param width ratio across width from 0 to 1
  140487. * @param height ratio up height from 0 to 1
  140488. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  140489. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  140490. */
  140491. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  140492. /**
  140493. * Append an hook to a rope object
  140494. * @param impostor is the rope impostor to add hook to
  140495. * @param otherImpostor is the rigid impostor to hook to
  140496. * @param length ratio along the rope from 0 to 1
  140497. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  140498. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  140499. */
  140500. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  140501. /**
  140502. * Sleeps the physics body and stops it from being active
  140503. * @param impostor impostor to sleep
  140504. */
  140505. sleepBody(impostor: PhysicsImpostor): void;
  140506. /**
  140507. * Activates the physics body
  140508. * @param impostor impostor to activate
  140509. */
  140510. wakeUpBody(impostor: PhysicsImpostor): void;
  140511. /**
  140512. * Updates the distance parameters of the joint
  140513. * @param joint joint to update
  140514. * @param maxDistance maximum distance of the joint
  140515. * @param minDistance minimum distance of the joint
  140516. */
  140517. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  140518. /**
  140519. * Sets a motor on the joint
  140520. * @param joint joint to set motor on
  140521. * @param speed speed of the motor
  140522. * @param maxForce maximum force of the motor
  140523. * @param motorIndex index of the motor
  140524. */
  140525. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  140526. /**
  140527. * Sets the motors limit
  140528. * @param joint joint to set limit on
  140529. * @param upperLimit upper limit
  140530. * @param lowerLimit lower limit
  140531. */
  140532. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  140533. /**
  140534. * Syncs the position and rotation of a mesh with the impostor
  140535. * @param mesh mesh to sync
  140536. * @param impostor impostor to update the mesh with
  140537. */
  140538. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140539. /**
  140540. * Gets the radius of the impostor
  140541. * @param impostor impostor to get radius from
  140542. * @returns the radius
  140543. */
  140544. getRadius(impostor: PhysicsImpostor): number;
  140545. /**
  140546. * Gets the box size of the impostor
  140547. * @param impostor impostor to get box size from
  140548. * @param result the resulting box size
  140549. */
  140550. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140551. /**
  140552. * Disposes of the impostor
  140553. */
  140554. dispose(): void;
  140555. /**
  140556. * Does a raycast in the physics world
  140557. * @param from when should the ray start?
  140558. * @param to when should the ray end?
  140559. * @returns PhysicsRaycastResult
  140560. */
  140561. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140562. }
  140563. }
  140564. declare module BABYLON {
  140565. interface AbstractScene {
  140566. /**
  140567. * The list of reflection probes added to the scene
  140568. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  140569. */
  140570. reflectionProbes: Array<ReflectionProbe>;
  140571. /**
  140572. * Removes the given reflection probe from this scene.
  140573. * @param toRemove The reflection probe to remove
  140574. * @returns The index of the removed reflection probe
  140575. */
  140576. removeReflectionProbe(toRemove: ReflectionProbe): number;
  140577. /**
  140578. * Adds the given reflection probe to this scene.
  140579. * @param newReflectionProbe The reflection probe to add
  140580. */
  140581. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  140582. }
  140583. /**
  140584. * Class used to generate realtime reflection / refraction cube textures
  140585. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  140586. */
  140587. export class ReflectionProbe {
  140588. /** defines the name of the probe */
  140589. name: string;
  140590. private _scene;
  140591. private _renderTargetTexture;
  140592. private _projectionMatrix;
  140593. private _viewMatrix;
  140594. private _target;
  140595. private _add;
  140596. private _attachedMesh;
  140597. private _invertYAxis;
  140598. /** Gets or sets probe position (center of the cube map) */
  140599. position: Vector3;
  140600. /**
  140601. * Creates a new reflection probe
  140602. * @param name defines the name of the probe
  140603. * @param size defines the texture resolution (for each face)
  140604. * @param scene defines the hosting scene
  140605. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  140606. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  140607. */
  140608. constructor(
  140609. /** defines the name of the probe */
  140610. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  140611. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  140612. get samples(): number;
  140613. set samples(value: number);
  140614. /** Gets or sets the refresh rate to use (on every frame by default) */
  140615. get refreshRate(): number;
  140616. set refreshRate(value: number);
  140617. /**
  140618. * Gets the hosting scene
  140619. * @returns a Scene
  140620. */
  140621. getScene(): Scene;
  140622. /** Gets the internal CubeTexture used to render to */
  140623. get cubeTexture(): RenderTargetTexture;
  140624. /** Gets the list of meshes to render */
  140625. get renderList(): Nullable<AbstractMesh[]>;
  140626. /**
  140627. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  140628. * @param mesh defines the mesh to attach to
  140629. */
  140630. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  140631. /**
  140632. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  140633. * @param renderingGroupId The rendering group id corresponding to its index
  140634. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  140635. */
  140636. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  140637. /**
  140638. * Clean all associated resources
  140639. */
  140640. dispose(): void;
  140641. /**
  140642. * Converts the reflection probe information to a readable string for debug purpose.
  140643. * @param fullDetails Supports for multiple levels of logging within scene loading
  140644. * @returns the human readable reflection probe info
  140645. */
  140646. toString(fullDetails?: boolean): string;
  140647. /**
  140648. * Get the class name of the relfection probe.
  140649. * @returns "ReflectionProbe"
  140650. */
  140651. getClassName(): string;
  140652. /**
  140653. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  140654. * @returns The JSON representation of the texture
  140655. */
  140656. serialize(): any;
  140657. /**
  140658. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  140659. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  140660. * @param scene Define the scene the parsed reflection probe should be instantiated in
  140661. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  140662. * @returns The parsed reflection probe if successful
  140663. */
  140664. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  140665. }
  140666. }
  140667. declare module BABYLON {
  140668. /** @hidden */
  140669. export var _BabylonLoaderRegistered: boolean;
  140670. /**
  140671. * Helps setting up some configuration for the babylon file loader.
  140672. */
  140673. export class BabylonFileLoaderConfiguration {
  140674. /**
  140675. * The loader does not allow injecting custom physix engine into the plugins.
  140676. * Unfortunately in ES6, we need to manually inject them into the plugin.
  140677. * So you could set this variable to your engine import to make it work.
  140678. */
  140679. static LoaderInjectedPhysicsEngine: any;
  140680. }
  140681. }
  140682. declare module BABYLON {
  140683. /**
  140684. * The Physically based simple base material of BJS.
  140685. *
  140686. * This enables better naming and convention enforcements on top of the pbrMaterial.
  140687. * It is used as the base class for both the specGloss and metalRough conventions.
  140688. */
  140689. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  140690. /**
  140691. * Number of Simultaneous lights allowed on the material.
  140692. */
  140693. maxSimultaneousLights: number;
  140694. /**
  140695. * If sets to true, disables all the lights affecting the material.
  140696. */
  140697. disableLighting: boolean;
  140698. /**
  140699. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  140700. */
  140701. environmentTexture: BaseTexture;
  140702. /**
  140703. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  140704. */
  140705. invertNormalMapX: boolean;
  140706. /**
  140707. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  140708. */
  140709. invertNormalMapY: boolean;
  140710. /**
  140711. * Normal map used in the model.
  140712. */
  140713. normalTexture: BaseTexture;
  140714. /**
  140715. * Emissivie color used to self-illuminate the model.
  140716. */
  140717. emissiveColor: Color3;
  140718. /**
  140719. * Emissivie texture used to self-illuminate the model.
  140720. */
  140721. emissiveTexture: BaseTexture;
  140722. /**
  140723. * Occlusion Channel Strenght.
  140724. */
  140725. occlusionStrength: number;
  140726. /**
  140727. * Occlusion Texture of the material (adding extra occlusion effects).
  140728. */
  140729. occlusionTexture: BaseTexture;
  140730. /**
  140731. * Defines the alpha limits in alpha test mode.
  140732. */
  140733. alphaCutOff: number;
  140734. /**
  140735. * Gets the current double sided mode.
  140736. */
  140737. get doubleSided(): boolean;
  140738. /**
  140739. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  140740. */
  140741. set doubleSided(value: boolean);
  140742. /**
  140743. * Stores the pre-calculated light information of a mesh in a texture.
  140744. */
  140745. lightmapTexture: BaseTexture;
  140746. /**
  140747. * If true, the light map contains occlusion information instead of lighting info.
  140748. */
  140749. useLightmapAsShadowmap: boolean;
  140750. /**
  140751. * Instantiates a new PBRMaterial instance.
  140752. *
  140753. * @param name The material name
  140754. * @param scene The scene the material will be use in.
  140755. */
  140756. constructor(name: string, scene: Scene);
  140757. getClassName(): string;
  140758. }
  140759. }
  140760. declare module BABYLON {
  140761. /**
  140762. * The PBR material of BJS following the metal roughness convention.
  140763. *
  140764. * This fits to the PBR convention in the GLTF definition:
  140765. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  140766. */
  140767. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  140768. /**
  140769. * The base color has two different interpretations depending on the value of metalness.
  140770. * When the material is a metal, the base color is the specific measured reflectance value
  140771. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  140772. * of the material.
  140773. */
  140774. baseColor: Color3;
  140775. /**
  140776. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  140777. * well as opacity information in the alpha channel.
  140778. */
  140779. baseTexture: BaseTexture;
  140780. /**
  140781. * Specifies the metallic scalar value of the material.
  140782. * Can also be used to scale the metalness values of the metallic texture.
  140783. */
  140784. metallic: number;
  140785. /**
  140786. * Specifies the roughness scalar value of the material.
  140787. * Can also be used to scale the roughness values of the metallic texture.
  140788. */
  140789. roughness: number;
  140790. /**
  140791. * Texture containing both the metallic value in the B channel and the
  140792. * roughness value in the G channel to keep better precision.
  140793. */
  140794. metallicRoughnessTexture: BaseTexture;
  140795. /**
  140796. * Instantiates a new PBRMetalRoughnessMaterial instance.
  140797. *
  140798. * @param name The material name
  140799. * @param scene The scene the material will be use in.
  140800. */
  140801. constructor(name: string, scene: Scene);
  140802. /**
  140803. * Return the currrent class name of the material.
  140804. */
  140805. getClassName(): string;
  140806. /**
  140807. * Makes a duplicate of the current material.
  140808. * @param name - name to use for the new material.
  140809. */
  140810. clone(name: string): PBRMetallicRoughnessMaterial;
  140811. /**
  140812. * Serialize the material to a parsable JSON object.
  140813. */
  140814. serialize(): any;
  140815. /**
  140816. * Parses a JSON object correponding to the serialize function.
  140817. */
  140818. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  140819. }
  140820. }
  140821. declare module BABYLON {
  140822. /**
  140823. * The PBR material of BJS following the specular glossiness convention.
  140824. *
  140825. * This fits to the PBR convention in the GLTF definition:
  140826. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  140827. */
  140828. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  140829. /**
  140830. * Specifies the diffuse color of the material.
  140831. */
  140832. diffuseColor: Color3;
  140833. /**
  140834. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  140835. * channel.
  140836. */
  140837. diffuseTexture: BaseTexture;
  140838. /**
  140839. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  140840. */
  140841. specularColor: Color3;
  140842. /**
  140843. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  140844. */
  140845. glossiness: number;
  140846. /**
  140847. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  140848. */
  140849. specularGlossinessTexture: BaseTexture;
  140850. /**
  140851. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  140852. *
  140853. * @param name The material name
  140854. * @param scene The scene the material will be use in.
  140855. */
  140856. constructor(name: string, scene: Scene);
  140857. /**
  140858. * Return the currrent class name of the material.
  140859. */
  140860. getClassName(): string;
  140861. /**
  140862. * Makes a duplicate of the current material.
  140863. * @param name - name to use for the new material.
  140864. */
  140865. clone(name: string): PBRSpecularGlossinessMaterial;
  140866. /**
  140867. * Serialize the material to a parsable JSON object.
  140868. */
  140869. serialize(): any;
  140870. /**
  140871. * Parses a JSON object correponding to the serialize function.
  140872. */
  140873. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  140874. }
  140875. }
  140876. declare module BABYLON {
  140877. /**
  140878. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  140879. * It can help converting any input color in a desired output one. This can then be used to create effects
  140880. * from sepia, black and white to sixties or futuristic rendering...
  140881. *
  140882. * The only supported format is currently 3dl.
  140883. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  140884. */
  140885. export class ColorGradingTexture extends BaseTexture {
  140886. /**
  140887. * The texture URL.
  140888. */
  140889. url: string;
  140890. /**
  140891. * Empty line regex stored for GC.
  140892. */
  140893. private static _noneEmptyLineRegex;
  140894. private _textureMatrix;
  140895. private _onLoad;
  140896. /**
  140897. * Instantiates a ColorGradingTexture from the following parameters.
  140898. *
  140899. * @param url The location of the color gradind data (currently only supporting 3dl)
  140900. * @param sceneOrEngine The scene or engine the texture will be used in
  140901. * @param onLoad defines a callback triggered when the texture has been loaded
  140902. */
  140903. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  140904. /**
  140905. * Fires the onload event from the constructor if requested.
  140906. */
  140907. private _triggerOnLoad;
  140908. /**
  140909. * Returns the texture matrix used in most of the material.
  140910. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  140911. */
  140912. getTextureMatrix(): Matrix;
  140913. /**
  140914. * Occurs when the file being loaded is a .3dl LUT file.
  140915. */
  140916. private load3dlTexture;
  140917. /**
  140918. * Starts the loading process of the texture.
  140919. */
  140920. private loadTexture;
  140921. /**
  140922. * Clones the color gradind texture.
  140923. */
  140924. clone(): ColorGradingTexture;
  140925. /**
  140926. * Called during delayed load for textures.
  140927. */
  140928. delayLoad(): void;
  140929. /**
  140930. * Parses a color grading texture serialized by Babylon.
  140931. * @param parsedTexture The texture information being parsedTexture
  140932. * @param scene The scene to load the texture in
  140933. * @param rootUrl The root url of the data assets to load
  140934. * @return A color gradind texture
  140935. */
  140936. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  140937. /**
  140938. * Serializes the LUT texture to json format.
  140939. */
  140940. serialize(): any;
  140941. }
  140942. }
  140943. declare module BABYLON {
  140944. /**
  140945. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  140946. */
  140947. export class EquiRectangularCubeTexture extends BaseTexture {
  140948. /** The six faces of the cube. */
  140949. private static _FacesMapping;
  140950. private _noMipmap;
  140951. private _onLoad;
  140952. private _onError;
  140953. /** The size of the cubemap. */
  140954. private _size;
  140955. /** The buffer of the image. */
  140956. private _buffer;
  140957. /** The width of the input image. */
  140958. private _width;
  140959. /** The height of the input image. */
  140960. private _height;
  140961. /** The URL to the image. */
  140962. url: string;
  140963. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  140964. coordinatesMode: number;
  140965. /**
  140966. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  140967. * @param url The location of the image
  140968. * @param scene The scene the texture will be used in
  140969. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  140970. * @param noMipmap Forces to not generate the mipmap if true
  140971. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  140972. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  140973. * @param onLoad — defines a callback called when texture is loaded
  140974. * @param onError — defines a callback called if there is an error
  140975. */
  140976. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  140977. /**
  140978. * Load the image data, by putting the image on a canvas and extracting its buffer.
  140979. */
  140980. private loadImage;
  140981. /**
  140982. * Convert the image buffer into a cubemap and create a CubeTexture.
  140983. */
  140984. private loadTexture;
  140985. /**
  140986. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  140987. * @param buffer The ArrayBuffer that should be converted.
  140988. * @returns The buffer as Float32Array.
  140989. */
  140990. private getFloat32ArrayFromArrayBuffer;
  140991. /**
  140992. * Get the current class name of the texture useful for serialization or dynamic coding.
  140993. * @returns "EquiRectangularCubeTexture"
  140994. */
  140995. getClassName(): string;
  140996. /**
  140997. * Create a clone of the current EquiRectangularCubeTexture and return it.
  140998. * @returns A clone of the current EquiRectangularCubeTexture.
  140999. */
  141000. clone(): EquiRectangularCubeTexture;
  141001. }
  141002. }
  141003. declare module BABYLON {
  141004. /**
  141005. * Defines the options related to the creation of an HtmlElementTexture
  141006. */
  141007. export interface IHtmlElementTextureOptions {
  141008. /**
  141009. * Defines wether mip maps should be created or not.
  141010. */
  141011. generateMipMaps?: boolean;
  141012. /**
  141013. * Defines the sampling mode of the texture.
  141014. */
  141015. samplingMode?: number;
  141016. /**
  141017. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  141018. */
  141019. engine: Nullable<ThinEngine>;
  141020. /**
  141021. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  141022. */
  141023. scene: Nullable<Scene>;
  141024. }
  141025. /**
  141026. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  141027. * To be as efficient as possible depending on your constraints nothing aside the first upload
  141028. * is automatically managed.
  141029. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  141030. * in your application.
  141031. *
  141032. * As the update is not automatic, you need to call them manually.
  141033. */
  141034. export class HtmlElementTexture extends BaseTexture {
  141035. /**
  141036. * The texture URL.
  141037. */
  141038. element: HTMLVideoElement | HTMLCanvasElement;
  141039. private static readonly DefaultOptions;
  141040. private _textureMatrix;
  141041. private _isVideo;
  141042. private _generateMipMaps;
  141043. private _samplingMode;
  141044. /**
  141045. * Instantiates a HtmlElementTexture from the following parameters.
  141046. *
  141047. * @param name Defines the name of the texture
  141048. * @param element Defines the video or canvas the texture is filled with
  141049. * @param options Defines the other none mandatory texture creation options
  141050. */
  141051. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  141052. private _createInternalTexture;
  141053. /**
  141054. * Returns the texture matrix used in most of the material.
  141055. */
  141056. getTextureMatrix(): Matrix;
  141057. /**
  141058. * Updates the content of the texture.
  141059. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  141060. */
  141061. update(invertY?: Nullable<boolean>): void;
  141062. }
  141063. }
  141064. declare module BABYLON {
  141065. /**
  141066. * Based on jsTGALoader - Javascript loader for TGA file
  141067. * By Vincent Thibault
  141068. * @see http://blog.robrowser.com/javascript-tga-loader.html
  141069. */
  141070. export class TGATools {
  141071. private static _TYPE_INDEXED;
  141072. private static _TYPE_RGB;
  141073. private static _TYPE_GREY;
  141074. private static _TYPE_RLE_INDEXED;
  141075. private static _TYPE_RLE_RGB;
  141076. private static _TYPE_RLE_GREY;
  141077. private static _ORIGIN_MASK;
  141078. private static _ORIGIN_SHIFT;
  141079. private static _ORIGIN_BL;
  141080. private static _ORIGIN_BR;
  141081. private static _ORIGIN_UL;
  141082. private static _ORIGIN_UR;
  141083. /**
  141084. * Gets the header of a TGA file
  141085. * @param data defines the TGA data
  141086. * @returns the header
  141087. */
  141088. static GetTGAHeader(data: Uint8Array): any;
  141089. /**
  141090. * Uploads TGA content to a Babylon Texture
  141091. * @hidden
  141092. */
  141093. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  141094. /** @hidden */
  141095. 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;
  141096. /** @hidden */
  141097. 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;
  141098. /** @hidden */
  141099. 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;
  141100. /** @hidden */
  141101. 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;
  141102. /** @hidden */
  141103. 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;
  141104. /** @hidden */
  141105. 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;
  141106. }
  141107. }
  141108. declare module BABYLON {
  141109. /**
  141110. * Implementation of the TGA Texture Loader.
  141111. * @hidden
  141112. */
  141113. export class _TGATextureLoader implements IInternalTextureLoader {
  141114. /**
  141115. * Defines wether the loader supports cascade loading the different faces.
  141116. */
  141117. readonly supportCascades: boolean;
  141118. /**
  141119. * This returns if the loader support the current file information.
  141120. * @param extension defines the file extension of the file being loaded
  141121. * @returns true if the loader can load the specified file
  141122. */
  141123. canLoad(extension: string): boolean;
  141124. /**
  141125. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  141126. * @param data contains the texture data
  141127. * @param texture defines the BabylonJS internal texture
  141128. * @param createPolynomials will be true if polynomials have been requested
  141129. * @param onLoad defines the callback to trigger once the texture is ready
  141130. * @param onError defines the callback to trigger in case of error
  141131. */
  141132. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  141133. /**
  141134. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  141135. * @param data contains the texture data
  141136. * @param texture defines the BabylonJS internal texture
  141137. * @param callback defines the method to call once ready to upload
  141138. */
  141139. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  141140. }
  141141. }
  141142. declare module BABYLON {
  141143. /**
  141144. * Info about the .basis files
  141145. */
  141146. class BasisFileInfo {
  141147. /**
  141148. * If the file has alpha
  141149. */
  141150. hasAlpha: boolean;
  141151. /**
  141152. * Info about each image of the basis file
  141153. */
  141154. images: Array<{
  141155. levels: Array<{
  141156. width: number;
  141157. height: number;
  141158. transcodedPixels: ArrayBufferView;
  141159. }>;
  141160. }>;
  141161. }
  141162. /**
  141163. * Result of transcoding a basis file
  141164. */
  141165. class TranscodeResult {
  141166. /**
  141167. * Info about the .basis file
  141168. */
  141169. fileInfo: BasisFileInfo;
  141170. /**
  141171. * Format to use when loading the file
  141172. */
  141173. format: number;
  141174. }
  141175. /**
  141176. * Configuration options for the Basis transcoder
  141177. */
  141178. export class BasisTranscodeConfiguration {
  141179. /**
  141180. * Supported compression formats used to determine the supported output format of the transcoder
  141181. */
  141182. supportedCompressionFormats?: {
  141183. /**
  141184. * etc1 compression format
  141185. */
  141186. etc1?: boolean;
  141187. /**
  141188. * s3tc compression format
  141189. */
  141190. s3tc?: boolean;
  141191. /**
  141192. * pvrtc compression format
  141193. */
  141194. pvrtc?: boolean;
  141195. /**
  141196. * etc2 compression format
  141197. */
  141198. etc2?: boolean;
  141199. };
  141200. /**
  141201. * If mipmap levels should be loaded for transcoded images (Default: true)
  141202. */
  141203. loadMipmapLevels?: boolean;
  141204. /**
  141205. * Index of a single image to load (Default: all images)
  141206. */
  141207. loadSingleImage?: number;
  141208. }
  141209. /**
  141210. * Used to load .Basis files
  141211. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  141212. */
  141213. export class BasisTools {
  141214. private static _IgnoreSupportedFormats;
  141215. /**
  141216. * URL to use when loading the basis transcoder
  141217. */
  141218. static JSModuleURL: string;
  141219. /**
  141220. * URL to use when loading the wasm module for the transcoder
  141221. */
  141222. static WasmModuleURL: string;
  141223. /**
  141224. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  141225. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  141226. * @returns internal format corresponding to the Basis format
  141227. */
  141228. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  141229. private static _WorkerPromise;
  141230. private static _Worker;
  141231. private static _actionId;
  141232. private static _CreateWorkerAsync;
  141233. /**
  141234. * Transcodes a loaded image file to compressed pixel data
  141235. * @param data image data to transcode
  141236. * @param config configuration options for the transcoding
  141237. * @returns a promise resulting in the transcoded image
  141238. */
  141239. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  141240. /**
  141241. * Loads a texture from the transcode result
  141242. * @param texture texture load to
  141243. * @param transcodeResult the result of transcoding the basis file to load from
  141244. */
  141245. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  141246. }
  141247. }
  141248. declare module BABYLON {
  141249. /**
  141250. * Loader for .basis file format
  141251. */
  141252. export class _BasisTextureLoader implements IInternalTextureLoader {
  141253. /**
  141254. * Defines whether the loader supports cascade loading the different faces.
  141255. */
  141256. readonly supportCascades: boolean;
  141257. /**
  141258. * This returns if the loader support the current file information.
  141259. * @param extension defines the file extension of the file being loaded
  141260. * @returns true if the loader can load the specified file
  141261. */
  141262. canLoad(extension: string): boolean;
  141263. /**
  141264. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  141265. * @param data contains the texture data
  141266. * @param texture defines the BabylonJS internal texture
  141267. * @param createPolynomials will be true if polynomials have been requested
  141268. * @param onLoad defines the callback to trigger once the texture is ready
  141269. * @param onError defines the callback to trigger in case of error
  141270. */
  141271. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  141272. /**
  141273. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  141274. * @param data contains the texture data
  141275. * @param texture defines the BabylonJS internal texture
  141276. * @param callback defines the method to call once ready to upload
  141277. */
  141278. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  141279. }
  141280. }
  141281. declare module BABYLON {
  141282. /**
  141283. * Defines the basic options interface of a TexturePacker Frame
  141284. */
  141285. export interface ITexturePackerFrame {
  141286. /**
  141287. * The frame ID
  141288. */
  141289. id: number;
  141290. /**
  141291. * The frames Scale
  141292. */
  141293. scale: Vector2;
  141294. /**
  141295. * The Frames offset
  141296. */
  141297. offset: Vector2;
  141298. }
  141299. /**
  141300. * This is a support class for frame Data on texture packer sets.
  141301. */
  141302. export class TexturePackerFrame implements ITexturePackerFrame {
  141303. /**
  141304. * The frame ID
  141305. */
  141306. id: number;
  141307. /**
  141308. * The frames Scale
  141309. */
  141310. scale: Vector2;
  141311. /**
  141312. * The Frames offset
  141313. */
  141314. offset: Vector2;
  141315. /**
  141316. * Initializes a texture package frame.
  141317. * @param id The numerical frame identifier
  141318. * @param scale Scalar Vector2 for UV frame
  141319. * @param offset Vector2 for the frame position in UV units.
  141320. * @returns TexturePackerFrame
  141321. */
  141322. constructor(id: number, scale: Vector2, offset: Vector2);
  141323. }
  141324. }
  141325. declare module BABYLON {
  141326. /**
  141327. * Defines the basic options interface of a TexturePacker
  141328. */
  141329. export interface ITexturePackerOptions {
  141330. /**
  141331. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  141332. */
  141333. map?: string[];
  141334. /**
  141335. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  141336. */
  141337. uvsIn?: string;
  141338. /**
  141339. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  141340. */
  141341. uvsOut?: string;
  141342. /**
  141343. * number representing the layout style. Defaults to LAYOUT_STRIP
  141344. */
  141345. layout?: number;
  141346. /**
  141347. * number of columns if using custom column count layout(2). This defaults to 4.
  141348. */
  141349. colnum?: number;
  141350. /**
  141351. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  141352. */
  141353. updateInputMeshes?: boolean;
  141354. /**
  141355. * boolean flag to dispose all the source textures. Defaults to true.
  141356. */
  141357. disposeSources?: boolean;
  141358. /**
  141359. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  141360. */
  141361. fillBlanks?: boolean;
  141362. /**
  141363. * string value representing the context fill style color. Defaults to 'black'.
  141364. */
  141365. customFillColor?: string;
  141366. /**
  141367. * Width and Height Value of each Frame in the TexturePacker Sets
  141368. */
  141369. frameSize?: number;
  141370. /**
  141371. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  141372. */
  141373. paddingRatio?: number;
  141374. /**
  141375. * Number that declares the fill method for the padding gutter.
  141376. */
  141377. paddingMode?: number;
  141378. /**
  141379. * If in SUBUV_COLOR padding mode what color to use.
  141380. */
  141381. paddingColor?: Color3 | Color4;
  141382. }
  141383. /**
  141384. * Defines the basic interface of a TexturePacker JSON File
  141385. */
  141386. export interface ITexturePackerJSON {
  141387. /**
  141388. * The frame ID
  141389. */
  141390. name: string;
  141391. /**
  141392. * The base64 channel data
  141393. */
  141394. sets: any;
  141395. /**
  141396. * The options of the Packer
  141397. */
  141398. options: ITexturePackerOptions;
  141399. /**
  141400. * The frame data of the Packer
  141401. */
  141402. frames: Array<number>;
  141403. }
  141404. /**
  141405. * This is a support class that generates a series of packed texture sets.
  141406. * @see https://doc.babylonjs.com/babylon101/materials
  141407. */
  141408. export class TexturePacker {
  141409. /** Packer Layout Constant 0 */
  141410. static readonly LAYOUT_STRIP: number;
  141411. /** Packer Layout Constant 1 */
  141412. static readonly LAYOUT_POWER2: number;
  141413. /** Packer Layout Constant 2 */
  141414. static readonly LAYOUT_COLNUM: number;
  141415. /** Packer Layout Constant 0 */
  141416. static readonly SUBUV_WRAP: number;
  141417. /** Packer Layout Constant 1 */
  141418. static readonly SUBUV_EXTEND: number;
  141419. /** Packer Layout Constant 2 */
  141420. static readonly SUBUV_COLOR: number;
  141421. /** The Name of the Texture Package */
  141422. name: string;
  141423. /** The scene scope of the TexturePacker */
  141424. scene: Scene;
  141425. /** The Meshes to target */
  141426. meshes: AbstractMesh[];
  141427. /** Arguments passed with the Constructor */
  141428. options: ITexturePackerOptions;
  141429. /** The promise that is started upon initialization */
  141430. promise: Nullable<Promise<TexturePacker | string>>;
  141431. /** The Container object for the channel sets that are generated */
  141432. sets: object;
  141433. /** The Container array for the frames that are generated */
  141434. frames: TexturePackerFrame[];
  141435. /** The expected number of textures the system is parsing. */
  141436. private _expecting;
  141437. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  141438. private _paddingValue;
  141439. /**
  141440. * Initializes a texture package series from an array of meshes or a single mesh.
  141441. * @param name The name of the package
  141442. * @param meshes The target meshes to compose the package from
  141443. * @param options The arguments that texture packer should follow while building.
  141444. * @param scene The scene which the textures are scoped to.
  141445. * @returns TexturePacker
  141446. */
  141447. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  141448. /**
  141449. * Starts the package process
  141450. * @param resolve The promises resolution function
  141451. * @returns TexturePacker
  141452. */
  141453. private _createFrames;
  141454. /**
  141455. * Calculates the Size of the Channel Sets
  141456. * @returns Vector2
  141457. */
  141458. private _calculateSize;
  141459. /**
  141460. * Calculates the UV data for the frames.
  141461. * @param baseSize the base frameSize
  141462. * @param padding the base frame padding
  141463. * @param dtSize size of the Dynamic Texture for that channel
  141464. * @param dtUnits is 1/dtSize
  141465. * @param update flag to update the input meshes
  141466. */
  141467. private _calculateMeshUVFrames;
  141468. /**
  141469. * Calculates the frames Offset.
  141470. * @param index of the frame
  141471. * @returns Vector2
  141472. */
  141473. private _getFrameOffset;
  141474. /**
  141475. * Updates a Mesh to the frame data
  141476. * @param mesh that is the target
  141477. * @param frameID or the frame index
  141478. */
  141479. private _updateMeshUV;
  141480. /**
  141481. * Updates a Meshes materials to use the texture packer channels
  141482. * @param m is the mesh to target
  141483. * @param force all channels on the packer to be set.
  141484. */
  141485. private _updateTextureReferences;
  141486. /**
  141487. * Public method to set a Mesh to a frame
  141488. * @param m that is the target
  141489. * @param frameID or the frame index
  141490. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  141491. */
  141492. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  141493. /**
  141494. * Starts the async promise to compile the texture packer.
  141495. * @returns Promise<void>
  141496. */
  141497. processAsync(): Promise<void>;
  141498. /**
  141499. * Disposes all textures associated with this packer
  141500. */
  141501. dispose(): void;
  141502. /**
  141503. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  141504. * @param imageType is the image type to use.
  141505. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  141506. */
  141507. download(imageType?: string, quality?: number): void;
  141508. /**
  141509. * Public method to load a texturePacker JSON file.
  141510. * @param data of the JSON file in string format.
  141511. */
  141512. updateFromJSON(data: string): void;
  141513. }
  141514. }
  141515. declare module BABYLON {
  141516. /**
  141517. * 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.
  141518. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  141519. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  141520. */
  141521. export class CustomProceduralTexture extends ProceduralTexture {
  141522. private _animate;
  141523. private _time;
  141524. private _config;
  141525. private _texturePath;
  141526. /**
  141527. * Instantiates a new Custom Procedural Texture.
  141528. * 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.
  141529. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  141530. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  141531. * @param name Define the name of the texture
  141532. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  141533. * @param size Define the size of the texture to create
  141534. * @param scene Define the scene the texture belongs to
  141535. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  141536. * @param generateMipMaps Define if the texture should creates mip maps or not
  141537. */
  141538. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  141539. private _loadJson;
  141540. /**
  141541. * Is the texture ready to be used ? (rendered at least once)
  141542. * @returns true if ready, otherwise, false.
  141543. */
  141544. isReady(): boolean;
  141545. /**
  141546. * Render the texture to its associated render target.
  141547. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  141548. */
  141549. render(useCameraPostProcess?: boolean): void;
  141550. /**
  141551. * Update the list of dependant textures samplers in the shader.
  141552. */
  141553. updateTextures(): void;
  141554. /**
  141555. * Update the uniform values of the procedural texture in the shader.
  141556. */
  141557. updateShaderUniforms(): void;
  141558. /**
  141559. * Define if the texture animates or not.
  141560. */
  141561. get animate(): boolean;
  141562. set animate(value: boolean);
  141563. }
  141564. }
  141565. declare module BABYLON {
  141566. /** @hidden */
  141567. export var noisePixelShader: {
  141568. name: string;
  141569. shader: string;
  141570. };
  141571. }
  141572. declare module BABYLON {
  141573. /**
  141574. * Class used to generate noise procedural textures
  141575. */
  141576. export class NoiseProceduralTexture extends ProceduralTexture {
  141577. private _time;
  141578. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  141579. brightness: number;
  141580. /** Defines the number of octaves to process */
  141581. octaves: number;
  141582. /** Defines the level of persistence (0.8 by default) */
  141583. persistence: number;
  141584. /** Gets or sets animation speed factor (default is 1) */
  141585. animationSpeedFactor: number;
  141586. /**
  141587. * Creates a new NoiseProceduralTexture
  141588. * @param name defines the name fo the texture
  141589. * @param size defines the size of the texture (default is 256)
  141590. * @param scene defines the hosting scene
  141591. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  141592. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  141593. */
  141594. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  141595. private _updateShaderUniforms;
  141596. protected _getDefines(): string;
  141597. /** Generate the current state of the procedural texture */
  141598. render(useCameraPostProcess?: boolean): void;
  141599. /**
  141600. * Serializes this noise procedural texture
  141601. * @returns a serialized noise procedural texture object
  141602. */
  141603. serialize(): any;
  141604. /**
  141605. * Clone the texture.
  141606. * @returns the cloned texture
  141607. */
  141608. clone(): NoiseProceduralTexture;
  141609. /**
  141610. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  141611. * @param parsedTexture defines parsed texture data
  141612. * @param scene defines the current scene
  141613. * @param rootUrl defines the root URL containing noise procedural texture information
  141614. * @returns a parsed NoiseProceduralTexture
  141615. */
  141616. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  141617. }
  141618. }
  141619. declare module BABYLON {
  141620. /**
  141621. * Raw cube texture where the raw buffers are passed in
  141622. */
  141623. export class RawCubeTexture extends CubeTexture {
  141624. /**
  141625. * Creates a cube texture where the raw buffers are passed in.
  141626. * @param scene defines the scene the texture is attached to
  141627. * @param data defines the array of data to use to create each face
  141628. * @param size defines the size of the textures
  141629. * @param format defines the format of the data
  141630. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  141631. * @param generateMipMaps defines if the engine should generate the mip levels
  141632. * @param invertY defines if data must be stored with Y axis inverted
  141633. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  141634. * @param compression defines the compression used (null by default)
  141635. */
  141636. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  141637. /**
  141638. * Updates the raw cube texture.
  141639. * @param data defines the data to store
  141640. * @param format defines the data format
  141641. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  141642. * @param invertY defines if data must be stored with Y axis inverted
  141643. * @param compression defines the compression used (null by default)
  141644. * @param level defines which level of the texture to update
  141645. */
  141646. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  141647. /**
  141648. * Updates a raw cube texture with RGBD encoded data.
  141649. * @param data defines the array of data [mipmap][face] to use to create each face
  141650. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  141651. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  141652. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  141653. * @returns a promsie that resolves when the operation is complete
  141654. */
  141655. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  141656. /**
  141657. * Clones the raw cube texture.
  141658. * @return a new cube texture
  141659. */
  141660. clone(): CubeTexture;
  141661. /** @hidden */
  141662. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  141663. }
  141664. }
  141665. declare module BABYLON {
  141666. /**
  141667. * Class used to store 2D array textures containing user data
  141668. */
  141669. export class RawTexture2DArray extends Texture {
  141670. /** Gets or sets the texture format to use */
  141671. format: number;
  141672. /**
  141673. * Create a new RawTexture2DArray
  141674. * @param data defines the data of the texture
  141675. * @param width defines the width of the texture
  141676. * @param height defines the height of the texture
  141677. * @param depth defines the number of layers of the texture
  141678. * @param format defines the texture format to use
  141679. * @param scene defines the hosting scene
  141680. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  141681. * @param invertY defines if texture must be stored with Y axis inverted
  141682. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141683. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  141684. */
  141685. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  141686. /** Gets or sets the texture format to use */
  141687. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  141688. /**
  141689. * Update the texture with new data
  141690. * @param data defines the data to store in the texture
  141691. */
  141692. update(data: ArrayBufferView): void;
  141693. }
  141694. }
  141695. declare module BABYLON {
  141696. /**
  141697. * Class used to store 3D textures containing user data
  141698. */
  141699. export class RawTexture3D extends Texture {
  141700. /** Gets or sets the texture format to use */
  141701. format: number;
  141702. /**
  141703. * Create a new RawTexture3D
  141704. * @param data defines the data of the texture
  141705. * @param width defines the width of the texture
  141706. * @param height defines the height of the texture
  141707. * @param depth defines the depth of the texture
  141708. * @param format defines the texture format to use
  141709. * @param scene defines the hosting scene
  141710. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  141711. * @param invertY defines if texture must be stored with Y axis inverted
  141712. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141713. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  141714. */
  141715. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  141716. /** Gets or sets the texture format to use */
  141717. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  141718. /**
  141719. * Update the texture with new data
  141720. * @param data defines the data to store in the texture
  141721. */
  141722. update(data: ArrayBufferView): void;
  141723. }
  141724. }
  141725. declare module BABYLON {
  141726. /**
  141727. * Creates a refraction texture used by refraction channel of the standard material.
  141728. * It is like a mirror but to see through a material.
  141729. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  141730. */
  141731. export class RefractionTexture extends RenderTargetTexture {
  141732. /**
  141733. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  141734. * 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.
  141735. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  141736. */
  141737. refractionPlane: Plane;
  141738. /**
  141739. * Define how deep under the surface we should see.
  141740. */
  141741. depth: number;
  141742. /**
  141743. * Creates a refraction texture used by refraction channel of the standard material.
  141744. * It is like a mirror but to see through a material.
  141745. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  141746. * @param name Define the texture name
  141747. * @param size Define the size of the underlying texture
  141748. * @param scene Define the scene the refraction belongs to
  141749. * @param generateMipMaps Define if we need to generate mips level for the refraction
  141750. */
  141751. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  141752. /**
  141753. * Clone the refraction texture.
  141754. * @returns the cloned texture
  141755. */
  141756. clone(): RefractionTexture;
  141757. /**
  141758. * Serialize the texture to a JSON representation you could use in Parse later on
  141759. * @returns the serialized JSON representation
  141760. */
  141761. serialize(): any;
  141762. }
  141763. }
  141764. declare module BABYLON {
  141765. /**
  141766. * Block used to add support for vertex skinning (bones)
  141767. */
  141768. export class BonesBlock extends NodeMaterialBlock {
  141769. /**
  141770. * Creates a new BonesBlock
  141771. * @param name defines the block name
  141772. */
  141773. constructor(name: string);
  141774. /**
  141775. * Initialize the block and prepare the context for build
  141776. * @param state defines the state that will be used for the build
  141777. */
  141778. initialize(state: NodeMaterialBuildState): void;
  141779. /**
  141780. * Gets the current class name
  141781. * @returns the class name
  141782. */
  141783. getClassName(): string;
  141784. /**
  141785. * Gets the matrix indices input component
  141786. */
  141787. get matricesIndices(): NodeMaterialConnectionPoint;
  141788. /**
  141789. * Gets the matrix weights input component
  141790. */
  141791. get matricesWeights(): NodeMaterialConnectionPoint;
  141792. /**
  141793. * Gets the extra matrix indices input component
  141794. */
  141795. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  141796. /**
  141797. * Gets the extra matrix weights input component
  141798. */
  141799. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  141800. /**
  141801. * Gets the world input component
  141802. */
  141803. get world(): NodeMaterialConnectionPoint;
  141804. /**
  141805. * Gets the output component
  141806. */
  141807. get output(): NodeMaterialConnectionPoint;
  141808. autoConfigure(material: NodeMaterial): void;
  141809. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  141810. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141811. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141812. protected _buildBlock(state: NodeMaterialBuildState): this;
  141813. }
  141814. }
  141815. declare module BABYLON {
  141816. /**
  141817. * Block used to add support for instances
  141818. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  141819. */
  141820. export class InstancesBlock extends NodeMaterialBlock {
  141821. /**
  141822. * Creates a new InstancesBlock
  141823. * @param name defines the block name
  141824. */
  141825. constructor(name: string);
  141826. /**
  141827. * Gets the current class name
  141828. * @returns the class name
  141829. */
  141830. getClassName(): string;
  141831. /**
  141832. * Gets the first world row input component
  141833. */
  141834. get world0(): NodeMaterialConnectionPoint;
  141835. /**
  141836. * Gets the second world row input component
  141837. */
  141838. get world1(): NodeMaterialConnectionPoint;
  141839. /**
  141840. * Gets the third world row input component
  141841. */
  141842. get world2(): NodeMaterialConnectionPoint;
  141843. /**
  141844. * Gets the forth world row input component
  141845. */
  141846. get world3(): NodeMaterialConnectionPoint;
  141847. /**
  141848. * Gets the world input component
  141849. */
  141850. get world(): NodeMaterialConnectionPoint;
  141851. /**
  141852. * Gets the output component
  141853. */
  141854. get output(): NodeMaterialConnectionPoint;
  141855. /**
  141856. * Gets the isntanceID component
  141857. */
  141858. get instanceID(): NodeMaterialConnectionPoint;
  141859. autoConfigure(material: NodeMaterial): void;
  141860. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  141861. protected _buildBlock(state: NodeMaterialBuildState): this;
  141862. }
  141863. }
  141864. declare module BABYLON {
  141865. /**
  141866. * Block used to add morph targets support to vertex shader
  141867. */
  141868. export class MorphTargetsBlock extends NodeMaterialBlock {
  141869. private _repeatableContentAnchor;
  141870. /**
  141871. * Create a new MorphTargetsBlock
  141872. * @param name defines the block name
  141873. */
  141874. constructor(name: string);
  141875. /**
  141876. * Gets the current class name
  141877. * @returns the class name
  141878. */
  141879. getClassName(): string;
  141880. /**
  141881. * Gets the position input component
  141882. */
  141883. get position(): NodeMaterialConnectionPoint;
  141884. /**
  141885. * Gets the normal input component
  141886. */
  141887. get normal(): NodeMaterialConnectionPoint;
  141888. /**
  141889. * Gets the tangent input component
  141890. */
  141891. get tangent(): NodeMaterialConnectionPoint;
  141892. /**
  141893. * Gets the tangent input component
  141894. */
  141895. get uv(): NodeMaterialConnectionPoint;
  141896. /**
  141897. * Gets the position output component
  141898. */
  141899. get positionOutput(): NodeMaterialConnectionPoint;
  141900. /**
  141901. * Gets the normal output component
  141902. */
  141903. get normalOutput(): NodeMaterialConnectionPoint;
  141904. /**
  141905. * Gets the tangent output component
  141906. */
  141907. get tangentOutput(): NodeMaterialConnectionPoint;
  141908. /**
  141909. * Gets the tangent output component
  141910. */
  141911. get uvOutput(): NodeMaterialConnectionPoint;
  141912. initialize(state: NodeMaterialBuildState): void;
  141913. autoConfigure(material: NodeMaterial): void;
  141914. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141915. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141916. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  141917. protected _buildBlock(state: NodeMaterialBuildState): this;
  141918. }
  141919. }
  141920. declare module BABYLON {
  141921. /**
  141922. * Block used to get data information from a light
  141923. */
  141924. export class LightInformationBlock extends NodeMaterialBlock {
  141925. private _lightDataUniformName;
  141926. private _lightColorUniformName;
  141927. private _lightTypeDefineName;
  141928. /**
  141929. * Gets or sets the light associated with this block
  141930. */
  141931. light: Nullable<Light>;
  141932. /**
  141933. * Creates a new LightInformationBlock
  141934. * @param name defines the block name
  141935. */
  141936. constructor(name: string);
  141937. /**
  141938. * Gets the current class name
  141939. * @returns the class name
  141940. */
  141941. getClassName(): string;
  141942. /**
  141943. * Gets the world position input component
  141944. */
  141945. get worldPosition(): NodeMaterialConnectionPoint;
  141946. /**
  141947. * Gets the direction output component
  141948. */
  141949. get direction(): NodeMaterialConnectionPoint;
  141950. /**
  141951. * Gets the direction output component
  141952. */
  141953. get color(): NodeMaterialConnectionPoint;
  141954. /**
  141955. * Gets the direction output component
  141956. */
  141957. get intensity(): NodeMaterialConnectionPoint;
  141958. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141959. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141960. protected _buildBlock(state: NodeMaterialBuildState): this;
  141961. serialize(): any;
  141962. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141963. }
  141964. }
  141965. declare module BABYLON {
  141966. /**
  141967. * Block used to add image processing support to fragment shader
  141968. */
  141969. export class ImageProcessingBlock extends NodeMaterialBlock {
  141970. /**
  141971. * Create a new ImageProcessingBlock
  141972. * @param name defines the block name
  141973. */
  141974. constructor(name: string);
  141975. /**
  141976. * Gets the current class name
  141977. * @returns the class name
  141978. */
  141979. getClassName(): string;
  141980. /**
  141981. * Gets the color input component
  141982. */
  141983. get color(): NodeMaterialConnectionPoint;
  141984. /**
  141985. * Gets the output component
  141986. */
  141987. get output(): NodeMaterialConnectionPoint;
  141988. /**
  141989. * Initialize the block and prepare the context for build
  141990. * @param state defines the state that will be used for the build
  141991. */
  141992. initialize(state: NodeMaterialBuildState): void;
  141993. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  141994. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141995. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141996. protected _buildBlock(state: NodeMaterialBuildState): this;
  141997. }
  141998. }
  141999. declare module BABYLON {
  142000. /**
  142001. * Block used to pertub normals based on a normal map
  142002. */
  142003. export class PerturbNormalBlock extends NodeMaterialBlock {
  142004. private _tangentSpaceParameterName;
  142005. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  142006. invertX: boolean;
  142007. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  142008. invertY: boolean;
  142009. /**
  142010. * Create a new PerturbNormalBlock
  142011. * @param name defines the block name
  142012. */
  142013. constructor(name: string);
  142014. /**
  142015. * Gets the current class name
  142016. * @returns the class name
  142017. */
  142018. getClassName(): string;
  142019. /**
  142020. * Gets the world position input component
  142021. */
  142022. get worldPosition(): NodeMaterialConnectionPoint;
  142023. /**
  142024. * Gets the world normal input component
  142025. */
  142026. get worldNormal(): NodeMaterialConnectionPoint;
  142027. /**
  142028. * Gets the world tangent input component
  142029. */
  142030. get worldTangent(): NodeMaterialConnectionPoint;
  142031. /**
  142032. * Gets the uv input component
  142033. */
  142034. get uv(): NodeMaterialConnectionPoint;
  142035. /**
  142036. * Gets the normal map color input component
  142037. */
  142038. get normalMapColor(): NodeMaterialConnectionPoint;
  142039. /**
  142040. * Gets the strength input component
  142041. */
  142042. get strength(): NodeMaterialConnectionPoint;
  142043. /**
  142044. * Gets the output component
  142045. */
  142046. get output(): NodeMaterialConnectionPoint;
  142047. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142048. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142049. autoConfigure(material: NodeMaterial): void;
  142050. protected _buildBlock(state: NodeMaterialBuildState): this;
  142051. protected _dumpPropertiesCode(): string;
  142052. serialize(): any;
  142053. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142054. }
  142055. }
  142056. declare module BABYLON {
  142057. /**
  142058. * Block used to discard a pixel if a value is smaller than a cutoff
  142059. */
  142060. export class DiscardBlock extends NodeMaterialBlock {
  142061. /**
  142062. * Create a new DiscardBlock
  142063. * @param name defines the block name
  142064. */
  142065. constructor(name: string);
  142066. /**
  142067. * Gets the current class name
  142068. * @returns the class name
  142069. */
  142070. getClassName(): string;
  142071. /**
  142072. * Gets the color input component
  142073. */
  142074. get value(): NodeMaterialConnectionPoint;
  142075. /**
  142076. * Gets the cutoff input component
  142077. */
  142078. get cutoff(): NodeMaterialConnectionPoint;
  142079. protected _buildBlock(state: NodeMaterialBuildState): this;
  142080. }
  142081. }
  142082. declare module BABYLON {
  142083. /**
  142084. * Block used to test if the fragment shader is front facing
  142085. */
  142086. export class FrontFacingBlock extends NodeMaterialBlock {
  142087. /**
  142088. * Creates a new FrontFacingBlock
  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 output component
  142099. */
  142100. get output(): NodeMaterialConnectionPoint;
  142101. protected _buildBlock(state: NodeMaterialBuildState): this;
  142102. }
  142103. }
  142104. declare module BABYLON {
  142105. /**
  142106. * Block used to get the derivative value on x and y of a given input
  142107. */
  142108. export class DerivativeBlock extends NodeMaterialBlock {
  142109. /**
  142110. * Create a new DerivativeBlock
  142111. * @param name defines the block name
  142112. */
  142113. constructor(name: string);
  142114. /**
  142115. * Gets the current class name
  142116. * @returns the class name
  142117. */
  142118. getClassName(): string;
  142119. /**
  142120. * Gets the input component
  142121. */
  142122. get input(): NodeMaterialConnectionPoint;
  142123. /**
  142124. * Gets the derivative output on x
  142125. */
  142126. get dx(): NodeMaterialConnectionPoint;
  142127. /**
  142128. * Gets the derivative output on y
  142129. */
  142130. get dy(): NodeMaterialConnectionPoint;
  142131. protected _buildBlock(state: NodeMaterialBuildState): this;
  142132. }
  142133. }
  142134. declare module BABYLON {
  142135. /**
  142136. * Block used to make gl_FragCoord available
  142137. */
  142138. export class FragCoordBlock extends NodeMaterialBlock {
  142139. /**
  142140. * Creates a new FragCoordBlock
  142141. * @param name defines the block name
  142142. */
  142143. constructor(name: string);
  142144. /**
  142145. * Gets the current class name
  142146. * @returns the class name
  142147. */
  142148. getClassName(): string;
  142149. /**
  142150. * Gets the xy component
  142151. */
  142152. get xy(): NodeMaterialConnectionPoint;
  142153. /**
  142154. * Gets the xyz component
  142155. */
  142156. get xyz(): NodeMaterialConnectionPoint;
  142157. /**
  142158. * Gets the xyzw component
  142159. */
  142160. get xyzw(): NodeMaterialConnectionPoint;
  142161. /**
  142162. * Gets the x component
  142163. */
  142164. get x(): NodeMaterialConnectionPoint;
  142165. /**
  142166. * Gets the y component
  142167. */
  142168. get y(): NodeMaterialConnectionPoint;
  142169. /**
  142170. * Gets the z component
  142171. */
  142172. get z(): NodeMaterialConnectionPoint;
  142173. /**
  142174. * Gets the w component
  142175. */
  142176. get output(): NodeMaterialConnectionPoint;
  142177. protected writeOutputs(state: NodeMaterialBuildState): string;
  142178. protected _buildBlock(state: NodeMaterialBuildState): this;
  142179. }
  142180. }
  142181. declare module BABYLON {
  142182. /**
  142183. * Block used to get the screen sizes
  142184. */
  142185. export class ScreenSizeBlock extends NodeMaterialBlock {
  142186. private _varName;
  142187. private _scene;
  142188. /**
  142189. * Creates a new ScreenSizeBlock
  142190. * @param name defines the block name
  142191. */
  142192. constructor(name: string);
  142193. /**
  142194. * Gets the current class name
  142195. * @returns the class name
  142196. */
  142197. getClassName(): string;
  142198. /**
  142199. * Gets the xy component
  142200. */
  142201. get xy(): NodeMaterialConnectionPoint;
  142202. /**
  142203. * Gets the x component
  142204. */
  142205. get x(): NodeMaterialConnectionPoint;
  142206. /**
  142207. * Gets the y component
  142208. */
  142209. get y(): NodeMaterialConnectionPoint;
  142210. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142211. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  142212. protected _buildBlock(state: NodeMaterialBuildState): this;
  142213. }
  142214. }
  142215. declare module BABYLON {
  142216. /**
  142217. * Block used to add support for scene fog
  142218. */
  142219. export class FogBlock extends NodeMaterialBlock {
  142220. private _fogDistanceName;
  142221. private _fogParameters;
  142222. /**
  142223. * Create a new FogBlock
  142224. * @param name defines the block name
  142225. */
  142226. constructor(name: string);
  142227. /**
  142228. * Gets the current class name
  142229. * @returns the class name
  142230. */
  142231. getClassName(): string;
  142232. /**
  142233. * Gets the world position input component
  142234. */
  142235. get worldPosition(): NodeMaterialConnectionPoint;
  142236. /**
  142237. * Gets the view input component
  142238. */
  142239. get view(): NodeMaterialConnectionPoint;
  142240. /**
  142241. * Gets the color input component
  142242. */
  142243. get input(): NodeMaterialConnectionPoint;
  142244. /**
  142245. * Gets the fog color input component
  142246. */
  142247. get fogColor(): NodeMaterialConnectionPoint;
  142248. /**
  142249. * Gets the output component
  142250. */
  142251. get output(): NodeMaterialConnectionPoint;
  142252. autoConfigure(material: NodeMaterial): void;
  142253. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142254. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142255. protected _buildBlock(state: NodeMaterialBuildState): this;
  142256. }
  142257. }
  142258. declare module BABYLON {
  142259. /**
  142260. * Block used to add light in the fragment shader
  142261. */
  142262. export class LightBlock extends NodeMaterialBlock {
  142263. private _lightId;
  142264. /**
  142265. * Gets or sets the light associated with this block
  142266. */
  142267. light: Nullable<Light>;
  142268. /**
  142269. * Create a new LightBlock
  142270. * @param name defines the block name
  142271. */
  142272. constructor(name: string);
  142273. /**
  142274. * Gets the current class name
  142275. * @returns the class name
  142276. */
  142277. getClassName(): string;
  142278. /**
  142279. * Gets the world position input component
  142280. */
  142281. get worldPosition(): NodeMaterialConnectionPoint;
  142282. /**
  142283. * Gets the world normal input component
  142284. */
  142285. get worldNormal(): NodeMaterialConnectionPoint;
  142286. /**
  142287. * Gets the camera (or eye) position component
  142288. */
  142289. get cameraPosition(): NodeMaterialConnectionPoint;
  142290. /**
  142291. * Gets the glossiness component
  142292. */
  142293. get glossiness(): NodeMaterialConnectionPoint;
  142294. /**
  142295. * Gets the glossinness power component
  142296. */
  142297. get glossPower(): NodeMaterialConnectionPoint;
  142298. /**
  142299. * Gets the diffuse color component
  142300. */
  142301. get diffuseColor(): NodeMaterialConnectionPoint;
  142302. /**
  142303. * Gets the specular color component
  142304. */
  142305. get specularColor(): NodeMaterialConnectionPoint;
  142306. /**
  142307. * Gets the diffuse output component
  142308. */
  142309. get diffuseOutput(): NodeMaterialConnectionPoint;
  142310. /**
  142311. * Gets the specular output component
  142312. */
  142313. get specularOutput(): NodeMaterialConnectionPoint;
  142314. /**
  142315. * Gets the shadow output component
  142316. */
  142317. get shadow(): NodeMaterialConnectionPoint;
  142318. autoConfigure(material: NodeMaterial): void;
  142319. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142320. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  142321. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142322. private _injectVertexCode;
  142323. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142324. serialize(): any;
  142325. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142326. }
  142327. }
  142328. declare module BABYLON {
  142329. /**
  142330. * Block used to read a reflection texture from a sampler
  142331. */
  142332. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  142333. /**
  142334. * Create a new ReflectionTextureBlock
  142335. * @param name defines the block name
  142336. */
  142337. constructor(name: string);
  142338. /**
  142339. * Gets the current class name
  142340. * @returns the class name
  142341. */
  142342. getClassName(): string;
  142343. /**
  142344. * Gets the world position input component
  142345. */
  142346. get position(): NodeMaterialConnectionPoint;
  142347. /**
  142348. * Gets the world position input component
  142349. */
  142350. get worldPosition(): NodeMaterialConnectionPoint;
  142351. /**
  142352. * Gets the world normal input component
  142353. */
  142354. get worldNormal(): NodeMaterialConnectionPoint;
  142355. /**
  142356. * Gets the world input component
  142357. */
  142358. get world(): NodeMaterialConnectionPoint;
  142359. /**
  142360. * Gets the camera (or eye) position component
  142361. */
  142362. get cameraPosition(): NodeMaterialConnectionPoint;
  142363. /**
  142364. * Gets the view input component
  142365. */
  142366. get view(): NodeMaterialConnectionPoint;
  142367. /**
  142368. * Gets the rgb output component
  142369. */
  142370. get rgb(): NodeMaterialConnectionPoint;
  142371. /**
  142372. * Gets the rgba output component
  142373. */
  142374. get rgba(): NodeMaterialConnectionPoint;
  142375. /**
  142376. * Gets the r output component
  142377. */
  142378. get r(): NodeMaterialConnectionPoint;
  142379. /**
  142380. * Gets the g output component
  142381. */
  142382. get g(): NodeMaterialConnectionPoint;
  142383. /**
  142384. * Gets the b output component
  142385. */
  142386. get b(): NodeMaterialConnectionPoint;
  142387. /**
  142388. * Gets the a output component
  142389. */
  142390. get a(): NodeMaterialConnectionPoint;
  142391. autoConfigure(material: NodeMaterial): void;
  142392. protected _buildBlock(state: NodeMaterialBuildState): this;
  142393. }
  142394. }
  142395. declare module BABYLON {
  142396. /**
  142397. * Block used to add 2 vectors
  142398. */
  142399. export class AddBlock extends NodeMaterialBlock {
  142400. /**
  142401. * Creates a new AddBlock
  142402. * @param name defines the block name
  142403. */
  142404. constructor(name: string);
  142405. /**
  142406. * Gets the current class name
  142407. * @returns the class name
  142408. */
  142409. getClassName(): string;
  142410. /**
  142411. * Gets the left operand input component
  142412. */
  142413. get left(): NodeMaterialConnectionPoint;
  142414. /**
  142415. * Gets the right operand input component
  142416. */
  142417. get right(): NodeMaterialConnectionPoint;
  142418. /**
  142419. * Gets the output component
  142420. */
  142421. get output(): NodeMaterialConnectionPoint;
  142422. protected _buildBlock(state: NodeMaterialBuildState): this;
  142423. }
  142424. }
  142425. declare module BABYLON {
  142426. /**
  142427. * Block used to scale a vector by a float
  142428. */
  142429. export class ScaleBlock extends NodeMaterialBlock {
  142430. /**
  142431. * Creates a new ScaleBlock
  142432. * @param name defines the block name
  142433. */
  142434. constructor(name: string);
  142435. /**
  142436. * Gets the current class name
  142437. * @returns the class name
  142438. */
  142439. getClassName(): string;
  142440. /**
  142441. * Gets the input component
  142442. */
  142443. get input(): NodeMaterialConnectionPoint;
  142444. /**
  142445. * Gets the factor input component
  142446. */
  142447. get factor(): NodeMaterialConnectionPoint;
  142448. /**
  142449. * Gets the output component
  142450. */
  142451. get output(): NodeMaterialConnectionPoint;
  142452. protected _buildBlock(state: NodeMaterialBuildState): this;
  142453. }
  142454. }
  142455. declare module BABYLON {
  142456. /**
  142457. * Block used to clamp a float
  142458. */
  142459. export class ClampBlock extends NodeMaterialBlock {
  142460. /** Gets or sets the minimum range */
  142461. minimum: number;
  142462. /** Gets or sets the maximum range */
  142463. maximum: number;
  142464. /**
  142465. * Creates a new ClampBlock
  142466. * @param name defines the block name
  142467. */
  142468. constructor(name: string);
  142469. /**
  142470. * Gets the current class name
  142471. * @returns the class name
  142472. */
  142473. getClassName(): string;
  142474. /**
  142475. * Gets the value input component
  142476. */
  142477. get value(): NodeMaterialConnectionPoint;
  142478. /**
  142479. * Gets the output component
  142480. */
  142481. get output(): NodeMaterialConnectionPoint;
  142482. protected _buildBlock(state: NodeMaterialBuildState): this;
  142483. protected _dumpPropertiesCode(): string;
  142484. serialize(): any;
  142485. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142486. }
  142487. }
  142488. declare module BABYLON {
  142489. /**
  142490. * Block used to apply a cross product between 2 vectors
  142491. */
  142492. export class CrossBlock extends NodeMaterialBlock {
  142493. /**
  142494. * Creates a new CrossBlock
  142495. * @param name defines the block name
  142496. */
  142497. constructor(name: string);
  142498. /**
  142499. * Gets the current class name
  142500. * @returns the class name
  142501. */
  142502. getClassName(): string;
  142503. /**
  142504. * Gets the left operand input component
  142505. */
  142506. get left(): NodeMaterialConnectionPoint;
  142507. /**
  142508. * Gets the right operand input component
  142509. */
  142510. get right(): NodeMaterialConnectionPoint;
  142511. /**
  142512. * Gets the output component
  142513. */
  142514. get output(): NodeMaterialConnectionPoint;
  142515. protected _buildBlock(state: NodeMaterialBuildState): this;
  142516. }
  142517. }
  142518. declare module BABYLON {
  142519. /**
  142520. * Block used to apply a dot product between 2 vectors
  142521. */
  142522. export class DotBlock extends NodeMaterialBlock {
  142523. /**
  142524. * Creates a new DotBlock
  142525. * @param name defines the block name
  142526. */
  142527. constructor(name: string);
  142528. /**
  142529. * Gets the current class name
  142530. * @returns the class name
  142531. */
  142532. getClassName(): string;
  142533. /**
  142534. * Gets the left operand input component
  142535. */
  142536. get left(): NodeMaterialConnectionPoint;
  142537. /**
  142538. * Gets the right operand input component
  142539. */
  142540. get right(): NodeMaterialConnectionPoint;
  142541. /**
  142542. * Gets the output component
  142543. */
  142544. get output(): NodeMaterialConnectionPoint;
  142545. protected _buildBlock(state: NodeMaterialBuildState): this;
  142546. }
  142547. }
  142548. declare module BABYLON {
  142549. /**
  142550. * Block used to normalize a vector
  142551. */
  142552. export class NormalizeBlock extends NodeMaterialBlock {
  142553. /**
  142554. * Creates a new NormalizeBlock
  142555. * @param name defines the block name
  142556. */
  142557. constructor(name: string);
  142558. /**
  142559. * Gets the current class name
  142560. * @returns the class name
  142561. */
  142562. getClassName(): string;
  142563. /**
  142564. * Gets the input component
  142565. */
  142566. get input(): NodeMaterialConnectionPoint;
  142567. /**
  142568. * Gets the output component
  142569. */
  142570. get output(): NodeMaterialConnectionPoint;
  142571. protected _buildBlock(state: NodeMaterialBuildState): this;
  142572. }
  142573. }
  142574. declare module BABYLON {
  142575. /**
  142576. * Operations supported by the Trigonometry block
  142577. */
  142578. export enum TrigonometryBlockOperations {
  142579. /** Cos */
  142580. Cos = 0,
  142581. /** Sin */
  142582. Sin = 1,
  142583. /** Abs */
  142584. Abs = 2,
  142585. /** Exp */
  142586. Exp = 3,
  142587. /** Exp2 */
  142588. Exp2 = 4,
  142589. /** Round */
  142590. Round = 5,
  142591. /** Floor */
  142592. Floor = 6,
  142593. /** Ceiling */
  142594. Ceiling = 7,
  142595. /** Square root */
  142596. Sqrt = 8,
  142597. /** Log */
  142598. Log = 9,
  142599. /** Tangent */
  142600. Tan = 10,
  142601. /** Arc tangent */
  142602. ArcTan = 11,
  142603. /** Arc cosinus */
  142604. ArcCos = 12,
  142605. /** Arc sinus */
  142606. ArcSin = 13,
  142607. /** Fraction */
  142608. Fract = 14,
  142609. /** Sign */
  142610. Sign = 15,
  142611. /** To radians (from degrees) */
  142612. Radians = 16,
  142613. /** To degrees (from radians) */
  142614. Degrees = 17
  142615. }
  142616. /**
  142617. * Block used to apply trigonometry operation to floats
  142618. */
  142619. export class TrigonometryBlock extends NodeMaterialBlock {
  142620. /**
  142621. * Gets or sets the operation applied by the block
  142622. */
  142623. operation: TrigonometryBlockOperations;
  142624. /**
  142625. * Creates a new TrigonometryBlock
  142626. * @param name defines the block name
  142627. */
  142628. constructor(name: string);
  142629. /**
  142630. * Gets the current class name
  142631. * @returns the class name
  142632. */
  142633. getClassName(): string;
  142634. /**
  142635. * Gets the input component
  142636. */
  142637. get input(): NodeMaterialConnectionPoint;
  142638. /**
  142639. * Gets the output component
  142640. */
  142641. get output(): NodeMaterialConnectionPoint;
  142642. protected _buildBlock(state: NodeMaterialBuildState): this;
  142643. serialize(): any;
  142644. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142645. protected _dumpPropertiesCode(): string;
  142646. }
  142647. }
  142648. declare module BABYLON {
  142649. /**
  142650. * Block used to create a Color3/4 out of individual inputs (one for each component)
  142651. */
  142652. export class ColorMergerBlock extends NodeMaterialBlock {
  142653. /**
  142654. * Create a new ColorMergerBlock
  142655. * @param name defines the block name
  142656. */
  142657. constructor(name: string);
  142658. /**
  142659. * Gets the current class name
  142660. * @returns the class name
  142661. */
  142662. getClassName(): string;
  142663. /**
  142664. * Gets the rgb component (input)
  142665. */
  142666. get rgbIn(): NodeMaterialConnectionPoint;
  142667. /**
  142668. * Gets the r component (input)
  142669. */
  142670. get r(): NodeMaterialConnectionPoint;
  142671. /**
  142672. * Gets the g component (input)
  142673. */
  142674. get g(): NodeMaterialConnectionPoint;
  142675. /**
  142676. * Gets the b component (input)
  142677. */
  142678. get b(): NodeMaterialConnectionPoint;
  142679. /**
  142680. * Gets the a component (input)
  142681. */
  142682. get a(): NodeMaterialConnectionPoint;
  142683. /**
  142684. * Gets the rgba component (output)
  142685. */
  142686. get rgba(): NodeMaterialConnectionPoint;
  142687. /**
  142688. * Gets the rgb component (output)
  142689. */
  142690. get rgbOut(): NodeMaterialConnectionPoint;
  142691. /**
  142692. * Gets the rgb component (output)
  142693. * @deprecated Please use rgbOut instead.
  142694. */
  142695. get rgb(): NodeMaterialConnectionPoint;
  142696. protected _buildBlock(state: NodeMaterialBuildState): this;
  142697. }
  142698. }
  142699. declare module BABYLON {
  142700. /**
  142701. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  142702. */
  142703. export class VectorSplitterBlock extends NodeMaterialBlock {
  142704. /**
  142705. * Create a new VectorSplitterBlock
  142706. * @param name defines the block name
  142707. */
  142708. constructor(name: string);
  142709. /**
  142710. * Gets the current class name
  142711. * @returns the class name
  142712. */
  142713. getClassName(): string;
  142714. /**
  142715. * Gets the xyzw component (input)
  142716. */
  142717. get xyzw(): NodeMaterialConnectionPoint;
  142718. /**
  142719. * Gets the xyz component (input)
  142720. */
  142721. get xyzIn(): NodeMaterialConnectionPoint;
  142722. /**
  142723. * Gets the xy component (input)
  142724. */
  142725. get xyIn(): NodeMaterialConnectionPoint;
  142726. /**
  142727. * Gets the xyz component (output)
  142728. */
  142729. get xyzOut(): NodeMaterialConnectionPoint;
  142730. /**
  142731. * Gets the xy component (output)
  142732. */
  142733. get xyOut(): NodeMaterialConnectionPoint;
  142734. /**
  142735. * Gets the x component (output)
  142736. */
  142737. get x(): NodeMaterialConnectionPoint;
  142738. /**
  142739. * Gets the y component (output)
  142740. */
  142741. get y(): NodeMaterialConnectionPoint;
  142742. /**
  142743. * Gets the z component (output)
  142744. */
  142745. get z(): NodeMaterialConnectionPoint;
  142746. /**
  142747. * Gets the w component (output)
  142748. */
  142749. get w(): NodeMaterialConnectionPoint;
  142750. protected _inputRename(name: string): string;
  142751. protected _outputRename(name: string): string;
  142752. protected _buildBlock(state: NodeMaterialBuildState): this;
  142753. }
  142754. }
  142755. declare module BABYLON {
  142756. /**
  142757. * Block used to lerp between 2 values
  142758. */
  142759. export class LerpBlock extends NodeMaterialBlock {
  142760. /**
  142761. * Creates a new LerpBlock
  142762. * @param name defines the block name
  142763. */
  142764. constructor(name: string);
  142765. /**
  142766. * Gets the current class name
  142767. * @returns the class name
  142768. */
  142769. getClassName(): string;
  142770. /**
  142771. * Gets the left operand input component
  142772. */
  142773. get left(): NodeMaterialConnectionPoint;
  142774. /**
  142775. * Gets the right operand input component
  142776. */
  142777. get right(): NodeMaterialConnectionPoint;
  142778. /**
  142779. * Gets the gradient operand input component
  142780. */
  142781. get gradient(): NodeMaterialConnectionPoint;
  142782. /**
  142783. * Gets the output component
  142784. */
  142785. get output(): NodeMaterialConnectionPoint;
  142786. protected _buildBlock(state: NodeMaterialBuildState): this;
  142787. }
  142788. }
  142789. declare module BABYLON {
  142790. /**
  142791. * Block used to divide 2 vectors
  142792. */
  142793. export class DivideBlock extends NodeMaterialBlock {
  142794. /**
  142795. * Creates a new DivideBlock
  142796. * @param name defines the block name
  142797. */
  142798. constructor(name: string);
  142799. /**
  142800. * Gets the current class name
  142801. * @returns the class name
  142802. */
  142803. getClassName(): string;
  142804. /**
  142805. * Gets the left operand input component
  142806. */
  142807. get left(): NodeMaterialConnectionPoint;
  142808. /**
  142809. * Gets the right operand input component
  142810. */
  142811. get right(): NodeMaterialConnectionPoint;
  142812. /**
  142813. * Gets the output component
  142814. */
  142815. get output(): NodeMaterialConnectionPoint;
  142816. protected _buildBlock(state: NodeMaterialBuildState): this;
  142817. }
  142818. }
  142819. declare module BABYLON {
  142820. /**
  142821. * Block used to subtract 2 vectors
  142822. */
  142823. export class SubtractBlock extends NodeMaterialBlock {
  142824. /**
  142825. * Creates a new SubtractBlock
  142826. * @param name defines the block name
  142827. */
  142828. constructor(name: string);
  142829. /**
  142830. * Gets the current class name
  142831. * @returns the class name
  142832. */
  142833. getClassName(): string;
  142834. /**
  142835. * Gets the left operand input component
  142836. */
  142837. get left(): NodeMaterialConnectionPoint;
  142838. /**
  142839. * Gets the right operand input component
  142840. */
  142841. get right(): NodeMaterialConnectionPoint;
  142842. /**
  142843. * Gets the output component
  142844. */
  142845. get output(): NodeMaterialConnectionPoint;
  142846. protected _buildBlock(state: NodeMaterialBuildState): this;
  142847. }
  142848. }
  142849. declare module BABYLON {
  142850. /**
  142851. * Block used to step a value
  142852. */
  142853. export class StepBlock extends NodeMaterialBlock {
  142854. /**
  142855. * Creates a new StepBlock
  142856. * @param name defines the block name
  142857. */
  142858. constructor(name: string);
  142859. /**
  142860. * Gets the current class name
  142861. * @returns the class name
  142862. */
  142863. getClassName(): string;
  142864. /**
  142865. * Gets the value operand input component
  142866. */
  142867. get value(): NodeMaterialConnectionPoint;
  142868. /**
  142869. * Gets the edge operand input component
  142870. */
  142871. get edge(): NodeMaterialConnectionPoint;
  142872. /**
  142873. * Gets the output component
  142874. */
  142875. get output(): NodeMaterialConnectionPoint;
  142876. protected _buildBlock(state: NodeMaterialBuildState): this;
  142877. }
  142878. }
  142879. declare module BABYLON {
  142880. /**
  142881. * Block used to get the opposite (1 - x) of a value
  142882. */
  142883. export class OneMinusBlock extends NodeMaterialBlock {
  142884. /**
  142885. * Creates a new OneMinusBlock
  142886. * @param name defines the block name
  142887. */
  142888. constructor(name: string);
  142889. /**
  142890. * Gets the current class name
  142891. * @returns the class name
  142892. */
  142893. getClassName(): string;
  142894. /**
  142895. * Gets the input component
  142896. */
  142897. get input(): NodeMaterialConnectionPoint;
  142898. /**
  142899. * Gets the output component
  142900. */
  142901. get output(): NodeMaterialConnectionPoint;
  142902. protected _buildBlock(state: NodeMaterialBuildState): this;
  142903. }
  142904. }
  142905. declare module BABYLON {
  142906. /**
  142907. * Block used to get the view direction
  142908. */
  142909. export class ViewDirectionBlock extends NodeMaterialBlock {
  142910. /**
  142911. * Creates a new ViewDirectionBlock
  142912. * @param name defines the block name
  142913. */
  142914. constructor(name: string);
  142915. /**
  142916. * Gets the current class name
  142917. * @returns the class name
  142918. */
  142919. getClassName(): string;
  142920. /**
  142921. * Gets the world position component
  142922. */
  142923. get worldPosition(): NodeMaterialConnectionPoint;
  142924. /**
  142925. * Gets the camera position component
  142926. */
  142927. get cameraPosition(): NodeMaterialConnectionPoint;
  142928. /**
  142929. * Gets the output component
  142930. */
  142931. get output(): NodeMaterialConnectionPoint;
  142932. autoConfigure(material: NodeMaterial): void;
  142933. protected _buildBlock(state: NodeMaterialBuildState): this;
  142934. }
  142935. }
  142936. declare module BABYLON {
  142937. /**
  142938. * Block used to compute fresnel value
  142939. */
  142940. export class FresnelBlock extends NodeMaterialBlock {
  142941. /**
  142942. * Create a new FresnelBlock
  142943. * @param name defines the block name
  142944. */
  142945. constructor(name: string);
  142946. /**
  142947. * Gets the current class name
  142948. * @returns the class name
  142949. */
  142950. getClassName(): string;
  142951. /**
  142952. * Gets the world normal input component
  142953. */
  142954. get worldNormal(): NodeMaterialConnectionPoint;
  142955. /**
  142956. * Gets the view direction input component
  142957. */
  142958. get viewDirection(): NodeMaterialConnectionPoint;
  142959. /**
  142960. * Gets the bias input component
  142961. */
  142962. get bias(): NodeMaterialConnectionPoint;
  142963. /**
  142964. * Gets the camera (or eye) position component
  142965. */
  142966. get power(): NodeMaterialConnectionPoint;
  142967. /**
  142968. * Gets the fresnel output component
  142969. */
  142970. get fresnel(): NodeMaterialConnectionPoint;
  142971. autoConfigure(material: NodeMaterial): void;
  142972. protected _buildBlock(state: NodeMaterialBuildState): this;
  142973. }
  142974. }
  142975. declare module BABYLON {
  142976. /**
  142977. * Block used to get the max of 2 values
  142978. */
  142979. export class MaxBlock extends NodeMaterialBlock {
  142980. /**
  142981. * Creates a new MaxBlock
  142982. * @param name defines the block name
  142983. */
  142984. constructor(name: string);
  142985. /**
  142986. * Gets the current class name
  142987. * @returns the class name
  142988. */
  142989. getClassName(): string;
  142990. /**
  142991. * Gets the left operand input component
  142992. */
  142993. get left(): NodeMaterialConnectionPoint;
  142994. /**
  142995. * Gets the right operand input component
  142996. */
  142997. get right(): NodeMaterialConnectionPoint;
  142998. /**
  142999. * Gets the output component
  143000. */
  143001. get output(): NodeMaterialConnectionPoint;
  143002. protected _buildBlock(state: NodeMaterialBuildState): this;
  143003. }
  143004. }
  143005. declare module BABYLON {
  143006. /**
  143007. * Block used to get the min of 2 values
  143008. */
  143009. export class MinBlock extends NodeMaterialBlock {
  143010. /**
  143011. * Creates a new MinBlock
  143012. * @param name defines the block name
  143013. */
  143014. constructor(name: string);
  143015. /**
  143016. * Gets the current class name
  143017. * @returns the class name
  143018. */
  143019. getClassName(): string;
  143020. /**
  143021. * Gets the left operand input component
  143022. */
  143023. get left(): NodeMaterialConnectionPoint;
  143024. /**
  143025. * Gets the right operand input component
  143026. */
  143027. get right(): NodeMaterialConnectionPoint;
  143028. /**
  143029. * Gets the output component
  143030. */
  143031. get output(): NodeMaterialConnectionPoint;
  143032. protected _buildBlock(state: NodeMaterialBuildState): this;
  143033. }
  143034. }
  143035. declare module BABYLON {
  143036. /**
  143037. * Block used to get the distance between 2 values
  143038. */
  143039. export class DistanceBlock extends NodeMaterialBlock {
  143040. /**
  143041. * Creates a new DistanceBlock
  143042. * @param name defines the block name
  143043. */
  143044. constructor(name: string);
  143045. /**
  143046. * Gets the current class name
  143047. * @returns the class name
  143048. */
  143049. getClassName(): string;
  143050. /**
  143051. * Gets the left operand input component
  143052. */
  143053. get left(): NodeMaterialConnectionPoint;
  143054. /**
  143055. * Gets the right operand input component
  143056. */
  143057. get right(): NodeMaterialConnectionPoint;
  143058. /**
  143059. * Gets the output component
  143060. */
  143061. get output(): NodeMaterialConnectionPoint;
  143062. protected _buildBlock(state: NodeMaterialBuildState): this;
  143063. }
  143064. }
  143065. declare module BABYLON {
  143066. /**
  143067. * Block used to get the length of a vector
  143068. */
  143069. export class LengthBlock extends NodeMaterialBlock {
  143070. /**
  143071. * Creates a new LengthBlock
  143072. * @param name defines the block name
  143073. */
  143074. constructor(name: string);
  143075. /**
  143076. * Gets the current class name
  143077. * @returns the class name
  143078. */
  143079. getClassName(): string;
  143080. /**
  143081. * Gets the value input component
  143082. */
  143083. get value(): NodeMaterialConnectionPoint;
  143084. /**
  143085. * Gets the output component
  143086. */
  143087. get output(): NodeMaterialConnectionPoint;
  143088. protected _buildBlock(state: NodeMaterialBuildState): this;
  143089. }
  143090. }
  143091. declare module BABYLON {
  143092. /**
  143093. * Block used to get negative version of a value (i.e. x * -1)
  143094. */
  143095. export class NegateBlock extends NodeMaterialBlock {
  143096. /**
  143097. * Creates a new NegateBlock
  143098. * @param name defines the block name
  143099. */
  143100. constructor(name: string);
  143101. /**
  143102. * Gets the current class name
  143103. * @returns the class name
  143104. */
  143105. getClassName(): string;
  143106. /**
  143107. * Gets the value input component
  143108. */
  143109. get value(): NodeMaterialConnectionPoint;
  143110. /**
  143111. * Gets the output component
  143112. */
  143113. get output(): NodeMaterialConnectionPoint;
  143114. protected _buildBlock(state: NodeMaterialBuildState): this;
  143115. }
  143116. }
  143117. declare module BABYLON {
  143118. /**
  143119. * Block used to get the value of the first parameter raised to the power of the second
  143120. */
  143121. export class PowBlock extends NodeMaterialBlock {
  143122. /**
  143123. * Creates a new PowBlock
  143124. * @param name defines the block name
  143125. */
  143126. constructor(name: string);
  143127. /**
  143128. * Gets the current class name
  143129. * @returns the class name
  143130. */
  143131. getClassName(): string;
  143132. /**
  143133. * Gets the value operand input component
  143134. */
  143135. get value(): NodeMaterialConnectionPoint;
  143136. /**
  143137. * Gets the power operand input component
  143138. */
  143139. get power(): NodeMaterialConnectionPoint;
  143140. /**
  143141. * Gets the output component
  143142. */
  143143. get output(): NodeMaterialConnectionPoint;
  143144. protected _buildBlock(state: NodeMaterialBuildState): this;
  143145. }
  143146. }
  143147. declare module BABYLON {
  143148. /**
  143149. * Block used to get a random number
  143150. */
  143151. export class RandomNumberBlock extends NodeMaterialBlock {
  143152. /**
  143153. * Creates a new RandomNumberBlock
  143154. * @param name defines the block name
  143155. */
  143156. constructor(name: string);
  143157. /**
  143158. * Gets the current class name
  143159. * @returns the class name
  143160. */
  143161. getClassName(): string;
  143162. /**
  143163. * Gets the seed input component
  143164. */
  143165. get seed(): NodeMaterialConnectionPoint;
  143166. /**
  143167. * Gets the output component
  143168. */
  143169. get output(): NodeMaterialConnectionPoint;
  143170. protected _buildBlock(state: NodeMaterialBuildState): this;
  143171. }
  143172. }
  143173. declare module BABYLON {
  143174. /**
  143175. * Block used to compute arc tangent of 2 values
  143176. */
  143177. export class ArcTan2Block extends NodeMaterialBlock {
  143178. /**
  143179. * Creates a new ArcTan2Block
  143180. * @param name defines the block name
  143181. */
  143182. constructor(name: string);
  143183. /**
  143184. * Gets the current class name
  143185. * @returns the class name
  143186. */
  143187. getClassName(): string;
  143188. /**
  143189. * Gets the x operand input component
  143190. */
  143191. get x(): NodeMaterialConnectionPoint;
  143192. /**
  143193. * Gets the y operand input component
  143194. */
  143195. get y(): NodeMaterialConnectionPoint;
  143196. /**
  143197. * Gets the output component
  143198. */
  143199. get output(): NodeMaterialConnectionPoint;
  143200. protected _buildBlock(state: NodeMaterialBuildState): this;
  143201. }
  143202. }
  143203. declare module BABYLON {
  143204. /**
  143205. * Block used to smooth step a value
  143206. */
  143207. export class SmoothStepBlock extends NodeMaterialBlock {
  143208. /**
  143209. * Creates a new SmoothStepBlock
  143210. * @param name defines the block name
  143211. */
  143212. constructor(name: string);
  143213. /**
  143214. * Gets the current class name
  143215. * @returns the class name
  143216. */
  143217. getClassName(): string;
  143218. /**
  143219. * Gets the value operand input component
  143220. */
  143221. get value(): NodeMaterialConnectionPoint;
  143222. /**
  143223. * Gets the first edge operand input component
  143224. */
  143225. get edge0(): NodeMaterialConnectionPoint;
  143226. /**
  143227. * Gets the second edge operand input component
  143228. */
  143229. get edge1(): NodeMaterialConnectionPoint;
  143230. /**
  143231. * Gets the output component
  143232. */
  143233. get output(): NodeMaterialConnectionPoint;
  143234. protected _buildBlock(state: NodeMaterialBuildState): this;
  143235. }
  143236. }
  143237. declare module BABYLON {
  143238. /**
  143239. * Block used to get the reciprocal (1 / x) of a value
  143240. */
  143241. export class ReciprocalBlock extends NodeMaterialBlock {
  143242. /**
  143243. * Creates a new ReciprocalBlock
  143244. * @param name defines the block name
  143245. */
  143246. constructor(name: string);
  143247. /**
  143248. * Gets the current class name
  143249. * @returns the class name
  143250. */
  143251. getClassName(): string;
  143252. /**
  143253. * Gets the input component
  143254. */
  143255. get input(): NodeMaterialConnectionPoint;
  143256. /**
  143257. * Gets the output component
  143258. */
  143259. get output(): NodeMaterialConnectionPoint;
  143260. protected _buildBlock(state: NodeMaterialBuildState): this;
  143261. }
  143262. }
  143263. declare module BABYLON {
  143264. /**
  143265. * Block used to replace a color by another one
  143266. */
  143267. export class ReplaceColorBlock extends NodeMaterialBlock {
  143268. /**
  143269. * Creates a new ReplaceColorBlock
  143270. * @param name defines the block name
  143271. */
  143272. constructor(name: string);
  143273. /**
  143274. * Gets the current class name
  143275. * @returns the class name
  143276. */
  143277. getClassName(): string;
  143278. /**
  143279. * Gets the value input component
  143280. */
  143281. get value(): NodeMaterialConnectionPoint;
  143282. /**
  143283. * Gets the reference input component
  143284. */
  143285. get reference(): NodeMaterialConnectionPoint;
  143286. /**
  143287. * Gets the distance input component
  143288. */
  143289. get distance(): NodeMaterialConnectionPoint;
  143290. /**
  143291. * Gets the replacement input component
  143292. */
  143293. get replacement(): NodeMaterialConnectionPoint;
  143294. /**
  143295. * Gets the output component
  143296. */
  143297. get output(): NodeMaterialConnectionPoint;
  143298. protected _buildBlock(state: NodeMaterialBuildState): this;
  143299. }
  143300. }
  143301. declare module BABYLON {
  143302. /**
  143303. * Block used to posterize a value
  143304. * @see https://en.wikipedia.org/wiki/Posterization
  143305. */
  143306. export class PosterizeBlock extends NodeMaterialBlock {
  143307. /**
  143308. * Creates a new PosterizeBlock
  143309. * @param name defines the block name
  143310. */
  143311. constructor(name: string);
  143312. /**
  143313. * Gets the current class name
  143314. * @returns the class name
  143315. */
  143316. getClassName(): string;
  143317. /**
  143318. * Gets the value input component
  143319. */
  143320. get value(): NodeMaterialConnectionPoint;
  143321. /**
  143322. * Gets the steps input component
  143323. */
  143324. get steps(): NodeMaterialConnectionPoint;
  143325. /**
  143326. * Gets the output component
  143327. */
  143328. get output(): NodeMaterialConnectionPoint;
  143329. protected _buildBlock(state: NodeMaterialBuildState): this;
  143330. }
  143331. }
  143332. declare module BABYLON {
  143333. /**
  143334. * Operations supported by the Wave block
  143335. */
  143336. export enum WaveBlockKind {
  143337. /** SawTooth */
  143338. SawTooth = 0,
  143339. /** Square */
  143340. Square = 1,
  143341. /** Triangle */
  143342. Triangle = 2
  143343. }
  143344. /**
  143345. * Block used to apply wave operation to floats
  143346. */
  143347. export class WaveBlock extends NodeMaterialBlock {
  143348. /**
  143349. * Gets or sets the kibnd of wave to be applied by the block
  143350. */
  143351. kind: WaveBlockKind;
  143352. /**
  143353. * Creates a new WaveBlock
  143354. * @param name defines the block name
  143355. */
  143356. constructor(name: string);
  143357. /**
  143358. * Gets the current class name
  143359. * @returns the class name
  143360. */
  143361. getClassName(): string;
  143362. /**
  143363. * Gets the input component
  143364. */
  143365. get input(): NodeMaterialConnectionPoint;
  143366. /**
  143367. * Gets the output component
  143368. */
  143369. get output(): NodeMaterialConnectionPoint;
  143370. protected _buildBlock(state: NodeMaterialBuildState): this;
  143371. serialize(): any;
  143372. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143373. }
  143374. }
  143375. declare module BABYLON {
  143376. /**
  143377. * Class used to store a color step for the GradientBlock
  143378. */
  143379. export class GradientBlockColorStep {
  143380. /**
  143381. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  143382. */
  143383. step: number;
  143384. /**
  143385. * Gets or sets the color associated with this step
  143386. */
  143387. color: Color3;
  143388. /**
  143389. * Creates a new GradientBlockColorStep
  143390. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  143391. * @param color defines the color associated with this step
  143392. */
  143393. constructor(
  143394. /**
  143395. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  143396. */
  143397. step: number,
  143398. /**
  143399. * Gets or sets the color associated with this step
  143400. */
  143401. color: Color3);
  143402. }
  143403. /**
  143404. * Block used to return a color from a gradient based on an input value between 0 and 1
  143405. */
  143406. export class GradientBlock extends NodeMaterialBlock {
  143407. /**
  143408. * Gets or sets the list of color steps
  143409. */
  143410. colorSteps: GradientBlockColorStep[];
  143411. /**
  143412. * Creates a new GradientBlock
  143413. * @param name defines the block name
  143414. */
  143415. constructor(name: string);
  143416. /**
  143417. * Gets the current class name
  143418. * @returns the class name
  143419. */
  143420. getClassName(): string;
  143421. /**
  143422. * Gets the gradient input component
  143423. */
  143424. get gradient(): NodeMaterialConnectionPoint;
  143425. /**
  143426. * Gets the output component
  143427. */
  143428. get output(): NodeMaterialConnectionPoint;
  143429. private _writeColorConstant;
  143430. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143431. serialize(): any;
  143432. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143433. protected _dumpPropertiesCode(): string;
  143434. }
  143435. }
  143436. declare module BABYLON {
  143437. /**
  143438. * Block used to normalize lerp between 2 values
  143439. */
  143440. export class NLerpBlock extends NodeMaterialBlock {
  143441. /**
  143442. * Creates a new NLerpBlock
  143443. * @param name defines the block name
  143444. */
  143445. constructor(name: string);
  143446. /**
  143447. * Gets the current class name
  143448. * @returns the class name
  143449. */
  143450. getClassName(): string;
  143451. /**
  143452. * Gets the left operand input component
  143453. */
  143454. get left(): NodeMaterialConnectionPoint;
  143455. /**
  143456. * Gets the right operand input component
  143457. */
  143458. get right(): NodeMaterialConnectionPoint;
  143459. /**
  143460. * Gets the gradient operand input component
  143461. */
  143462. get gradient(): NodeMaterialConnectionPoint;
  143463. /**
  143464. * Gets the output component
  143465. */
  143466. get output(): NodeMaterialConnectionPoint;
  143467. protected _buildBlock(state: NodeMaterialBuildState): this;
  143468. }
  143469. }
  143470. declare module BABYLON {
  143471. /**
  143472. * block used to Generate a Worley Noise 3D Noise Pattern
  143473. */
  143474. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  143475. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143476. manhattanDistance: boolean;
  143477. /**
  143478. * Creates a new WorleyNoise3DBlock
  143479. * @param name defines the block name
  143480. */
  143481. constructor(name: string);
  143482. /**
  143483. * Gets the current class name
  143484. * @returns the class name
  143485. */
  143486. getClassName(): string;
  143487. /**
  143488. * Gets the seed input component
  143489. */
  143490. get seed(): NodeMaterialConnectionPoint;
  143491. /**
  143492. * Gets the jitter input component
  143493. */
  143494. get jitter(): NodeMaterialConnectionPoint;
  143495. /**
  143496. * Gets the output component
  143497. */
  143498. get output(): NodeMaterialConnectionPoint;
  143499. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143500. /**
  143501. * Exposes the properties to the UI?
  143502. */
  143503. protected _dumpPropertiesCode(): string;
  143504. /**
  143505. * Exposes the properties to the Seralize?
  143506. */
  143507. serialize(): any;
  143508. /**
  143509. * Exposes the properties to the deseralize?
  143510. */
  143511. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143512. }
  143513. }
  143514. declare module BABYLON {
  143515. /**
  143516. * block used to Generate a Simplex Perlin 3d Noise Pattern
  143517. */
  143518. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  143519. /**
  143520. * Creates a new SimplexPerlin3DBlock
  143521. * @param name defines the block name
  143522. */
  143523. constructor(name: string);
  143524. /**
  143525. * Gets the current class name
  143526. * @returns the class name
  143527. */
  143528. getClassName(): string;
  143529. /**
  143530. * Gets the seed operand input component
  143531. */
  143532. get seed(): NodeMaterialConnectionPoint;
  143533. /**
  143534. * Gets the output component
  143535. */
  143536. get output(): NodeMaterialConnectionPoint;
  143537. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143538. }
  143539. }
  143540. declare module BABYLON {
  143541. /**
  143542. * Block used to blend normals
  143543. */
  143544. export class NormalBlendBlock extends NodeMaterialBlock {
  143545. /**
  143546. * Creates a new NormalBlendBlock
  143547. * @param name defines the block name
  143548. */
  143549. constructor(name: string);
  143550. /**
  143551. * Gets the current class name
  143552. * @returns the class name
  143553. */
  143554. getClassName(): string;
  143555. /**
  143556. * Gets the first input component
  143557. */
  143558. get normalMap0(): NodeMaterialConnectionPoint;
  143559. /**
  143560. * Gets the second input component
  143561. */
  143562. get normalMap1(): NodeMaterialConnectionPoint;
  143563. /**
  143564. * Gets the output component
  143565. */
  143566. get output(): NodeMaterialConnectionPoint;
  143567. protected _buildBlock(state: NodeMaterialBuildState): this;
  143568. }
  143569. }
  143570. declare module BABYLON {
  143571. /**
  143572. * Block used to rotate a 2d vector by a given angle
  143573. */
  143574. export class Rotate2dBlock extends NodeMaterialBlock {
  143575. /**
  143576. * Creates a new Rotate2dBlock
  143577. * @param name defines the block name
  143578. */
  143579. constructor(name: string);
  143580. /**
  143581. * Gets the current class name
  143582. * @returns the class name
  143583. */
  143584. getClassName(): string;
  143585. /**
  143586. * Gets the input vector
  143587. */
  143588. get input(): NodeMaterialConnectionPoint;
  143589. /**
  143590. * Gets the input angle
  143591. */
  143592. get angle(): NodeMaterialConnectionPoint;
  143593. /**
  143594. * Gets the output component
  143595. */
  143596. get output(): NodeMaterialConnectionPoint;
  143597. autoConfigure(material: NodeMaterial): void;
  143598. protected _buildBlock(state: NodeMaterialBuildState): this;
  143599. }
  143600. }
  143601. declare module BABYLON {
  143602. /**
  143603. * Block used to get the reflected vector from a direction and a normal
  143604. */
  143605. export class ReflectBlock extends NodeMaterialBlock {
  143606. /**
  143607. * Creates a new ReflectBlock
  143608. * @param name defines the block name
  143609. */
  143610. constructor(name: string);
  143611. /**
  143612. * Gets the current class name
  143613. * @returns the class name
  143614. */
  143615. getClassName(): string;
  143616. /**
  143617. * Gets the incident component
  143618. */
  143619. get incident(): NodeMaterialConnectionPoint;
  143620. /**
  143621. * Gets the normal component
  143622. */
  143623. get normal(): NodeMaterialConnectionPoint;
  143624. /**
  143625. * Gets the output component
  143626. */
  143627. get output(): NodeMaterialConnectionPoint;
  143628. protected _buildBlock(state: NodeMaterialBuildState): this;
  143629. }
  143630. }
  143631. declare module BABYLON {
  143632. /**
  143633. * Block used to get the refracted vector from a direction and a normal
  143634. */
  143635. export class RefractBlock extends NodeMaterialBlock {
  143636. /**
  143637. * Creates a new RefractBlock
  143638. * @param name defines the block name
  143639. */
  143640. constructor(name: string);
  143641. /**
  143642. * Gets the current class name
  143643. * @returns the class name
  143644. */
  143645. getClassName(): string;
  143646. /**
  143647. * Gets the incident component
  143648. */
  143649. get incident(): NodeMaterialConnectionPoint;
  143650. /**
  143651. * Gets the normal component
  143652. */
  143653. get normal(): NodeMaterialConnectionPoint;
  143654. /**
  143655. * Gets the index of refraction component
  143656. */
  143657. get ior(): NodeMaterialConnectionPoint;
  143658. /**
  143659. * Gets the output component
  143660. */
  143661. get output(): NodeMaterialConnectionPoint;
  143662. protected _buildBlock(state: NodeMaterialBuildState): this;
  143663. }
  143664. }
  143665. declare module BABYLON {
  143666. /**
  143667. * Block used to desaturate a color
  143668. */
  143669. export class DesaturateBlock extends NodeMaterialBlock {
  143670. /**
  143671. * Creates a new DesaturateBlock
  143672. * @param name defines the block name
  143673. */
  143674. constructor(name: string);
  143675. /**
  143676. * Gets the current class name
  143677. * @returns the class name
  143678. */
  143679. getClassName(): string;
  143680. /**
  143681. * Gets the color operand input component
  143682. */
  143683. get color(): NodeMaterialConnectionPoint;
  143684. /**
  143685. * Gets the level operand input component
  143686. */
  143687. get level(): NodeMaterialConnectionPoint;
  143688. /**
  143689. * Gets the output component
  143690. */
  143691. get output(): NodeMaterialConnectionPoint;
  143692. protected _buildBlock(state: NodeMaterialBuildState): this;
  143693. }
  143694. }
  143695. declare module BABYLON {
  143696. /**
  143697. * Block used to implement the ambient occlusion module of the PBR material
  143698. */
  143699. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  143700. /**
  143701. * Create a new AmbientOcclusionBlock
  143702. * @param name defines the block name
  143703. */
  143704. constructor(name: string);
  143705. /**
  143706. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  143707. */
  143708. useAmbientInGrayScale: boolean;
  143709. /**
  143710. * Initialize the block and prepare the context for build
  143711. * @param state defines the state that will be used for the build
  143712. */
  143713. initialize(state: NodeMaterialBuildState): void;
  143714. /**
  143715. * Gets the current class name
  143716. * @returns the class name
  143717. */
  143718. getClassName(): string;
  143719. /**
  143720. * Gets the texture input component
  143721. */
  143722. get texture(): NodeMaterialConnectionPoint;
  143723. /**
  143724. * Gets the texture intensity component
  143725. */
  143726. get intensity(): NodeMaterialConnectionPoint;
  143727. /**
  143728. * Gets the direct light intensity input component
  143729. */
  143730. get directLightIntensity(): NodeMaterialConnectionPoint;
  143731. /**
  143732. * Gets the ambient occlusion object output component
  143733. */
  143734. get ambientOcclusion(): NodeMaterialConnectionPoint;
  143735. /**
  143736. * Gets the main code of the block (fragment side)
  143737. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  143738. * @returns the shader code
  143739. */
  143740. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  143741. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143742. protected _buildBlock(state: NodeMaterialBuildState): this;
  143743. protected _dumpPropertiesCode(): string;
  143744. serialize(): any;
  143745. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143746. }
  143747. }
  143748. declare module BABYLON {
  143749. /**
  143750. * Block used to implement the reflection module of the PBR material
  143751. */
  143752. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  143753. /** @hidden */
  143754. _defineLODReflectionAlpha: string;
  143755. /** @hidden */
  143756. _defineLinearSpecularReflection: string;
  143757. private _vEnvironmentIrradianceName;
  143758. /** @hidden */
  143759. _vReflectionMicrosurfaceInfosName: string;
  143760. /** @hidden */
  143761. _vReflectionInfosName: string;
  143762. /** @hidden */
  143763. _vReflectionFilteringInfoName: string;
  143764. private _scene;
  143765. /**
  143766. * The three properties below are set by the main PBR block prior to calling methods of this class.
  143767. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  143768. * It's less burden on the user side in the editor part.
  143769. */
  143770. /** @hidden */
  143771. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  143772. /** @hidden */
  143773. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  143774. /** @hidden */
  143775. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  143776. /**
  143777. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  143778. * diffuse part of the IBL.
  143779. */
  143780. useSphericalHarmonics: boolean;
  143781. /**
  143782. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  143783. */
  143784. forceIrradianceInFragment: boolean;
  143785. /**
  143786. * Create a new ReflectionBlock
  143787. * @param name defines the block name
  143788. */
  143789. constructor(name: string);
  143790. /**
  143791. * Gets the current class name
  143792. * @returns the class name
  143793. */
  143794. getClassName(): string;
  143795. /**
  143796. * Gets the position input component
  143797. */
  143798. get position(): NodeMaterialConnectionPoint;
  143799. /**
  143800. * Gets the world position input component
  143801. */
  143802. get worldPosition(): NodeMaterialConnectionPoint;
  143803. /**
  143804. * Gets the world normal input component
  143805. */
  143806. get worldNormal(): NodeMaterialConnectionPoint;
  143807. /**
  143808. * Gets the world input component
  143809. */
  143810. get world(): NodeMaterialConnectionPoint;
  143811. /**
  143812. * Gets the camera (or eye) position component
  143813. */
  143814. get cameraPosition(): NodeMaterialConnectionPoint;
  143815. /**
  143816. * Gets the view input component
  143817. */
  143818. get view(): NodeMaterialConnectionPoint;
  143819. /**
  143820. * Gets the color input component
  143821. */
  143822. get color(): NodeMaterialConnectionPoint;
  143823. /**
  143824. * Gets the reflection object output component
  143825. */
  143826. get reflection(): NodeMaterialConnectionPoint;
  143827. /**
  143828. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  143829. */
  143830. get hasTexture(): boolean;
  143831. /**
  143832. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  143833. */
  143834. get reflectionColor(): string;
  143835. protected _getTexture(): Nullable<BaseTexture>;
  143836. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143837. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143838. /**
  143839. * Gets the code to inject in the vertex shader
  143840. * @param state current state of the node material building
  143841. * @returns the shader code
  143842. */
  143843. handleVertexSide(state: NodeMaterialBuildState): string;
  143844. /**
  143845. * Gets the main code of the block (fragment side)
  143846. * @param state current state of the node material building
  143847. * @param normalVarName name of the existing variable corresponding to the normal
  143848. * @returns the shader code
  143849. */
  143850. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  143851. protected _buildBlock(state: NodeMaterialBuildState): this;
  143852. protected _dumpPropertiesCode(): string;
  143853. serialize(): any;
  143854. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143855. }
  143856. }
  143857. declare module BABYLON {
  143858. /**
  143859. * Block used to implement the sheen module of the PBR material
  143860. */
  143861. export class SheenBlock extends NodeMaterialBlock {
  143862. /**
  143863. * Create a new SheenBlock
  143864. * @param name defines the block name
  143865. */
  143866. constructor(name: string);
  143867. /**
  143868. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  143869. * It allows the strength of the sheen effect to not depend on the base color of the material,
  143870. * making it easier to setup and tweak the effect
  143871. */
  143872. albedoScaling: boolean;
  143873. /**
  143874. * Defines if the sheen is linked to the sheen color.
  143875. */
  143876. linkSheenWithAlbedo: boolean;
  143877. /**
  143878. * Initialize the block and prepare the context for build
  143879. * @param state defines the state that will be used for the build
  143880. */
  143881. initialize(state: NodeMaterialBuildState): void;
  143882. /**
  143883. * Gets the current class name
  143884. * @returns the class name
  143885. */
  143886. getClassName(): string;
  143887. /**
  143888. * Gets the intensity input component
  143889. */
  143890. get intensity(): NodeMaterialConnectionPoint;
  143891. /**
  143892. * Gets the color input component
  143893. */
  143894. get color(): NodeMaterialConnectionPoint;
  143895. /**
  143896. * Gets the roughness input component
  143897. */
  143898. get roughness(): NodeMaterialConnectionPoint;
  143899. /**
  143900. * Gets the sheen object output component
  143901. */
  143902. get sheen(): NodeMaterialConnectionPoint;
  143903. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143904. /**
  143905. * Gets the main code of the block (fragment side)
  143906. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143907. * @returns the shader code
  143908. */
  143909. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  143910. protected _buildBlock(state: NodeMaterialBuildState): this;
  143911. protected _dumpPropertiesCode(): string;
  143912. serialize(): any;
  143913. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143914. }
  143915. }
  143916. declare module BABYLON {
  143917. /**
  143918. * Block used to implement the reflectivity module of the PBR material
  143919. */
  143920. export class ReflectivityBlock extends NodeMaterialBlock {
  143921. private _metallicReflectanceColor;
  143922. private _metallicF0Factor;
  143923. /** @hidden */
  143924. _vMetallicReflectanceFactorsName: string;
  143925. /**
  143926. * The property below is set by the main PBR block prior to calling methods of this class.
  143927. */
  143928. /** @hidden */
  143929. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  143930. /**
  143931. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  143932. */
  143933. useAmbientOcclusionFromMetallicTextureRed: boolean;
  143934. /**
  143935. * Specifies if the metallic texture contains the metallness information in its blue channel.
  143936. */
  143937. useMetallnessFromMetallicTextureBlue: boolean;
  143938. /**
  143939. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  143940. */
  143941. useRoughnessFromMetallicTextureAlpha: boolean;
  143942. /**
  143943. * Specifies if the metallic texture contains the roughness information in its green channel.
  143944. */
  143945. useRoughnessFromMetallicTextureGreen: boolean;
  143946. /**
  143947. * Create a new ReflectivityBlock
  143948. * @param name defines the block name
  143949. */
  143950. constructor(name: string);
  143951. /**
  143952. * Initialize the block and prepare the context for build
  143953. * @param state defines the state that will be used for the build
  143954. */
  143955. initialize(state: NodeMaterialBuildState): void;
  143956. /**
  143957. * Gets the current class name
  143958. * @returns the class name
  143959. */
  143960. getClassName(): string;
  143961. /**
  143962. * Gets the metallic input component
  143963. */
  143964. get metallic(): NodeMaterialConnectionPoint;
  143965. /**
  143966. * Gets the roughness input component
  143967. */
  143968. get roughness(): NodeMaterialConnectionPoint;
  143969. /**
  143970. * Gets the texture input component
  143971. */
  143972. get texture(): NodeMaterialConnectionPoint;
  143973. /**
  143974. * Gets the reflectivity object output component
  143975. */
  143976. get reflectivity(): NodeMaterialConnectionPoint;
  143977. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143978. /**
  143979. * Gets the main code of the block (fragment side)
  143980. * @param state current state of the node material building
  143981. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  143982. * @returns the shader code
  143983. */
  143984. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  143985. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143986. protected _buildBlock(state: NodeMaterialBuildState): this;
  143987. protected _dumpPropertiesCode(): string;
  143988. serialize(): any;
  143989. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143990. }
  143991. }
  143992. declare module BABYLON {
  143993. /**
  143994. * Block used to implement the anisotropy module of the PBR material
  143995. */
  143996. export class AnisotropyBlock extends NodeMaterialBlock {
  143997. /**
  143998. * The two properties below are set by the main PBR block prior to calling methods of this class.
  143999. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144000. * It's less burden on the user side in the editor part.
  144001. */
  144002. /** @hidden */
  144003. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144004. /** @hidden */
  144005. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144006. /**
  144007. * Create a new AnisotropyBlock
  144008. * @param name defines the block name
  144009. */
  144010. constructor(name: string);
  144011. /**
  144012. * Initialize the block and prepare the context for build
  144013. * @param state defines the state that will be used for the build
  144014. */
  144015. initialize(state: NodeMaterialBuildState): void;
  144016. /**
  144017. * Gets the current class name
  144018. * @returns the class name
  144019. */
  144020. getClassName(): string;
  144021. /**
  144022. * Gets the intensity input component
  144023. */
  144024. get intensity(): NodeMaterialConnectionPoint;
  144025. /**
  144026. * Gets the direction input component
  144027. */
  144028. get direction(): NodeMaterialConnectionPoint;
  144029. /**
  144030. * Gets the texture input component
  144031. */
  144032. get texture(): NodeMaterialConnectionPoint;
  144033. /**
  144034. * Gets the uv input component
  144035. */
  144036. get uv(): NodeMaterialConnectionPoint;
  144037. /**
  144038. * Gets the worldTangent input component
  144039. */
  144040. get worldTangent(): NodeMaterialConnectionPoint;
  144041. /**
  144042. * Gets the anisotropy object output component
  144043. */
  144044. get anisotropy(): NodeMaterialConnectionPoint;
  144045. private _generateTBNSpace;
  144046. /**
  144047. * Gets the main code of the block (fragment side)
  144048. * @param state current state of the node material building
  144049. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  144050. * @returns the shader code
  144051. */
  144052. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  144053. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144054. protected _buildBlock(state: NodeMaterialBuildState): this;
  144055. }
  144056. }
  144057. declare module BABYLON {
  144058. /**
  144059. * Block used to implement the clear coat module of the PBR material
  144060. */
  144061. export class ClearCoatBlock extends NodeMaterialBlock {
  144062. private _scene;
  144063. /**
  144064. * Create a new ClearCoatBlock
  144065. * @param name defines the block name
  144066. */
  144067. constructor(name: string);
  144068. /**
  144069. * Initialize the block and prepare the context for build
  144070. * @param state defines the state that will be used for the build
  144071. */
  144072. initialize(state: NodeMaterialBuildState): void;
  144073. /**
  144074. * Gets the current class name
  144075. * @returns the class name
  144076. */
  144077. getClassName(): string;
  144078. /**
  144079. * Gets the intensity input component
  144080. */
  144081. get intensity(): NodeMaterialConnectionPoint;
  144082. /**
  144083. * Gets the roughness input component
  144084. */
  144085. get roughness(): NodeMaterialConnectionPoint;
  144086. /**
  144087. * Gets the ior input component
  144088. */
  144089. get ior(): NodeMaterialConnectionPoint;
  144090. /**
  144091. * Gets the texture input component
  144092. */
  144093. get texture(): NodeMaterialConnectionPoint;
  144094. /**
  144095. * Gets the bump texture input component
  144096. */
  144097. get bumpTexture(): NodeMaterialConnectionPoint;
  144098. /**
  144099. * Gets the uv input component
  144100. */
  144101. get uv(): NodeMaterialConnectionPoint;
  144102. /**
  144103. * Gets the tint color input component
  144104. */
  144105. get tintColor(): NodeMaterialConnectionPoint;
  144106. /**
  144107. * Gets the tint "at distance" input component
  144108. */
  144109. get tintAtDistance(): NodeMaterialConnectionPoint;
  144110. /**
  144111. * Gets the tint thickness input component
  144112. */
  144113. get tintThickness(): NodeMaterialConnectionPoint;
  144114. /**
  144115. * Gets the world tangent input component
  144116. */
  144117. get worldTangent(): NodeMaterialConnectionPoint;
  144118. /**
  144119. * Gets the clear coat object output component
  144120. */
  144121. get clearcoat(): NodeMaterialConnectionPoint;
  144122. autoConfigure(material: NodeMaterial): void;
  144123. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144124. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144125. private _generateTBNSpace;
  144126. /**
  144127. * Gets the main code of the block (fragment side)
  144128. * @param state current state of the node material building
  144129. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  144130. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144131. * @param worldPosVarName name of the variable holding the world position
  144132. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  144133. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  144134. * @param worldNormalVarName name of the variable holding the world normal
  144135. * @returns the shader code
  144136. */
  144137. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  144138. protected _buildBlock(state: NodeMaterialBuildState): this;
  144139. }
  144140. }
  144141. declare module BABYLON {
  144142. /**
  144143. * Block used to implement the sub surface module of the PBR material
  144144. */
  144145. export class SubSurfaceBlock extends NodeMaterialBlock {
  144146. /**
  144147. * Create a new SubSurfaceBlock
  144148. * @param name defines the block name
  144149. */
  144150. constructor(name: string);
  144151. /**
  144152. * Stores the intensity of the different subsurface effects in the thickness texture.
  144153. * * the green channel is the translucency intensity.
  144154. * * the blue channel is the scattering intensity.
  144155. * * the alpha channel is the refraction intensity.
  144156. */
  144157. useMaskFromThicknessTexture: boolean;
  144158. /**
  144159. * Initialize the block and prepare the context for build
  144160. * @param state defines the state that will be used for the build
  144161. */
  144162. initialize(state: NodeMaterialBuildState): void;
  144163. /**
  144164. * Gets the current class name
  144165. * @returns the class name
  144166. */
  144167. getClassName(): string;
  144168. /**
  144169. * Gets the min thickness input component
  144170. */
  144171. get minThickness(): NodeMaterialConnectionPoint;
  144172. /**
  144173. * Gets the max thickness input component
  144174. */
  144175. get maxThickness(): NodeMaterialConnectionPoint;
  144176. /**
  144177. * Gets the thickness texture component
  144178. */
  144179. get thicknessTexture(): NodeMaterialConnectionPoint;
  144180. /**
  144181. * Gets the tint color input component
  144182. */
  144183. get tintColor(): NodeMaterialConnectionPoint;
  144184. /**
  144185. * Gets the translucency intensity input component
  144186. */
  144187. get translucencyIntensity(): NodeMaterialConnectionPoint;
  144188. /**
  144189. * Gets the translucency diffusion distance input component
  144190. */
  144191. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  144192. /**
  144193. * Gets the refraction object parameters
  144194. */
  144195. get refraction(): NodeMaterialConnectionPoint;
  144196. /**
  144197. * Gets the sub surface object output component
  144198. */
  144199. get subsurface(): NodeMaterialConnectionPoint;
  144200. autoConfigure(material: NodeMaterial): void;
  144201. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144202. /**
  144203. * Gets the main code of the block (fragment side)
  144204. * @param state current state of the node material building
  144205. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  144206. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144207. * @param worldPosVarName name of the variable holding the world position
  144208. * @returns the shader code
  144209. */
  144210. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  144211. protected _buildBlock(state: NodeMaterialBuildState): this;
  144212. }
  144213. }
  144214. declare module BABYLON {
  144215. /**
  144216. * Block used to implement the PBR metallic/roughness model
  144217. */
  144218. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  144219. /**
  144220. * Gets or sets the light associated with this block
  144221. */
  144222. light: Nullable<Light>;
  144223. private _lightId;
  144224. private _scene;
  144225. private _environmentBRDFTexture;
  144226. private _environmentBrdfSamplerName;
  144227. private _vNormalWName;
  144228. private _invertNormalName;
  144229. /**
  144230. * Create a new ReflectionBlock
  144231. * @param name defines the block name
  144232. */
  144233. constructor(name: string);
  144234. /**
  144235. * Intensity of the direct lights e.g. the four lights available in your scene.
  144236. * This impacts both the direct diffuse and specular highlights.
  144237. */
  144238. directIntensity: number;
  144239. /**
  144240. * Intensity of the environment e.g. how much the environment will light the object
  144241. * either through harmonics for rough material or through the refelction for shiny ones.
  144242. */
  144243. environmentIntensity: number;
  144244. /**
  144245. * This is a special control allowing the reduction of the specular highlights coming from the
  144246. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  144247. */
  144248. specularIntensity: number;
  144249. /**
  144250. * Defines the falloff type used in this material.
  144251. * It by default is Physical.
  144252. */
  144253. lightFalloff: number;
  144254. /**
  144255. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  144256. */
  144257. useAlphaFromAlbedoTexture: boolean;
  144258. /**
  144259. * Specifies that alpha test should be used
  144260. */
  144261. useAlphaTest: boolean;
  144262. /**
  144263. * Defines the alpha limits in alpha test mode.
  144264. */
  144265. alphaTestCutoff: number;
  144266. /**
  144267. * Specifies that alpha blending should be used
  144268. */
  144269. useAlphaBlending: boolean;
  144270. /**
  144271. * Defines if the alpha value should be determined via the rgb values.
  144272. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  144273. */
  144274. opacityRGB: boolean;
  144275. /**
  144276. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  144277. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  144278. */
  144279. useRadianceOverAlpha: boolean;
  144280. /**
  144281. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  144282. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  144283. */
  144284. useSpecularOverAlpha: boolean;
  144285. /**
  144286. * Enables specular anti aliasing in the PBR shader.
  144287. * It will both interacts on the Geometry for analytical and IBL lighting.
  144288. * It also prefilter the roughness map based on the bump values.
  144289. */
  144290. enableSpecularAntiAliasing: boolean;
  144291. /**
  144292. * Enables realtime filtering on the texture.
  144293. */
  144294. realTimeFiltering: boolean;
  144295. /**
  144296. * Quality switch for realtime filtering
  144297. */
  144298. realTimeFilteringQuality: number;
  144299. /**
  144300. * Defines if the material uses energy conservation.
  144301. */
  144302. useEnergyConservation: boolean;
  144303. /**
  144304. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  144305. * too much the area relying on ambient texture to define their ambient occlusion.
  144306. */
  144307. useRadianceOcclusion: boolean;
  144308. /**
  144309. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  144310. * makes the reflect vector face the model (under horizon).
  144311. */
  144312. useHorizonOcclusion: boolean;
  144313. /**
  144314. * If set to true, no lighting calculations will be applied.
  144315. */
  144316. unlit: boolean;
  144317. /**
  144318. * Force normal to face away from face.
  144319. */
  144320. forceNormalForward: boolean;
  144321. /**
  144322. * Defines the material debug mode.
  144323. * It helps seeing only some components of the material while troubleshooting.
  144324. */
  144325. debugMode: number;
  144326. /**
  144327. * Specify from where on screen the debug mode should start.
  144328. * The value goes from -1 (full screen) to 1 (not visible)
  144329. * It helps with side by side comparison against the final render
  144330. * This defaults to 0
  144331. */
  144332. debugLimit: number;
  144333. /**
  144334. * As the default viewing range might not be enough (if the ambient is really small for instance)
  144335. * You can use the factor to better multiply the final value.
  144336. */
  144337. debugFactor: number;
  144338. /**
  144339. * Initialize the block and prepare the context for build
  144340. * @param state defines the state that will be used for the build
  144341. */
  144342. initialize(state: NodeMaterialBuildState): void;
  144343. /**
  144344. * Gets the current class name
  144345. * @returns the class name
  144346. */
  144347. getClassName(): string;
  144348. /**
  144349. * Gets the world position input component
  144350. */
  144351. get worldPosition(): NodeMaterialConnectionPoint;
  144352. /**
  144353. * Gets the world normal input component
  144354. */
  144355. get worldNormal(): NodeMaterialConnectionPoint;
  144356. /**
  144357. * Gets the perturbed normal input component
  144358. */
  144359. get perturbedNormal(): NodeMaterialConnectionPoint;
  144360. /**
  144361. * Gets the camera position input component
  144362. */
  144363. get cameraPosition(): NodeMaterialConnectionPoint;
  144364. /**
  144365. * Gets the base color input component
  144366. */
  144367. get baseColor(): NodeMaterialConnectionPoint;
  144368. /**
  144369. * Gets the opacity texture input component
  144370. */
  144371. get opacityTexture(): NodeMaterialConnectionPoint;
  144372. /**
  144373. * Gets the ambient color input component
  144374. */
  144375. get ambientColor(): NodeMaterialConnectionPoint;
  144376. /**
  144377. * Gets the reflectivity object parameters
  144378. */
  144379. get reflectivity(): NodeMaterialConnectionPoint;
  144380. /**
  144381. * Gets the ambient occlusion object parameters
  144382. */
  144383. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144384. /**
  144385. * Gets the reflection object parameters
  144386. */
  144387. get reflection(): NodeMaterialConnectionPoint;
  144388. /**
  144389. * Gets the sheen object parameters
  144390. */
  144391. get sheen(): NodeMaterialConnectionPoint;
  144392. /**
  144393. * Gets the clear coat object parameters
  144394. */
  144395. get clearcoat(): NodeMaterialConnectionPoint;
  144396. /**
  144397. * Gets the sub surface object parameters
  144398. */
  144399. get subsurface(): NodeMaterialConnectionPoint;
  144400. /**
  144401. * Gets the anisotropy object parameters
  144402. */
  144403. get anisotropy(): NodeMaterialConnectionPoint;
  144404. /**
  144405. * Gets the ambient output component
  144406. */
  144407. get ambient(): NodeMaterialConnectionPoint;
  144408. /**
  144409. * Gets the diffuse output component
  144410. */
  144411. get diffuse(): NodeMaterialConnectionPoint;
  144412. /**
  144413. * Gets the specular output component
  144414. */
  144415. get specular(): NodeMaterialConnectionPoint;
  144416. /**
  144417. * Gets the sheen output component
  144418. */
  144419. get sheenDir(): NodeMaterialConnectionPoint;
  144420. /**
  144421. * Gets the clear coat output component
  144422. */
  144423. get clearcoatDir(): NodeMaterialConnectionPoint;
  144424. /**
  144425. * Gets the indirect diffuse output component
  144426. */
  144427. get diffuseIndirect(): NodeMaterialConnectionPoint;
  144428. /**
  144429. * Gets the indirect specular output component
  144430. */
  144431. get specularIndirect(): NodeMaterialConnectionPoint;
  144432. /**
  144433. * Gets the indirect sheen output component
  144434. */
  144435. get sheenIndirect(): NodeMaterialConnectionPoint;
  144436. /**
  144437. * Gets the indirect clear coat output component
  144438. */
  144439. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  144440. /**
  144441. * Gets the refraction output component
  144442. */
  144443. get refraction(): NodeMaterialConnectionPoint;
  144444. /**
  144445. * Gets the global lighting output component
  144446. */
  144447. get lighting(): NodeMaterialConnectionPoint;
  144448. /**
  144449. * Gets the shadow output component
  144450. */
  144451. get shadow(): NodeMaterialConnectionPoint;
  144452. /**
  144453. * Gets the alpha output component
  144454. */
  144455. get alpha(): NodeMaterialConnectionPoint;
  144456. autoConfigure(material: NodeMaterial): void;
  144457. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144458. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  144459. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144460. private _injectVertexCode;
  144461. /**
  144462. * Gets the code corresponding to the albedo/opacity module
  144463. * @returns the shader code
  144464. */
  144465. getAlbedoOpacityCode(): string;
  144466. protected _buildBlock(state: NodeMaterialBuildState): this;
  144467. protected _dumpPropertiesCode(): string;
  144468. serialize(): any;
  144469. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144470. }
  144471. }
  144472. declare module BABYLON {
  144473. /**
  144474. * Block used to compute value of one parameter modulo another
  144475. */
  144476. export class ModBlock extends NodeMaterialBlock {
  144477. /**
  144478. * Creates a new ModBlock
  144479. * @param name defines the block name
  144480. */
  144481. constructor(name: string);
  144482. /**
  144483. * Gets the current class name
  144484. * @returns the class name
  144485. */
  144486. getClassName(): string;
  144487. /**
  144488. * Gets the left operand input component
  144489. */
  144490. get left(): NodeMaterialConnectionPoint;
  144491. /**
  144492. * Gets the right operand input component
  144493. */
  144494. get right(): NodeMaterialConnectionPoint;
  144495. /**
  144496. * Gets the output component
  144497. */
  144498. get output(): NodeMaterialConnectionPoint;
  144499. protected _buildBlock(state: NodeMaterialBuildState): this;
  144500. }
  144501. }
  144502. declare module BABYLON {
  144503. /**
  144504. * Helper class to push actions to a pool of workers.
  144505. */
  144506. export class WorkerPool implements IDisposable {
  144507. private _workerInfos;
  144508. private _pendingActions;
  144509. /**
  144510. * Constructor
  144511. * @param workers Array of workers to use for actions
  144512. */
  144513. constructor(workers: Array<Worker>);
  144514. /**
  144515. * Terminates all workers and clears any pending actions.
  144516. */
  144517. dispose(): void;
  144518. /**
  144519. * Pushes an action to the worker pool. If all the workers are active, the action will be
  144520. * pended until a worker has completed its action.
  144521. * @param action The action to perform. Call onComplete when the action is complete.
  144522. */
  144523. push(action: (worker: Worker, onComplete: () => void) => void): void;
  144524. private _execute;
  144525. }
  144526. }
  144527. declare module BABYLON {
  144528. /**
  144529. * Configuration for Draco compression
  144530. */
  144531. export interface IDracoCompressionConfiguration {
  144532. /**
  144533. * Configuration for the decoder.
  144534. */
  144535. decoder: {
  144536. /**
  144537. * The url to the WebAssembly module.
  144538. */
  144539. wasmUrl?: string;
  144540. /**
  144541. * The url to the WebAssembly binary.
  144542. */
  144543. wasmBinaryUrl?: string;
  144544. /**
  144545. * The url to the fallback JavaScript module.
  144546. */
  144547. fallbackUrl?: string;
  144548. };
  144549. }
  144550. /**
  144551. * Draco compression (https://google.github.io/draco/)
  144552. *
  144553. * This class wraps the Draco module.
  144554. *
  144555. * **Encoder**
  144556. *
  144557. * The encoder is not currently implemented.
  144558. *
  144559. * **Decoder**
  144560. *
  144561. * 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.
  144562. *
  144563. * To update the configuration, use the following code:
  144564. * ```javascript
  144565. * DracoCompression.Configuration = {
  144566. * decoder: {
  144567. * wasmUrl: "<url to the WebAssembly library>",
  144568. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  144569. * fallbackUrl: "<url to the fallback JavaScript library>",
  144570. * }
  144571. * };
  144572. * ```
  144573. *
  144574. * 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.
  144575. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  144576. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  144577. *
  144578. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  144579. * ```javascript
  144580. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  144581. * ```
  144582. *
  144583. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  144584. */
  144585. export class DracoCompression implements IDisposable {
  144586. private _workerPoolPromise?;
  144587. private _decoderModulePromise?;
  144588. /**
  144589. * The configuration. Defaults to the following urls:
  144590. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  144591. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  144592. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  144593. */
  144594. static Configuration: IDracoCompressionConfiguration;
  144595. /**
  144596. * Returns true if the decoder configuration is available.
  144597. */
  144598. static get DecoderAvailable(): boolean;
  144599. /**
  144600. * Default number of workers to create when creating the draco compression object.
  144601. */
  144602. static DefaultNumWorkers: number;
  144603. private static GetDefaultNumWorkers;
  144604. private static _Default;
  144605. /**
  144606. * Default instance for the draco compression object.
  144607. */
  144608. static get Default(): DracoCompression;
  144609. /**
  144610. * Constructor
  144611. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  144612. */
  144613. constructor(numWorkers?: number);
  144614. /**
  144615. * Stop all async operations and release resources.
  144616. */
  144617. dispose(): void;
  144618. /**
  144619. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  144620. * @returns a promise that resolves when ready
  144621. */
  144622. whenReadyAsync(): Promise<void>;
  144623. /**
  144624. * Decode Draco compressed mesh data to vertex data.
  144625. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  144626. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  144627. * @returns A promise that resolves with the decoded vertex data
  144628. */
  144629. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  144630. [kind: string]: number;
  144631. }): Promise<VertexData>;
  144632. }
  144633. }
  144634. declare module BABYLON {
  144635. /**
  144636. * Class for building Constructive Solid Geometry
  144637. */
  144638. export class CSG {
  144639. private polygons;
  144640. /**
  144641. * The world matrix
  144642. */
  144643. matrix: Matrix;
  144644. /**
  144645. * Stores the position
  144646. */
  144647. position: Vector3;
  144648. /**
  144649. * Stores the rotation
  144650. */
  144651. rotation: Vector3;
  144652. /**
  144653. * Stores the rotation quaternion
  144654. */
  144655. rotationQuaternion: Nullable<Quaternion>;
  144656. /**
  144657. * Stores the scaling vector
  144658. */
  144659. scaling: Vector3;
  144660. /**
  144661. * Convert the Mesh to CSG
  144662. * @param mesh The Mesh to convert to CSG
  144663. * @returns A new CSG from the Mesh
  144664. */
  144665. static FromMesh(mesh: Mesh): CSG;
  144666. /**
  144667. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  144668. * @param polygons Polygons used to construct a CSG solid
  144669. */
  144670. private static FromPolygons;
  144671. /**
  144672. * Clones, or makes a deep copy, of the CSG
  144673. * @returns A new CSG
  144674. */
  144675. clone(): CSG;
  144676. /**
  144677. * Unions this CSG with another CSG
  144678. * @param csg The CSG to union against this CSG
  144679. * @returns The unioned CSG
  144680. */
  144681. union(csg: CSG): CSG;
  144682. /**
  144683. * Unions this CSG with another CSG in place
  144684. * @param csg The CSG to union against this CSG
  144685. */
  144686. unionInPlace(csg: CSG): void;
  144687. /**
  144688. * Subtracts this CSG with another CSG
  144689. * @param csg The CSG to subtract against this CSG
  144690. * @returns A new CSG
  144691. */
  144692. subtract(csg: CSG): CSG;
  144693. /**
  144694. * Subtracts this CSG with another CSG in place
  144695. * @param csg The CSG to subtact against this CSG
  144696. */
  144697. subtractInPlace(csg: CSG): void;
  144698. /**
  144699. * Intersect this CSG with another CSG
  144700. * @param csg The CSG to intersect against this CSG
  144701. * @returns A new CSG
  144702. */
  144703. intersect(csg: CSG): CSG;
  144704. /**
  144705. * Intersects this CSG with another CSG in place
  144706. * @param csg The CSG to intersect against this CSG
  144707. */
  144708. intersectInPlace(csg: CSG): void;
  144709. /**
  144710. * Return a new CSG solid with solid and empty space switched. This solid is
  144711. * not modified.
  144712. * @returns A new CSG solid with solid and empty space switched
  144713. */
  144714. inverse(): CSG;
  144715. /**
  144716. * Inverses the CSG in place
  144717. */
  144718. inverseInPlace(): void;
  144719. /**
  144720. * This is used to keep meshes transformations so they can be restored
  144721. * when we build back a Babylon Mesh
  144722. * NB : All CSG operations are performed in world coordinates
  144723. * @param csg The CSG to copy the transform attributes from
  144724. * @returns This CSG
  144725. */
  144726. copyTransformAttributes(csg: CSG): CSG;
  144727. /**
  144728. * Build Raw mesh from CSG
  144729. * Coordinates here are in world space
  144730. * @param name The name of the mesh geometry
  144731. * @param scene The Scene
  144732. * @param keepSubMeshes Specifies if the submeshes should be kept
  144733. * @returns A new Mesh
  144734. */
  144735. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  144736. /**
  144737. * Build Mesh from CSG taking material and transforms into account
  144738. * @param name The name of the Mesh
  144739. * @param material The material of the Mesh
  144740. * @param scene The Scene
  144741. * @param keepSubMeshes Specifies if submeshes should be kept
  144742. * @returns The new Mesh
  144743. */
  144744. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  144745. }
  144746. }
  144747. declare module BABYLON {
  144748. /**
  144749. * Class used to create a trail following a mesh
  144750. */
  144751. export class TrailMesh extends Mesh {
  144752. private _generator;
  144753. private _autoStart;
  144754. private _running;
  144755. private _diameter;
  144756. private _length;
  144757. private _sectionPolygonPointsCount;
  144758. private _sectionVectors;
  144759. private _sectionNormalVectors;
  144760. private _beforeRenderObserver;
  144761. /**
  144762. * @constructor
  144763. * @param name The value used by scene.getMeshByName() to do a lookup.
  144764. * @param generator The mesh or transform node to generate a trail.
  144765. * @param scene The scene to add this mesh to.
  144766. * @param diameter Diameter of trailing mesh. Default is 1.
  144767. * @param length Length of trailing mesh. Default is 60.
  144768. * @param autoStart Automatically start trailing mesh. Default true.
  144769. */
  144770. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  144771. /**
  144772. * "TrailMesh"
  144773. * @returns "TrailMesh"
  144774. */
  144775. getClassName(): string;
  144776. private _createMesh;
  144777. /**
  144778. * Start trailing mesh.
  144779. */
  144780. start(): void;
  144781. /**
  144782. * Stop trailing mesh.
  144783. */
  144784. stop(): void;
  144785. /**
  144786. * Update trailing mesh geometry.
  144787. */
  144788. update(): void;
  144789. /**
  144790. * Returns a new TrailMesh object.
  144791. * @param name is a string, the name given to the new mesh
  144792. * @param newGenerator use new generator object for cloned trail mesh
  144793. * @returns a new mesh
  144794. */
  144795. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  144796. /**
  144797. * Serializes this trail mesh
  144798. * @param serializationObject object to write serialization to
  144799. */
  144800. serialize(serializationObject: any): void;
  144801. /**
  144802. * Parses a serialized trail mesh
  144803. * @param parsedMesh the serialized mesh
  144804. * @param scene the scene to create the trail mesh in
  144805. * @returns the created trail mesh
  144806. */
  144807. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  144808. }
  144809. }
  144810. declare module BABYLON {
  144811. /**
  144812. * Class containing static functions to help procedurally build meshes
  144813. */
  144814. export class TiledBoxBuilder {
  144815. /**
  144816. * Creates a box mesh
  144817. * 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)
  144818. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144820. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144822. * @param name defines the name of the mesh
  144823. * @param options defines the options used to create the mesh
  144824. * @param scene defines the hosting scene
  144825. * @returns the box mesh
  144826. */
  144827. static CreateTiledBox(name: string, options: {
  144828. pattern?: number;
  144829. width?: number;
  144830. height?: number;
  144831. depth?: number;
  144832. tileSize?: number;
  144833. tileWidth?: number;
  144834. tileHeight?: number;
  144835. alignHorizontal?: number;
  144836. alignVertical?: number;
  144837. faceUV?: Vector4[];
  144838. faceColors?: Color4[];
  144839. sideOrientation?: number;
  144840. updatable?: boolean;
  144841. }, scene?: Nullable<Scene>): Mesh;
  144842. }
  144843. }
  144844. declare module BABYLON {
  144845. /**
  144846. * Class containing static functions to help procedurally build meshes
  144847. */
  144848. export class TorusKnotBuilder {
  144849. /**
  144850. * Creates a torus knot mesh
  144851. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  144852. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  144853. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  144854. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  144855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144858. * @param name defines the name of the mesh
  144859. * @param options defines the options used to create the mesh
  144860. * @param scene defines the hosting scene
  144861. * @returns the torus knot mesh
  144862. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  144863. */
  144864. static CreateTorusKnot(name: string, options: {
  144865. radius?: number;
  144866. tube?: number;
  144867. radialSegments?: number;
  144868. tubularSegments?: number;
  144869. p?: number;
  144870. q?: number;
  144871. updatable?: boolean;
  144872. sideOrientation?: number;
  144873. frontUVs?: Vector4;
  144874. backUVs?: Vector4;
  144875. }, scene: any): Mesh;
  144876. }
  144877. }
  144878. declare module BABYLON {
  144879. /**
  144880. * Polygon
  144881. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  144882. */
  144883. export class Polygon {
  144884. /**
  144885. * Creates a rectangle
  144886. * @param xmin bottom X coord
  144887. * @param ymin bottom Y coord
  144888. * @param xmax top X coord
  144889. * @param ymax top Y coord
  144890. * @returns points that make the resulting rectation
  144891. */
  144892. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  144893. /**
  144894. * Creates a circle
  144895. * @param radius radius of circle
  144896. * @param cx scale in x
  144897. * @param cy scale in y
  144898. * @param numberOfSides number of sides that make up the circle
  144899. * @returns points that make the resulting circle
  144900. */
  144901. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  144902. /**
  144903. * Creates a polygon from input string
  144904. * @param input Input polygon data
  144905. * @returns the parsed points
  144906. */
  144907. static Parse(input: string): Vector2[];
  144908. /**
  144909. * Starts building a polygon from x and y coordinates
  144910. * @param x x coordinate
  144911. * @param y y coordinate
  144912. * @returns the started path2
  144913. */
  144914. static StartingAt(x: number, y: number): Path2;
  144915. }
  144916. /**
  144917. * Builds a polygon
  144918. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  144919. */
  144920. export class PolygonMeshBuilder {
  144921. private _points;
  144922. private _outlinepoints;
  144923. private _holes;
  144924. private _name;
  144925. private _scene;
  144926. private _epoints;
  144927. private _eholes;
  144928. private _addToepoint;
  144929. /**
  144930. * Babylon reference to the earcut plugin.
  144931. */
  144932. bjsEarcut: any;
  144933. /**
  144934. * Creates a PolygonMeshBuilder
  144935. * @param name name of the builder
  144936. * @param contours Path of the polygon
  144937. * @param scene scene to add to when creating the mesh
  144938. * @param earcutInjection can be used to inject your own earcut reference
  144939. */
  144940. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  144941. /**
  144942. * Adds a whole within the polygon
  144943. * @param hole Array of points defining the hole
  144944. * @returns this
  144945. */
  144946. addHole(hole: Vector2[]): PolygonMeshBuilder;
  144947. /**
  144948. * Creates the polygon
  144949. * @param updatable If the mesh should be updatable
  144950. * @param depth The depth of the mesh created
  144951. * @returns the created mesh
  144952. */
  144953. build(updatable?: boolean, depth?: number): Mesh;
  144954. /**
  144955. * Creates the polygon
  144956. * @param depth The depth of the mesh created
  144957. * @returns the created VertexData
  144958. */
  144959. buildVertexData(depth?: number): VertexData;
  144960. /**
  144961. * Adds a side to the polygon
  144962. * @param positions points that make the polygon
  144963. * @param normals normals of the polygon
  144964. * @param uvs uvs of the polygon
  144965. * @param indices indices of the polygon
  144966. * @param bounds bounds of the polygon
  144967. * @param points points of the polygon
  144968. * @param depth depth of the polygon
  144969. * @param flip flip of the polygon
  144970. */
  144971. private addSide;
  144972. }
  144973. }
  144974. declare module BABYLON {
  144975. /**
  144976. * Class containing static functions to help procedurally build meshes
  144977. */
  144978. export class PolygonBuilder {
  144979. /**
  144980. * Creates a polygon mesh
  144981. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  144982. * * 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
  144983. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144985. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  144986. * * Remember you can only change the shape positions, not their number when updating a polygon
  144987. * @param name defines the name of the mesh
  144988. * @param options defines the options used to create the mesh
  144989. * @param scene defines the hosting scene
  144990. * @param earcutInjection can be used to inject your own earcut reference
  144991. * @returns the polygon mesh
  144992. */
  144993. static CreatePolygon(name: string, options: {
  144994. shape: Vector3[];
  144995. holes?: Vector3[][];
  144996. depth?: number;
  144997. faceUV?: Vector4[];
  144998. faceColors?: Color4[];
  144999. updatable?: boolean;
  145000. sideOrientation?: number;
  145001. frontUVs?: Vector4;
  145002. backUVs?: Vector4;
  145003. wrap?: boolean;
  145004. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145005. /**
  145006. * Creates an extruded polygon mesh, with depth in the Y direction.
  145007. * * 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)
  145008. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145009. * @param name defines the name of the mesh
  145010. * @param options defines the options used to create the mesh
  145011. * @param scene defines the hosting scene
  145012. * @param earcutInjection can be used to inject your own earcut reference
  145013. * @returns the polygon mesh
  145014. */
  145015. static ExtrudePolygon(name: string, options: {
  145016. shape: Vector3[];
  145017. holes?: Vector3[][];
  145018. depth?: number;
  145019. faceUV?: Vector4[];
  145020. faceColors?: Color4[];
  145021. updatable?: boolean;
  145022. sideOrientation?: number;
  145023. frontUVs?: Vector4;
  145024. backUVs?: Vector4;
  145025. wrap?: boolean;
  145026. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145027. }
  145028. }
  145029. declare module BABYLON {
  145030. /**
  145031. * Class containing static functions to help procedurally build meshes
  145032. */
  145033. export class LatheBuilder {
  145034. /**
  145035. * Creates lathe mesh.
  145036. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145037. * * 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
  145038. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145039. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145040. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145041. * * 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
  145042. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145043. * * 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
  145044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145045. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145046. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145048. * @param name defines the name of the mesh
  145049. * @param options defines the options used to create the mesh
  145050. * @param scene defines the hosting scene
  145051. * @returns the lathe mesh
  145052. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145053. */
  145054. static CreateLathe(name: string, options: {
  145055. shape: Vector3[];
  145056. radius?: number;
  145057. tessellation?: number;
  145058. clip?: number;
  145059. arc?: number;
  145060. closed?: boolean;
  145061. updatable?: boolean;
  145062. sideOrientation?: number;
  145063. frontUVs?: Vector4;
  145064. backUVs?: Vector4;
  145065. cap?: number;
  145066. invertUV?: boolean;
  145067. }, scene?: Nullable<Scene>): Mesh;
  145068. }
  145069. }
  145070. declare module BABYLON {
  145071. /**
  145072. * Class containing static functions to help procedurally build meshes
  145073. */
  145074. export class TiledPlaneBuilder {
  145075. /**
  145076. * Creates a tiled plane mesh
  145077. * * The parameter `pattern` will, depending on value, do nothing or
  145078. * * * flip (reflect about central vertical) alternate tiles across and up
  145079. * * * flip every tile on alternate rows
  145080. * * * rotate (180 degs) alternate tiles across and up
  145081. * * * rotate every tile on alternate rows
  145082. * * * flip and rotate alternate tiles across and up
  145083. * * * flip and rotate every tile on alternate rows
  145084. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  145085. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  145086. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145087. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145088. * * 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)
  145089. * * 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)
  145090. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  145091. * @param name defines the name of the mesh
  145092. * @param options defines the options used to create the mesh
  145093. * @param scene defines the hosting scene
  145094. * @returns the box mesh
  145095. */
  145096. static CreateTiledPlane(name: string, options: {
  145097. pattern?: number;
  145098. tileSize?: number;
  145099. tileWidth?: number;
  145100. tileHeight?: number;
  145101. size?: number;
  145102. width?: number;
  145103. height?: number;
  145104. alignHorizontal?: number;
  145105. alignVertical?: number;
  145106. sideOrientation?: number;
  145107. frontUVs?: Vector4;
  145108. backUVs?: Vector4;
  145109. updatable?: boolean;
  145110. }, scene?: Nullable<Scene>): Mesh;
  145111. }
  145112. }
  145113. declare module BABYLON {
  145114. /**
  145115. * Class containing static functions to help procedurally build meshes
  145116. */
  145117. export class TubeBuilder {
  145118. /**
  145119. * Creates a tube mesh.
  145120. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145121. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  145122. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  145123. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  145124. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  145125. * * 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)
  145126. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  145127. * * 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
  145128. * * 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
  145129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145130. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145131. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145133. * @param name defines the name of the mesh
  145134. * @param options defines the options used to create the mesh
  145135. * @param scene defines the hosting scene
  145136. * @returns the tube mesh
  145137. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145138. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  145139. */
  145140. static CreateTube(name: string, options: {
  145141. path: Vector3[];
  145142. radius?: number;
  145143. tessellation?: number;
  145144. radiusFunction?: {
  145145. (i: number, distance: number): number;
  145146. };
  145147. cap?: number;
  145148. arc?: number;
  145149. updatable?: boolean;
  145150. sideOrientation?: number;
  145151. frontUVs?: Vector4;
  145152. backUVs?: Vector4;
  145153. instance?: Mesh;
  145154. invertUV?: boolean;
  145155. }, scene?: Nullable<Scene>): Mesh;
  145156. }
  145157. }
  145158. declare module BABYLON {
  145159. /**
  145160. * Class containing static functions to help procedurally build meshes
  145161. */
  145162. export class IcoSphereBuilder {
  145163. /**
  145164. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  145165. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  145166. * * 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`)
  145167. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  145168. * * 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
  145169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145170. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 icosahedron mesh
  145176. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  145177. */
  145178. static CreateIcoSphere(name: string, options: {
  145179. radius?: number;
  145180. radiusX?: number;
  145181. radiusY?: number;
  145182. radiusZ?: number;
  145183. flat?: boolean;
  145184. subdivisions?: number;
  145185. sideOrientation?: number;
  145186. frontUVs?: Vector4;
  145187. backUVs?: Vector4;
  145188. updatable?: boolean;
  145189. }, scene?: Nullable<Scene>): Mesh;
  145190. }
  145191. }
  145192. declare module BABYLON {
  145193. /**
  145194. * Class containing static functions to help procedurally build meshes
  145195. */
  145196. export class DecalBuilder {
  145197. /**
  145198. * Creates a decal mesh.
  145199. * 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
  145200. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  145201. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  145202. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  145203. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  145204. * @param name defines the name of the mesh
  145205. * @param sourceMesh defines the mesh where the decal must be applied
  145206. * @param options defines the options used to create the mesh
  145207. * @param scene defines the hosting scene
  145208. * @returns the decal mesh
  145209. * @see https://doc.babylonjs.com/how_to/decals
  145210. */
  145211. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  145212. position?: Vector3;
  145213. normal?: Vector3;
  145214. size?: Vector3;
  145215. angle?: number;
  145216. }): Mesh;
  145217. }
  145218. }
  145219. declare module BABYLON {
  145220. /**
  145221. * Class containing static functions to help procedurally build meshes
  145222. */
  145223. export class MeshBuilder {
  145224. /**
  145225. * Creates a box mesh
  145226. * * The parameter `size` sets the size (float) of each box side (default 1)
  145227. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  145228. * * 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)
  145229. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145233. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  145234. * @param name defines the name of the mesh
  145235. * @param options defines the options used to create the mesh
  145236. * @param scene defines the hosting scene
  145237. * @returns the box mesh
  145238. */
  145239. static CreateBox(name: string, options: {
  145240. size?: number;
  145241. width?: number;
  145242. height?: number;
  145243. depth?: number;
  145244. faceUV?: Vector4[];
  145245. faceColors?: Color4[];
  145246. sideOrientation?: number;
  145247. frontUVs?: Vector4;
  145248. backUVs?: Vector4;
  145249. wrap?: boolean;
  145250. topBaseAt?: number;
  145251. bottomBaseAt?: number;
  145252. updatable?: boolean;
  145253. }, scene?: Nullable<Scene>): Mesh;
  145254. /**
  145255. * Creates a tiled box mesh
  145256. * * faceTiles sets the pattern, tile size and number of tiles for a face
  145257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145258. * @param name defines the name of the mesh
  145259. * @param options defines the options used to create the mesh
  145260. * @param scene defines the hosting scene
  145261. * @returns the tiled box mesh
  145262. */
  145263. static CreateTiledBox(name: string, options: {
  145264. pattern?: number;
  145265. size?: number;
  145266. width?: number;
  145267. height?: number;
  145268. depth: number;
  145269. tileSize?: number;
  145270. tileWidth?: number;
  145271. tileHeight?: number;
  145272. faceUV?: Vector4[];
  145273. faceColors?: Color4[];
  145274. alignHorizontal?: number;
  145275. alignVertical?: number;
  145276. sideOrientation?: number;
  145277. updatable?: boolean;
  145278. }, scene?: Nullable<Scene>): Mesh;
  145279. /**
  145280. * Creates a sphere mesh
  145281. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  145282. * * 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`)
  145283. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  145284. * * 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
  145285. * * 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)
  145286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145289. * @param name defines the name of the mesh
  145290. * @param options defines the options used to create the mesh
  145291. * @param scene defines the hosting scene
  145292. * @returns the sphere mesh
  145293. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  145294. */
  145295. static CreateSphere(name: string, options: {
  145296. segments?: number;
  145297. diameter?: number;
  145298. diameterX?: number;
  145299. diameterY?: number;
  145300. diameterZ?: number;
  145301. arc?: number;
  145302. slice?: number;
  145303. sideOrientation?: number;
  145304. frontUVs?: Vector4;
  145305. backUVs?: Vector4;
  145306. updatable?: boolean;
  145307. }, scene?: Nullable<Scene>): Mesh;
  145308. /**
  145309. * Creates a plane polygonal mesh. By default, this is a disc
  145310. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  145311. * * 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
  145312. * * 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
  145313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145314. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145316. * @param name defines the name of the mesh
  145317. * @param options defines the options used to create the mesh
  145318. * @param scene defines the hosting scene
  145319. * @returns the plane polygonal mesh
  145320. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  145321. */
  145322. static CreateDisc(name: string, options: {
  145323. radius?: number;
  145324. tessellation?: number;
  145325. arc?: number;
  145326. updatable?: boolean;
  145327. sideOrientation?: number;
  145328. frontUVs?: Vector4;
  145329. backUVs?: Vector4;
  145330. }, scene?: Nullable<Scene>): Mesh;
  145331. /**
  145332. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  145333. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  145334. * * 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`)
  145335. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  145336. * * 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
  145337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145340. * @param name defines the name of the mesh
  145341. * @param options defines the options used to create the mesh
  145342. * @param scene defines the hosting scene
  145343. * @returns the icosahedron mesh
  145344. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  145345. */
  145346. static CreateIcoSphere(name: string, options: {
  145347. radius?: number;
  145348. radiusX?: number;
  145349. radiusY?: number;
  145350. radiusZ?: number;
  145351. flat?: boolean;
  145352. subdivisions?: number;
  145353. sideOrientation?: number;
  145354. frontUVs?: Vector4;
  145355. backUVs?: Vector4;
  145356. updatable?: boolean;
  145357. }, scene?: Nullable<Scene>): Mesh;
  145358. /**
  145359. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145360. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  145361. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  145362. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  145363. * * 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
  145364. * * 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
  145365. * * 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
  145366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145367. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145368. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145369. * * 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
  145370. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  145371. * * 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
  145372. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  145373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145374. * @param name defines the name of the mesh
  145375. * @param options defines the options used to create the mesh
  145376. * @param scene defines the hosting scene
  145377. * @returns the ribbon mesh
  145378. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  145379. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145380. */
  145381. static CreateRibbon(name: string, options: {
  145382. pathArray: Vector3[][];
  145383. closeArray?: boolean;
  145384. closePath?: boolean;
  145385. offset?: number;
  145386. updatable?: boolean;
  145387. sideOrientation?: number;
  145388. frontUVs?: Vector4;
  145389. backUVs?: Vector4;
  145390. instance?: Mesh;
  145391. invertUV?: boolean;
  145392. uvs?: Vector2[];
  145393. colors?: Color4[];
  145394. }, scene?: Nullable<Scene>): Mesh;
  145395. /**
  145396. * Creates a cylinder or a cone mesh
  145397. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  145398. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  145399. * * 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.
  145400. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  145401. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  145402. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  145403. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  145404. * * 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).
  145405. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  145406. * * 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).
  145407. * * 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
  145408. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  145409. * * 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
  145410. * * 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.
  145411. * * If `enclose` is false, a ring surface is one element.
  145412. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  145413. * * 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
  145414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145417. * @param name defines the name of the mesh
  145418. * @param options defines the options used to create the mesh
  145419. * @param scene defines the hosting scene
  145420. * @returns the cylinder mesh
  145421. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  145422. */
  145423. static CreateCylinder(name: string, options: {
  145424. height?: number;
  145425. diameterTop?: number;
  145426. diameterBottom?: number;
  145427. diameter?: number;
  145428. tessellation?: number;
  145429. subdivisions?: number;
  145430. arc?: number;
  145431. faceColors?: Color4[];
  145432. faceUV?: Vector4[];
  145433. updatable?: boolean;
  145434. hasRings?: boolean;
  145435. enclose?: boolean;
  145436. cap?: number;
  145437. sideOrientation?: number;
  145438. frontUVs?: Vector4;
  145439. backUVs?: Vector4;
  145440. }, scene?: Nullable<Scene>): Mesh;
  145441. /**
  145442. * Creates a torus mesh
  145443. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  145444. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  145445. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  145446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145449. * @param name defines the name of the mesh
  145450. * @param options defines the options used to create the mesh
  145451. * @param scene defines the hosting scene
  145452. * @returns the torus mesh
  145453. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  145454. */
  145455. static CreateTorus(name: string, options: {
  145456. diameter?: number;
  145457. thickness?: number;
  145458. tessellation?: number;
  145459. updatable?: boolean;
  145460. sideOrientation?: number;
  145461. frontUVs?: Vector4;
  145462. backUVs?: Vector4;
  145463. }, scene?: Nullable<Scene>): Mesh;
  145464. /**
  145465. * Creates a torus knot mesh
  145466. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145467. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145468. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145469. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145471. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145473. * @param name defines the name of the mesh
  145474. * @param options defines the options used to create the mesh
  145475. * @param scene defines the hosting scene
  145476. * @returns the torus knot mesh
  145477. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145478. */
  145479. static CreateTorusKnot(name: string, options: {
  145480. radius?: number;
  145481. tube?: number;
  145482. radialSegments?: number;
  145483. tubularSegments?: number;
  145484. p?: number;
  145485. q?: number;
  145486. updatable?: boolean;
  145487. sideOrientation?: number;
  145488. frontUVs?: Vector4;
  145489. backUVs?: Vector4;
  145490. }, scene?: Nullable<Scene>): Mesh;
  145491. /**
  145492. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  145493. * * 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
  145494. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  145495. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  145496. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  145497. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  145498. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  145499. * * 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
  145500. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  145501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  145503. * @param name defines the name of the new line system
  145504. * @param options defines the options used to create the line system
  145505. * @param scene defines the hosting scene
  145506. * @returns a new line system mesh
  145507. */
  145508. static CreateLineSystem(name: string, options: {
  145509. lines: Vector3[][];
  145510. updatable?: boolean;
  145511. instance?: Nullable<LinesMesh>;
  145512. colors?: Nullable<Color4[][]>;
  145513. useVertexAlpha?: boolean;
  145514. }, scene: Nullable<Scene>): LinesMesh;
  145515. /**
  145516. * Creates a line mesh
  145517. * 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
  145518. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  145519. * * The parameter `points` is an array successive Vector3
  145520. * * 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
  145521. * * The optional parameter `colors` is an array of successive Color4, one per line point
  145522. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  145523. * * When updating an instance, remember that only point positions can change, not the number of points
  145524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145525. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  145526. * @param name defines the name of the new line system
  145527. * @param options defines the options used to create the line system
  145528. * @param scene defines the hosting scene
  145529. * @returns a new line mesh
  145530. */
  145531. static CreateLines(name: string, options: {
  145532. points: Vector3[];
  145533. updatable?: boolean;
  145534. instance?: Nullable<LinesMesh>;
  145535. colors?: Color4[];
  145536. useVertexAlpha?: boolean;
  145537. }, scene?: Nullable<Scene>): LinesMesh;
  145538. /**
  145539. * Creates a dashed line mesh
  145540. * * 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
  145541. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  145542. * * The parameter `points` is an array successive Vector3
  145543. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  145544. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  145545. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  145546. * * 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
  145547. * * When updating an instance, remember that only point positions can change, not the number of points
  145548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145549. * @param name defines the name of the mesh
  145550. * @param options defines the options used to create the mesh
  145551. * @param scene defines the hosting scene
  145552. * @returns the dashed line mesh
  145553. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  145554. */
  145555. static CreateDashedLines(name: string, options: {
  145556. points: Vector3[];
  145557. dashSize?: number;
  145558. gapSize?: number;
  145559. dashNb?: number;
  145560. updatable?: boolean;
  145561. instance?: LinesMesh;
  145562. }, scene?: Nullable<Scene>): LinesMesh;
  145563. /**
  145564. * 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.
  145565. * * 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.
  145566. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  145567. * * 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.
  145568. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  145569. * * 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
  145570. * * 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
  145571. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  145572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145573. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145574. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  145575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145576. * @param name defines the name of the mesh
  145577. * @param options defines the options used to create the mesh
  145578. * @param scene defines the hosting scene
  145579. * @returns the extruded shape mesh
  145580. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145581. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  145582. */
  145583. static ExtrudeShape(name: string, options: {
  145584. shape: Vector3[];
  145585. path: Vector3[];
  145586. scale?: number;
  145587. rotation?: number;
  145588. cap?: number;
  145589. updatable?: boolean;
  145590. sideOrientation?: number;
  145591. frontUVs?: Vector4;
  145592. backUVs?: Vector4;
  145593. instance?: Mesh;
  145594. invertUV?: boolean;
  145595. }, scene?: Nullable<Scene>): Mesh;
  145596. /**
  145597. * Creates an custom extruded shape mesh.
  145598. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  145599. * * 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.
  145600. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  145601. * * 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
  145602. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  145603. * * 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
  145604. * * It must returns a float value that will be the scale value applied to the shape on each path point
  145605. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  145606. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  145607. * * 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
  145608. * * 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
  145609. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  145610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145611. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145612. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145614. * @param name defines the name of the mesh
  145615. * @param options defines the options used to create the mesh
  145616. * @param scene defines the hosting scene
  145617. * @returns the custom extruded shape mesh
  145618. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  145619. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145620. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  145621. */
  145622. static ExtrudeShapeCustom(name: string, options: {
  145623. shape: Vector3[];
  145624. path: Vector3[];
  145625. scaleFunction?: any;
  145626. rotationFunction?: any;
  145627. ribbonCloseArray?: boolean;
  145628. ribbonClosePath?: boolean;
  145629. cap?: number;
  145630. updatable?: boolean;
  145631. sideOrientation?: number;
  145632. frontUVs?: Vector4;
  145633. backUVs?: Vector4;
  145634. instance?: Mesh;
  145635. invertUV?: boolean;
  145636. }, scene?: Nullable<Scene>): Mesh;
  145637. /**
  145638. * Creates lathe mesh.
  145639. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145640. * * 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
  145641. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145642. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145643. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145644. * * 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
  145645. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145646. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  145647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145648. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145649. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145651. * @param name defines the name of the mesh
  145652. * @param options defines the options used to create the mesh
  145653. * @param scene defines the hosting scene
  145654. * @returns the lathe mesh
  145655. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145656. */
  145657. static CreateLathe(name: string, options: {
  145658. shape: Vector3[];
  145659. radius?: number;
  145660. tessellation?: number;
  145661. clip?: number;
  145662. arc?: number;
  145663. closed?: boolean;
  145664. updatable?: boolean;
  145665. sideOrientation?: number;
  145666. frontUVs?: Vector4;
  145667. backUVs?: Vector4;
  145668. cap?: number;
  145669. invertUV?: boolean;
  145670. }, scene?: Nullable<Scene>): Mesh;
  145671. /**
  145672. * Creates a tiled plane mesh
  145673. * * You can set a limited pattern arrangement with the tiles
  145674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145675. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145677. * @param name defines the name of the mesh
  145678. * @param options defines the options used to create the mesh
  145679. * @param scene defines the hosting scene
  145680. * @returns the plane mesh
  145681. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  145682. */
  145683. static CreateTiledPlane(name: string, options: {
  145684. pattern?: number;
  145685. tileSize?: number;
  145686. tileWidth?: number;
  145687. tileHeight?: number;
  145688. size?: number;
  145689. width?: number;
  145690. height?: number;
  145691. alignHorizontal?: number;
  145692. alignVertical?: number;
  145693. sideOrientation?: number;
  145694. frontUVs?: Vector4;
  145695. backUVs?: Vector4;
  145696. updatable?: boolean;
  145697. }, scene?: Nullable<Scene>): Mesh;
  145698. /**
  145699. * Creates a plane mesh
  145700. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  145701. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  145702. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  145703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145704. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145706. * @param name defines the name of the mesh
  145707. * @param options defines the options used to create the mesh
  145708. * @param scene defines the hosting scene
  145709. * @returns the plane mesh
  145710. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  145711. */
  145712. static CreatePlane(name: string, options: {
  145713. size?: number;
  145714. width?: number;
  145715. height?: number;
  145716. sideOrientation?: number;
  145717. frontUVs?: Vector4;
  145718. backUVs?: Vector4;
  145719. updatable?: boolean;
  145720. sourcePlane?: Plane;
  145721. }, scene?: Nullable<Scene>): Mesh;
  145722. /**
  145723. * Creates a ground mesh
  145724. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  145725. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  145726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145727. * @param name defines the name of the mesh
  145728. * @param options defines the options used to create the mesh
  145729. * @param scene defines the hosting scene
  145730. * @returns the ground mesh
  145731. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  145732. */
  145733. static CreateGround(name: string, options: {
  145734. width?: number;
  145735. height?: number;
  145736. subdivisions?: number;
  145737. subdivisionsX?: number;
  145738. subdivisionsY?: number;
  145739. updatable?: boolean;
  145740. }, scene?: Nullable<Scene>): Mesh;
  145741. /**
  145742. * Creates a tiled ground mesh
  145743. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  145744. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  145745. * * 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
  145746. * * 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
  145747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145748. * @param name defines the name of the mesh
  145749. * @param options defines the options used to create the mesh
  145750. * @param scene defines the hosting scene
  145751. * @returns the tiled ground mesh
  145752. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  145753. */
  145754. static CreateTiledGround(name: string, options: {
  145755. xmin: number;
  145756. zmin: number;
  145757. xmax: number;
  145758. zmax: number;
  145759. subdivisions?: {
  145760. w: number;
  145761. h: number;
  145762. };
  145763. precision?: {
  145764. w: number;
  145765. h: number;
  145766. };
  145767. updatable?: boolean;
  145768. }, scene?: Nullable<Scene>): Mesh;
  145769. /**
  145770. * Creates a ground mesh from a height map
  145771. * * The parameter `url` sets the URL of the height map image resource.
  145772. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  145773. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  145774. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  145775. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  145776. * * 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.
  145777. * * 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).
  145778. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  145779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145780. * @param name defines the name of the mesh
  145781. * @param url defines the url to the height map
  145782. * @param options defines the options used to create the mesh
  145783. * @param scene defines the hosting scene
  145784. * @returns the ground mesh
  145785. * @see https://doc.babylonjs.com/babylon101/height_map
  145786. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  145787. */
  145788. static CreateGroundFromHeightMap(name: string, url: string, options: {
  145789. width?: number;
  145790. height?: number;
  145791. subdivisions?: number;
  145792. minHeight?: number;
  145793. maxHeight?: number;
  145794. colorFilter?: Color3;
  145795. alphaFilter?: number;
  145796. updatable?: boolean;
  145797. onReady?: (mesh: GroundMesh) => void;
  145798. }, scene?: Nullable<Scene>): GroundMesh;
  145799. /**
  145800. * Creates a polygon mesh
  145801. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  145802. * * 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
  145803. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145805. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  145806. * * Remember you can only change the shape positions, not their number when updating a polygon
  145807. * @param name defines the name of the mesh
  145808. * @param options defines the options used to create the mesh
  145809. * @param scene defines the hosting scene
  145810. * @param earcutInjection can be used to inject your own earcut reference
  145811. * @returns the polygon mesh
  145812. */
  145813. static CreatePolygon(name: string, options: {
  145814. shape: Vector3[];
  145815. holes?: Vector3[][];
  145816. depth?: number;
  145817. faceUV?: Vector4[];
  145818. faceColors?: Color4[];
  145819. updatable?: boolean;
  145820. sideOrientation?: number;
  145821. frontUVs?: Vector4;
  145822. backUVs?: Vector4;
  145823. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145824. /**
  145825. * Creates an extruded polygon mesh, with depth in the Y direction.
  145826. * * 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)
  145827. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145828. * @param name defines the name of the mesh
  145829. * @param options defines the options used to create the mesh
  145830. * @param scene defines the hosting scene
  145831. * @param earcutInjection can be used to inject your own earcut reference
  145832. * @returns the polygon mesh
  145833. */
  145834. static ExtrudePolygon(name: string, options: {
  145835. shape: Vector3[];
  145836. holes?: Vector3[][];
  145837. depth?: number;
  145838. faceUV?: Vector4[];
  145839. faceColors?: Color4[];
  145840. updatable?: boolean;
  145841. sideOrientation?: number;
  145842. frontUVs?: Vector4;
  145843. backUVs?: Vector4;
  145844. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145845. /**
  145846. * Creates a tube mesh.
  145847. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145848. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  145849. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  145850. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  145851. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  145852. * * 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)
  145853. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  145854. * * 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
  145855. * * 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
  145856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145858. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145860. * @param name defines the name of the mesh
  145861. * @param options defines the options used to create the mesh
  145862. * @param scene defines the hosting scene
  145863. * @returns the tube mesh
  145864. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145865. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  145866. */
  145867. static CreateTube(name: string, options: {
  145868. path: Vector3[];
  145869. radius?: number;
  145870. tessellation?: number;
  145871. radiusFunction?: {
  145872. (i: number, distance: number): number;
  145873. };
  145874. cap?: number;
  145875. arc?: number;
  145876. updatable?: boolean;
  145877. sideOrientation?: number;
  145878. frontUVs?: Vector4;
  145879. backUVs?: Vector4;
  145880. instance?: Mesh;
  145881. invertUV?: boolean;
  145882. }, scene?: Nullable<Scene>): Mesh;
  145883. /**
  145884. * Creates a polyhedron mesh
  145885. * * 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
  145886. * * The parameter `size` (positive float, default 1) sets the polygon size
  145887. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  145888. * * 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`
  145889. * * 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
  145890. * * 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)`)
  145891. * * 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
  145892. * * 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
  145893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145894. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145896. * @param name defines the name of the mesh
  145897. * @param options defines the options used to create the mesh
  145898. * @param scene defines the hosting scene
  145899. * @returns the polyhedron mesh
  145900. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  145901. */
  145902. static CreatePolyhedron(name: string, options: {
  145903. type?: number;
  145904. size?: number;
  145905. sizeX?: number;
  145906. sizeY?: number;
  145907. sizeZ?: number;
  145908. custom?: any;
  145909. faceUV?: Vector4[];
  145910. faceColors?: Color4[];
  145911. flat?: boolean;
  145912. updatable?: boolean;
  145913. sideOrientation?: number;
  145914. frontUVs?: Vector4;
  145915. backUVs?: Vector4;
  145916. }, scene?: Nullable<Scene>): Mesh;
  145917. /**
  145918. * Creates a decal mesh.
  145919. * 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
  145920. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  145921. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  145922. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  145923. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  145924. * @param name defines the name of the mesh
  145925. * @param sourceMesh defines the mesh where the decal must be applied
  145926. * @param options defines the options used to create the mesh
  145927. * @param scene defines the hosting scene
  145928. * @returns the decal mesh
  145929. * @see https://doc.babylonjs.com/how_to/decals
  145930. */
  145931. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  145932. position?: Vector3;
  145933. normal?: Vector3;
  145934. size?: Vector3;
  145935. angle?: number;
  145936. }): Mesh;
  145937. }
  145938. }
  145939. declare module BABYLON {
  145940. /**
  145941. * A simplifier interface for future simplification implementations
  145942. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145943. */
  145944. export interface ISimplifier {
  145945. /**
  145946. * Simplification of a given mesh according to the given settings.
  145947. * Since this requires computation, it is assumed that the function runs async.
  145948. * @param settings The settings of the simplification, including quality and distance
  145949. * @param successCallback A callback that will be called after the mesh was simplified.
  145950. * @param errorCallback in case of an error, this callback will be called. optional.
  145951. */
  145952. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  145953. }
  145954. /**
  145955. * Expected simplification settings.
  145956. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  145957. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145958. */
  145959. export interface ISimplificationSettings {
  145960. /**
  145961. * Gets or sets the expected quality
  145962. */
  145963. quality: number;
  145964. /**
  145965. * Gets or sets the distance when this optimized version should be used
  145966. */
  145967. distance: number;
  145968. /**
  145969. * Gets an already optimized mesh
  145970. */
  145971. optimizeMesh?: boolean;
  145972. }
  145973. /**
  145974. * Class used to specify simplification options
  145975. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145976. */
  145977. export class SimplificationSettings implements ISimplificationSettings {
  145978. /** expected quality */
  145979. quality: number;
  145980. /** distance when this optimized version should be used */
  145981. distance: number;
  145982. /** already optimized mesh */
  145983. optimizeMesh?: boolean | undefined;
  145984. /**
  145985. * Creates a SimplificationSettings
  145986. * @param quality expected quality
  145987. * @param distance distance when this optimized version should be used
  145988. * @param optimizeMesh already optimized mesh
  145989. */
  145990. constructor(
  145991. /** expected quality */
  145992. quality: number,
  145993. /** distance when this optimized version should be used */
  145994. distance: number,
  145995. /** already optimized mesh */
  145996. optimizeMesh?: boolean | undefined);
  145997. }
  145998. /**
  145999. * Interface used to define a simplification task
  146000. */
  146001. export interface ISimplificationTask {
  146002. /**
  146003. * Array of settings
  146004. */
  146005. settings: Array<ISimplificationSettings>;
  146006. /**
  146007. * Simplification type
  146008. */
  146009. simplificationType: SimplificationType;
  146010. /**
  146011. * Mesh to simplify
  146012. */
  146013. mesh: Mesh;
  146014. /**
  146015. * Callback called on success
  146016. */
  146017. successCallback?: () => void;
  146018. /**
  146019. * Defines if parallel processing can be used
  146020. */
  146021. parallelProcessing: boolean;
  146022. }
  146023. /**
  146024. * Queue used to order the simplification tasks
  146025. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146026. */
  146027. export class SimplificationQueue {
  146028. private _simplificationArray;
  146029. /**
  146030. * Gets a boolean indicating that the process is still running
  146031. */
  146032. running: boolean;
  146033. /**
  146034. * Creates a new queue
  146035. */
  146036. constructor();
  146037. /**
  146038. * Adds a new simplification task
  146039. * @param task defines a task to add
  146040. */
  146041. addTask(task: ISimplificationTask): void;
  146042. /**
  146043. * Execute next task
  146044. */
  146045. executeNext(): void;
  146046. /**
  146047. * Execute a simplification task
  146048. * @param task defines the task to run
  146049. */
  146050. runSimplification(task: ISimplificationTask): void;
  146051. private getSimplifier;
  146052. }
  146053. /**
  146054. * The implemented types of simplification
  146055. * At the moment only Quadratic Error Decimation is implemented
  146056. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146057. */
  146058. export enum SimplificationType {
  146059. /** Quadratic error decimation */
  146060. QUADRATIC = 0
  146061. }
  146062. /**
  146063. * An implementation of the Quadratic Error simplification algorithm.
  146064. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  146065. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  146066. * @author RaananW
  146067. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146068. */
  146069. export class QuadraticErrorSimplification implements ISimplifier {
  146070. private _mesh;
  146071. private triangles;
  146072. private vertices;
  146073. private references;
  146074. private _reconstructedMesh;
  146075. /** Gets or sets the number pf sync interations */
  146076. syncIterations: number;
  146077. /** Gets or sets the aggressiveness of the simplifier */
  146078. aggressiveness: number;
  146079. /** Gets or sets the number of allowed iterations for decimation */
  146080. decimationIterations: number;
  146081. /** Gets or sets the espilon to use for bounding box computation */
  146082. boundingBoxEpsilon: number;
  146083. /**
  146084. * Creates a new QuadraticErrorSimplification
  146085. * @param _mesh defines the target mesh
  146086. */
  146087. constructor(_mesh: Mesh);
  146088. /**
  146089. * Simplification of a given mesh according to the given settings.
  146090. * Since this requires computation, it is assumed that the function runs async.
  146091. * @param settings The settings of the simplification, including quality and distance
  146092. * @param successCallback A callback that will be called after the mesh was simplified.
  146093. */
  146094. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  146095. private runDecimation;
  146096. private initWithMesh;
  146097. private init;
  146098. private reconstructMesh;
  146099. private initDecimatedMesh;
  146100. private isFlipped;
  146101. private updateTriangles;
  146102. private identifyBorder;
  146103. private updateMesh;
  146104. private vertexError;
  146105. private calculateError;
  146106. }
  146107. }
  146108. declare module BABYLON {
  146109. interface Scene {
  146110. /** @hidden (Backing field) */
  146111. _simplificationQueue: SimplificationQueue;
  146112. /**
  146113. * Gets or sets the simplification queue attached to the scene
  146114. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146115. */
  146116. simplificationQueue: SimplificationQueue;
  146117. }
  146118. interface Mesh {
  146119. /**
  146120. * Simplify the mesh according to the given array of settings.
  146121. * Function will return immediately and will simplify async
  146122. * @param settings a collection of simplification settings
  146123. * @param parallelProcessing should all levels calculate parallel or one after the other
  146124. * @param simplificationType the type of simplification to run
  146125. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  146126. * @returns the current mesh
  146127. */
  146128. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  146129. }
  146130. /**
  146131. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  146132. * created in a scene
  146133. */
  146134. export class SimplicationQueueSceneComponent implements ISceneComponent {
  146135. /**
  146136. * The component name helpfull to identify the component in the list of scene components.
  146137. */
  146138. readonly name: string;
  146139. /**
  146140. * The scene the component belongs to.
  146141. */
  146142. scene: Scene;
  146143. /**
  146144. * Creates a new instance of the component for the given scene
  146145. * @param scene Defines the scene to register the component in
  146146. */
  146147. constructor(scene: Scene);
  146148. /**
  146149. * Registers the component in a given scene
  146150. */
  146151. register(): void;
  146152. /**
  146153. * Rebuilds the elements related to this component in case of
  146154. * context lost for instance.
  146155. */
  146156. rebuild(): void;
  146157. /**
  146158. * Disposes the component and the associated ressources
  146159. */
  146160. dispose(): void;
  146161. private _beforeCameraUpdate;
  146162. }
  146163. }
  146164. declare module BABYLON {
  146165. interface Mesh {
  146166. /**
  146167. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  146168. */
  146169. thinInstanceEnablePicking: boolean;
  146170. /**
  146171. * Creates a new thin instance
  146172. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  146173. * @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
  146174. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  146175. */
  146176. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  146177. /**
  146178. * Adds the transformation (matrix) of the current mesh as a thin instance
  146179. * @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
  146180. * @returns the thin instance index number
  146181. */
  146182. thinInstanceAddSelf(refresh: boolean): number;
  146183. /**
  146184. * Registers a custom attribute to be used with thin instances
  146185. * @param kind name of the attribute
  146186. * @param stride size in floats of the attribute
  146187. */
  146188. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  146189. /**
  146190. * Sets the matrix of a thin instance
  146191. * @param index index of the thin instance
  146192. * @param matrix matrix to set
  146193. * @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
  146194. */
  146195. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  146196. /**
  146197. * Sets the value of a custom attribute for a thin instance
  146198. * @param kind name of the attribute
  146199. * @param index index of the thin instance
  146200. * @param value value to set
  146201. * @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
  146202. */
  146203. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  146204. /**
  146205. * 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.
  146206. */
  146207. thinInstanceCount: number;
  146208. /**
  146209. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  146210. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  146211. * @param buffer buffer to set
  146212. * @param stride size in floats of each value of the buffer
  146213. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  146214. */
  146215. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  146216. /**
  146217. * Gets the list of world matrices
  146218. * @return an array containing all the world matrices from the thin instances
  146219. */
  146220. thinInstanceGetWorldMatrices(): Matrix[];
  146221. /**
  146222. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  146223. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  146224. */
  146225. thinInstanceBufferUpdated(kind: string): void;
  146226. /**
  146227. * Refreshes the bounding info, taking into account all the thin instances defined
  146228. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  146229. */
  146230. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  146231. /** @hidden */
  146232. _thinInstanceInitializeUserStorage(): void;
  146233. /** @hidden */
  146234. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  146235. /** @hidden */
  146236. _userThinInstanceBuffersStorage: {
  146237. data: {
  146238. [key: string]: Float32Array;
  146239. };
  146240. sizes: {
  146241. [key: string]: number;
  146242. };
  146243. vertexBuffers: {
  146244. [key: string]: Nullable<VertexBuffer>;
  146245. };
  146246. strides: {
  146247. [key: string]: number;
  146248. };
  146249. };
  146250. }
  146251. }
  146252. declare module BABYLON {
  146253. /**
  146254. * Navigation plugin interface to add navigation constrained by a navigation mesh
  146255. */
  146256. export interface INavigationEnginePlugin {
  146257. /**
  146258. * plugin name
  146259. */
  146260. name: string;
  146261. /**
  146262. * Creates a navigation mesh
  146263. * @param meshes array of all the geometry used to compute the navigatio mesh
  146264. * @param parameters bunch of parameters used to filter geometry
  146265. */
  146266. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  146267. /**
  146268. * Create a navigation mesh debug mesh
  146269. * @param scene is where the mesh will be added
  146270. * @returns debug display mesh
  146271. */
  146272. createDebugNavMesh(scene: Scene): Mesh;
  146273. /**
  146274. * Get a navigation mesh constrained position, closest to the parameter position
  146275. * @param position world position
  146276. * @returns the closest point to position constrained by the navigation mesh
  146277. */
  146278. getClosestPoint(position: Vector3): Vector3;
  146279. /**
  146280. * Get a navigation mesh constrained position, closest to the parameter position
  146281. * @param position world position
  146282. * @param result output the closest point to position constrained by the navigation mesh
  146283. */
  146284. getClosestPointToRef(position: Vector3, result: Vector3): void;
  146285. /**
  146286. * Get a navigation mesh constrained position, within a particular radius
  146287. * @param position world position
  146288. * @param maxRadius the maximum distance to the constrained world position
  146289. * @returns the closest point to position constrained by the navigation mesh
  146290. */
  146291. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  146292. /**
  146293. * Get a navigation mesh constrained position, within a particular radius
  146294. * @param position world position
  146295. * @param maxRadius the maximum distance to the constrained world position
  146296. * @param result output the closest point to position constrained by the navigation mesh
  146297. */
  146298. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  146299. /**
  146300. * Compute the final position from a segment made of destination-position
  146301. * @param position world position
  146302. * @param destination world position
  146303. * @returns the resulting point along the navmesh
  146304. */
  146305. moveAlong(position: Vector3, destination: Vector3): Vector3;
  146306. /**
  146307. * Compute the final position from a segment made of destination-position
  146308. * @param position world position
  146309. * @param destination world position
  146310. * @param result output the resulting point along the navmesh
  146311. */
  146312. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  146313. /**
  146314. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  146315. * @param start world position
  146316. * @param end world position
  146317. * @returns array containing world position composing the path
  146318. */
  146319. computePath(start: Vector3, end: Vector3): Vector3[];
  146320. /**
  146321. * If this plugin is supported
  146322. * @returns true if plugin is supported
  146323. */
  146324. isSupported(): boolean;
  146325. /**
  146326. * Create a new Crowd so you can add agents
  146327. * @param maxAgents the maximum agent count in the crowd
  146328. * @param maxAgentRadius the maximum radius an agent can have
  146329. * @param scene to attach the crowd to
  146330. * @returns the crowd you can add agents to
  146331. */
  146332. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  146333. /**
  146334. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146335. * The queries will try to find a solution within those bounds
  146336. * default is (1,1,1)
  146337. * @param extent x,y,z value that define the extent around the queries point of reference
  146338. */
  146339. setDefaultQueryExtent(extent: Vector3): void;
  146340. /**
  146341. * Get the Bounding box extent specified by setDefaultQueryExtent
  146342. * @returns the box extent values
  146343. */
  146344. getDefaultQueryExtent(): Vector3;
  146345. /**
  146346. * build the navmesh from a previously saved state using getNavmeshData
  146347. * @param data the Uint8Array returned by getNavmeshData
  146348. */
  146349. buildFromNavmeshData(data: Uint8Array): void;
  146350. /**
  146351. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  146352. * @returns data the Uint8Array that can be saved and reused
  146353. */
  146354. getNavmeshData(): Uint8Array;
  146355. /**
  146356. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146357. * @param result output the box extent values
  146358. */
  146359. getDefaultQueryExtentToRef(result: Vector3): void;
  146360. /**
  146361. * Release all resources
  146362. */
  146363. dispose(): void;
  146364. }
  146365. /**
  146366. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  146367. */
  146368. export interface ICrowd {
  146369. /**
  146370. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  146371. * You can attach anything to that node. The node position is updated in the scene update tick.
  146372. * @param pos world position that will be constrained by the navigation mesh
  146373. * @param parameters agent parameters
  146374. * @param transform hooked to the agent that will be update by the scene
  146375. * @returns agent index
  146376. */
  146377. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  146378. /**
  146379. * Returns the agent position in world space
  146380. * @param index agent index returned by addAgent
  146381. * @returns world space position
  146382. */
  146383. getAgentPosition(index: number): Vector3;
  146384. /**
  146385. * Gets the agent position result in world space
  146386. * @param index agent index returned by addAgent
  146387. * @param result output world space position
  146388. */
  146389. getAgentPositionToRef(index: number, result: Vector3): void;
  146390. /**
  146391. * Gets the agent velocity in world space
  146392. * @param index agent index returned by addAgent
  146393. * @returns world space velocity
  146394. */
  146395. getAgentVelocity(index: number): Vector3;
  146396. /**
  146397. * Gets the agent velocity result in world space
  146398. * @param index agent index returned by addAgent
  146399. * @param result output world space velocity
  146400. */
  146401. getAgentVelocityToRef(index: number, result: Vector3): void;
  146402. /**
  146403. * remove a particular agent previously created
  146404. * @param index agent index returned by addAgent
  146405. */
  146406. removeAgent(index: number): void;
  146407. /**
  146408. * get the list of all agents attached to this crowd
  146409. * @returns list of agent indices
  146410. */
  146411. getAgents(): number[];
  146412. /**
  146413. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  146414. * @param deltaTime in seconds
  146415. */
  146416. update(deltaTime: number): void;
  146417. /**
  146418. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  146419. * @param index agent index returned by addAgent
  146420. * @param destination targeted world position
  146421. */
  146422. agentGoto(index: number, destination: Vector3): void;
  146423. /**
  146424. * Teleport the agent to a new position
  146425. * @param index agent index returned by addAgent
  146426. * @param destination targeted world position
  146427. */
  146428. agentTeleport(index: number, destination: Vector3): void;
  146429. /**
  146430. * Update agent parameters
  146431. * @param index agent index returned by addAgent
  146432. * @param parameters agent parameters
  146433. */
  146434. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  146435. /**
  146436. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146437. * The queries will try to find a solution within those bounds
  146438. * default is (1,1,1)
  146439. * @param extent x,y,z value that define the extent around the queries point of reference
  146440. */
  146441. setDefaultQueryExtent(extent: Vector3): void;
  146442. /**
  146443. * Get the Bounding box extent specified by setDefaultQueryExtent
  146444. * @returns the box extent values
  146445. */
  146446. getDefaultQueryExtent(): Vector3;
  146447. /**
  146448. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146449. * @param result output the box extent values
  146450. */
  146451. getDefaultQueryExtentToRef(result: Vector3): void;
  146452. /**
  146453. * Release all resources
  146454. */
  146455. dispose(): void;
  146456. }
  146457. /**
  146458. * Configures an agent
  146459. */
  146460. export interface IAgentParameters {
  146461. /**
  146462. * Agent radius. [Limit: >= 0]
  146463. */
  146464. radius: number;
  146465. /**
  146466. * Agent height. [Limit: > 0]
  146467. */
  146468. height: number;
  146469. /**
  146470. * Maximum allowed acceleration. [Limit: >= 0]
  146471. */
  146472. maxAcceleration: number;
  146473. /**
  146474. * Maximum allowed speed. [Limit: >= 0]
  146475. */
  146476. maxSpeed: number;
  146477. /**
  146478. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  146479. */
  146480. collisionQueryRange: number;
  146481. /**
  146482. * The path visibility optimization range. [Limit: > 0]
  146483. */
  146484. pathOptimizationRange: number;
  146485. /**
  146486. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  146487. */
  146488. separationWeight: number;
  146489. }
  146490. /**
  146491. * Configures the navigation mesh creation
  146492. */
  146493. export interface INavMeshParameters {
  146494. /**
  146495. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  146496. */
  146497. cs: number;
  146498. /**
  146499. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  146500. */
  146501. ch: number;
  146502. /**
  146503. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  146504. */
  146505. walkableSlopeAngle: number;
  146506. /**
  146507. * Minimum floor to 'ceiling' height that will still allow the floor area to
  146508. * be considered walkable. [Limit: >= 3] [Units: vx]
  146509. */
  146510. walkableHeight: number;
  146511. /**
  146512. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  146513. */
  146514. walkableClimb: number;
  146515. /**
  146516. * The distance to erode/shrink the walkable area of the heightfield away from
  146517. * obstructions. [Limit: >=0] [Units: vx]
  146518. */
  146519. walkableRadius: number;
  146520. /**
  146521. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  146522. */
  146523. maxEdgeLen: number;
  146524. /**
  146525. * The maximum distance a simplfied contour's border edges should deviate
  146526. * the original raw contour. [Limit: >=0] [Units: vx]
  146527. */
  146528. maxSimplificationError: number;
  146529. /**
  146530. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  146531. */
  146532. minRegionArea: number;
  146533. /**
  146534. * Any regions with a span count smaller than this value will, if possible,
  146535. * be merged with larger regions. [Limit: >=0] [Units: vx]
  146536. */
  146537. mergeRegionArea: number;
  146538. /**
  146539. * The maximum number of vertices allowed for polygons generated during the
  146540. * contour to polygon conversion process. [Limit: >= 3]
  146541. */
  146542. maxVertsPerPoly: number;
  146543. /**
  146544. * Sets the sampling distance to use when generating the detail mesh.
  146545. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  146546. */
  146547. detailSampleDist: number;
  146548. /**
  146549. * The maximum distance the detail mesh surface should deviate from heightfield
  146550. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  146551. */
  146552. detailSampleMaxError: number;
  146553. }
  146554. }
  146555. declare module BABYLON {
  146556. /**
  146557. * RecastJS navigation plugin
  146558. */
  146559. export class RecastJSPlugin implements INavigationEnginePlugin {
  146560. /**
  146561. * Reference to the Recast library
  146562. */
  146563. bjsRECAST: any;
  146564. /**
  146565. * plugin name
  146566. */
  146567. name: string;
  146568. /**
  146569. * the first navmesh created. We might extend this to support multiple navmeshes
  146570. */
  146571. navMesh: any;
  146572. /**
  146573. * Initializes the recastJS plugin
  146574. * @param recastInjection can be used to inject your own recast reference
  146575. */
  146576. constructor(recastInjection?: any);
  146577. /**
  146578. * Creates a navigation mesh
  146579. * @param meshes array of all the geometry used to compute the navigatio mesh
  146580. * @param parameters bunch of parameters used to filter geometry
  146581. */
  146582. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  146583. /**
  146584. * Create a navigation mesh debug mesh
  146585. * @param scene is where the mesh will be added
  146586. * @returns debug display mesh
  146587. */
  146588. createDebugNavMesh(scene: Scene): Mesh;
  146589. /**
  146590. * Get a navigation mesh constrained position, closest to the parameter position
  146591. * @param position world position
  146592. * @returns the closest point to position constrained by the navigation mesh
  146593. */
  146594. getClosestPoint(position: Vector3): Vector3;
  146595. /**
  146596. * Get a navigation mesh constrained position, closest to the parameter position
  146597. * @param position world position
  146598. * @param result output the closest point to position constrained by the navigation mesh
  146599. */
  146600. getClosestPointToRef(position: Vector3, result: Vector3): void;
  146601. /**
  146602. * Get a navigation mesh constrained position, within a particular radius
  146603. * @param position world position
  146604. * @param maxRadius the maximum distance to the constrained world position
  146605. * @returns the closest point to position constrained by the navigation mesh
  146606. */
  146607. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  146608. /**
  146609. * Get a navigation mesh constrained position, within a particular radius
  146610. * @param position world position
  146611. * @param maxRadius the maximum distance to the constrained world position
  146612. * @param result output the closest point to position constrained by the navigation mesh
  146613. */
  146614. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  146615. /**
  146616. * Compute the final position from a segment made of destination-position
  146617. * @param position world position
  146618. * @param destination world position
  146619. * @returns the resulting point along the navmesh
  146620. */
  146621. moveAlong(position: Vector3, destination: Vector3): Vector3;
  146622. /**
  146623. * Compute the final position from a segment made of destination-position
  146624. * @param position world position
  146625. * @param destination world position
  146626. * @param result output the resulting point along the navmesh
  146627. */
  146628. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  146629. /**
  146630. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  146631. * @param start world position
  146632. * @param end world position
  146633. * @returns array containing world position composing the path
  146634. */
  146635. computePath(start: Vector3, end: Vector3): Vector3[];
  146636. /**
  146637. * Create a new Crowd so you can add agents
  146638. * @param maxAgents the maximum agent count in the crowd
  146639. * @param maxAgentRadius the maximum radius an agent can have
  146640. * @param scene to attach the crowd to
  146641. * @returns the crowd you can add agents to
  146642. */
  146643. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  146644. /**
  146645. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146646. * The queries will try to find a solution within those bounds
  146647. * default is (1,1,1)
  146648. * @param extent x,y,z value that define the extent around the queries point of reference
  146649. */
  146650. setDefaultQueryExtent(extent: Vector3): void;
  146651. /**
  146652. * Get the Bounding box extent specified by setDefaultQueryExtent
  146653. * @returns the box extent values
  146654. */
  146655. getDefaultQueryExtent(): Vector3;
  146656. /**
  146657. * build the navmesh from a previously saved state using getNavmeshData
  146658. * @param data the Uint8Array returned by getNavmeshData
  146659. */
  146660. buildFromNavmeshData(data: Uint8Array): void;
  146661. /**
  146662. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  146663. * @returns data the Uint8Array that can be saved and reused
  146664. */
  146665. getNavmeshData(): Uint8Array;
  146666. /**
  146667. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146668. * @param result output the box extent values
  146669. */
  146670. getDefaultQueryExtentToRef(result: Vector3): void;
  146671. /**
  146672. * Disposes
  146673. */
  146674. dispose(): void;
  146675. /**
  146676. * If this plugin is supported
  146677. * @returns true if plugin is supported
  146678. */
  146679. isSupported(): boolean;
  146680. }
  146681. /**
  146682. * Recast detour crowd implementation
  146683. */
  146684. export class RecastJSCrowd implements ICrowd {
  146685. /**
  146686. * Recast/detour plugin
  146687. */
  146688. bjsRECASTPlugin: RecastJSPlugin;
  146689. /**
  146690. * Link to the detour crowd
  146691. */
  146692. recastCrowd: any;
  146693. /**
  146694. * One transform per agent
  146695. */
  146696. transforms: TransformNode[];
  146697. /**
  146698. * All agents created
  146699. */
  146700. agents: number[];
  146701. /**
  146702. * Link to the scene is kept to unregister the crowd from the scene
  146703. */
  146704. private _scene;
  146705. /**
  146706. * Observer for crowd updates
  146707. */
  146708. private _onBeforeAnimationsObserver;
  146709. /**
  146710. * Constructor
  146711. * @param plugin recastJS plugin
  146712. * @param maxAgents the maximum agent count in the crowd
  146713. * @param maxAgentRadius the maximum radius an agent can have
  146714. * @param scene to attach the crowd to
  146715. * @returns the crowd you can add agents to
  146716. */
  146717. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  146718. /**
  146719. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  146720. * You can attach anything to that node. The node position is updated in the scene update tick.
  146721. * @param pos world position that will be constrained by the navigation mesh
  146722. * @param parameters agent parameters
  146723. * @param transform hooked to the agent that will be update by the scene
  146724. * @returns agent index
  146725. */
  146726. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  146727. /**
  146728. * Returns the agent position in world space
  146729. * @param index agent index returned by addAgent
  146730. * @returns world space position
  146731. */
  146732. getAgentPosition(index: number): Vector3;
  146733. /**
  146734. * Returns the agent position result in world space
  146735. * @param index agent index returned by addAgent
  146736. * @param result output world space position
  146737. */
  146738. getAgentPositionToRef(index: number, result: Vector3): void;
  146739. /**
  146740. * Returns the agent velocity in world space
  146741. * @param index agent index returned by addAgent
  146742. * @returns world space velocity
  146743. */
  146744. getAgentVelocity(index: number): Vector3;
  146745. /**
  146746. * Returns the agent velocity result in world space
  146747. * @param index agent index returned by addAgent
  146748. * @param result output world space velocity
  146749. */
  146750. getAgentVelocityToRef(index: number, result: Vector3): void;
  146751. /**
  146752. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  146753. * @param index agent index returned by addAgent
  146754. * @param destination targeted world position
  146755. */
  146756. agentGoto(index: number, destination: Vector3): void;
  146757. /**
  146758. * Teleport the agent to a new position
  146759. * @param index agent index returned by addAgent
  146760. * @param destination targeted world position
  146761. */
  146762. agentTeleport(index: number, destination: Vector3): void;
  146763. /**
  146764. * Update agent parameters
  146765. * @param index agent index returned by addAgent
  146766. * @param parameters agent parameters
  146767. */
  146768. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  146769. /**
  146770. * remove a particular agent previously created
  146771. * @param index agent index returned by addAgent
  146772. */
  146773. removeAgent(index: number): void;
  146774. /**
  146775. * get the list of all agents attached to this crowd
  146776. * @returns list of agent indices
  146777. */
  146778. getAgents(): number[];
  146779. /**
  146780. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  146781. * @param deltaTime in seconds
  146782. */
  146783. update(deltaTime: number): void;
  146784. /**
  146785. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146786. * The queries will try to find a solution within those bounds
  146787. * default is (1,1,1)
  146788. * @param extent x,y,z value that define the extent around the queries point of reference
  146789. */
  146790. setDefaultQueryExtent(extent: Vector3): void;
  146791. /**
  146792. * Get the Bounding box extent specified by setDefaultQueryExtent
  146793. * @returns the box extent values
  146794. */
  146795. getDefaultQueryExtent(): Vector3;
  146796. /**
  146797. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146798. * @param result output the box extent values
  146799. */
  146800. getDefaultQueryExtentToRef(result: Vector3): void;
  146801. /**
  146802. * Release all resources
  146803. */
  146804. dispose(): void;
  146805. }
  146806. }
  146807. declare module BABYLON {
  146808. /**
  146809. * Class used to enable access to IndexedDB
  146810. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  146811. */
  146812. export class Database implements IOfflineProvider {
  146813. private _callbackManifestChecked;
  146814. private _currentSceneUrl;
  146815. private _db;
  146816. private _enableSceneOffline;
  146817. private _enableTexturesOffline;
  146818. private _manifestVersionFound;
  146819. private _mustUpdateRessources;
  146820. private _hasReachedQuota;
  146821. private _isSupported;
  146822. private _idbFactory;
  146823. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  146824. private static IsUASupportingBlobStorage;
  146825. /**
  146826. * Gets a boolean indicating if Database storate is enabled (off by default)
  146827. */
  146828. static IDBStorageEnabled: boolean;
  146829. /**
  146830. * Gets a boolean indicating if scene must be saved in the database
  146831. */
  146832. get enableSceneOffline(): boolean;
  146833. /**
  146834. * Gets a boolean indicating if textures must be saved in the database
  146835. */
  146836. get enableTexturesOffline(): boolean;
  146837. /**
  146838. * Creates a new Database
  146839. * @param urlToScene defines the url to load the scene
  146840. * @param callbackManifestChecked defines the callback to use when manifest is checked
  146841. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  146842. */
  146843. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  146844. private static _ParseURL;
  146845. private static _ReturnFullUrlLocation;
  146846. private _checkManifestFile;
  146847. /**
  146848. * Open the database and make it available
  146849. * @param successCallback defines the callback to call on success
  146850. * @param errorCallback defines the callback to call on error
  146851. */
  146852. open(successCallback: () => void, errorCallback: () => void): void;
  146853. /**
  146854. * Loads an image from the database
  146855. * @param url defines the url to load from
  146856. * @param image defines the target DOM image
  146857. */
  146858. loadImage(url: string, image: HTMLImageElement): void;
  146859. private _loadImageFromDBAsync;
  146860. private _saveImageIntoDBAsync;
  146861. private _checkVersionFromDB;
  146862. private _loadVersionFromDBAsync;
  146863. private _saveVersionIntoDBAsync;
  146864. /**
  146865. * Loads a file from database
  146866. * @param url defines the URL to load from
  146867. * @param sceneLoaded defines a callback to call on success
  146868. * @param progressCallBack defines a callback to call when progress changed
  146869. * @param errorCallback defines a callback to call on error
  146870. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  146871. */
  146872. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  146873. private _loadFileAsync;
  146874. private _saveFileAsync;
  146875. /**
  146876. * Validates if xhr data is correct
  146877. * @param xhr defines the request to validate
  146878. * @param dataType defines the expected data type
  146879. * @returns true if data is correct
  146880. */
  146881. private static _ValidateXHRData;
  146882. }
  146883. }
  146884. declare module BABYLON {
  146885. /** @hidden */
  146886. export var gpuUpdateParticlesPixelShader: {
  146887. name: string;
  146888. shader: string;
  146889. };
  146890. }
  146891. declare module BABYLON {
  146892. /** @hidden */
  146893. export var gpuUpdateParticlesVertexShader: {
  146894. name: string;
  146895. shader: string;
  146896. };
  146897. }
  146898. declare module BABYLON {
  146899. /** @hidden */
  146900. export var clipPlaneFragmentDeclaration2: {
  146901. name: string;
  146902. shader: string;
  146903. };
  146904. }
  146905. declare module BABYLON {
  146906. /** @hidden */
  146907. export var gpuRenderParticlesPixelShader: {
  146908. name: string;
  146909. shader: string;
  146910. };
  146911. }
  146912. declare module BABYLON {
  146913. /** @hidden */
  146914. export var clipPlaneVertexDeclaration2: {
  146915. name: string;
  146916. shader: string;
  146917. };
  146918. }
  146919. declare module BABYLON {
  146920. /** @hidden */
  146921. export var gpuRenderParticlesVertexShader: {
  146922. name: string;
  146923. shader: string;
  146924. };
  146925. }
  146926. declare module BABYLON {
  146927. /**
  146928. * This represents a GPU particle system in Babylon
  146929. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  146930. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  146931. */
  146932. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  146933. /**
  146934. * The layer mask we are rendering the particles through.
  146935. */
  146936. layerMask: number;
  146937. private _capacity;
  146938. private _activeCount;
  146939. private _currentActiveCount;
  146940. private _accumulatedCount;
  146941. private _renderEffect;
  146942. private _updateEffect;
  146943. private _buffer0;
  146944. private _buffer1;
  146945. private _spriteBuffer;
  146946. private _updateVAO;
  146947. private _renderVAO;
  146948. private _targetIndex;
  146949. private _sourceBuffer;
  146950. private _targetBuffer;
  146951. private _currentRenderId;
  146952. private _started;
  146953. private _stopped;
  146954. private _timeDelta;
  146955. private _randomTexture;
  146956. private _randomTexture2;
  146957. private _attributesStrideSize;
  146958. private _updateEffectOptions;
  146959. private _randomTextureSize;
  146960. private _actualFrame;
  146961. private _customEffect;
  146962. private readonly _rawTextureWidth;
  146963. /**
  146964. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  146965. */
  146966. static get IsSupported(): boolean;
  146967. /**
  146968. * An event triggered when the system is disposed.
  146969. */
  146970. onDisposeObservable: Observable<IParticleSystem>;
  146971. /**
  146972. * Gets the maximum number of particles active at the same time.
  146973. * @returns The max number of active particles.
  146974. */
  146975. getCapacity(): number;
  146976. /**
  146977. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  146978. * to override the particles.
  146979. */
  146980. forceDepthWrite: boolean;
  146981. /**
  146982. * Gets or set the number of active particles
  146983. */
  146984. get activeParticleCount(): number;
  146985. set activeParticleCount(value: number);
  146986. private _preWarmDone;
  146987. /**
  146988. * Specifies if the particles are updated in emitter local space or world space.
  146989. */
  146990. isLocal: boolean;
  146991. /** Gets or sets a matrix to use to compute projection */
  146992. defaultProjectionMatrix: Matrix;
  146993. /**
  146994. * Is this system ready to be used/rendered
  146995. * @return true if the system is ready
  146996. */
  146997. isReady(): boolean;
  146998. /**
  146999. * Gets if the system has been started. (Note: this will still be true after stop is called)
  147000. * @returns True if it has been started, otherwise false.
  147001. */
  147002. isStarted(): boolean;
  147003. /**
  147004. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  147005. * @returns True if it has been stopped, otherwise false.
  147006. */
  147007. isStopped(): boolean;
  147008. /**
  147009. * Gets a boolean indicating that the system is stopping
  147010. * @returns true if the system is currently stopping
  147011. */
  147012. isStopping(): boolean;
  147013. /**
  147014. * Gets the number of particles active at the same time.
  147015. * @returns The number of active particles.
  147016. */
  147017. getActiveCount(): number;
  147018. /**
  147019. * Starts the particle system and begins to emit
  147020. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  147021. */
  147022. start(delay?: number): void;
  147023. /**
  147024. * Stops the particle system.
  147025. */
  147026. stop(): void;
  147027. /**
  147028. * Remove all active particles
  147029. */
  147030. reset(): void;
  147031. /**
  147032. * Returns the string "GPUParticleSystem"
  147033. * @returns a string containing the class name
  147034. */
  147035. getClassName(): string;
  147036. /**
  147037. * Gets the custom effect used to render the particles
  147038. * @param blendMode Blend mode for which the effect should be retrieved
  147039. * @returns The effect
  147040. */
  147041. getCustomEffect(blendMode?: number): Nullable<Effect>;
  147042. /**
  147043. * Sets the custom effect used to render the particles
  147044. * @param effect The effect to set
  147045. * @param blendMode Blend mode for which the effect should be set
  147046. */
  147047. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  147048. /** @hidden */
  147049. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  147050. /**
  147051. * Observable that will be called just before the particles are drawn
  147052. */
  147053. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  147054. /**
  147055. * Gets the name of the particle vertex shader
  147056. */
  147057. get vertexShaderName(): string;
  147058. private _colorGradientsTexture;
  147059. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  147060. /**
  147061. * Adds a new color gradient
  147062. * @param gradient defines the gradient to use (between 0 and 1)
  147063. * @param color1 defines the color to affect to the specified gradient
  147064. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  147065. * @returns the current particle system
  147066. */
  147067. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  147068. private _refreshColorGradient;
  147069. /** Force the system to rebuild all gradients that need to be resync */
  147070. forceRefreshGradients(): void;
  147071. /**
  147072. * Remove a specific color gradient
  147073. * @param gradient defines the gradient to remove
  147074. * @returns the current particle system
  147075. */
  147076. removeColorGradient(gradient: number): GPUParticleSystem;
  147077. private _angularSpeedGradientsTexture;
  147078. private _sizeGradientsTexture;
  147079. private _velocityGradientsTexture;
  147080. private _limitVelocityGradientsTexture;
  147081. private _dragGradientsTexture;
  147082. private _addFactorGradient;
  147083. /**
  147084. * Adds a new size gradient
  147085. * @param gradient defines the gradient to use (between 0 and 1)
  147086. * @param factor defines the size factor to affect to the specified gradient
  147087. * @returns the current particle system
  147088. */
  147089. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  147090. /**
  147091. * Remove a specific size gradient
  147092. * @param gradient defines the gradient to remove
  147093. * @returns the current particle system
  147094. */
  147095. removeSizeGradient(gradient: number): GPUParticleSystem;
  147096. private _refreshFactorGradient;
  147097. /**
  147098. * Adds a new angular speed gradient
  147099. * @param gradient defines the gradient to use (between 0 and 1)
  147100. * @param factor defines the angular speed to affect to the specified gradient
  147101. * @returns the current particle system
  147102. */
  147103. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  147104. /**
  147105. * Remove a specific angular speed gradient
  147106. * @param gradient defines the gradient to remove
  147107. * @returns the current particle system
  147108. */
  147109. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  147110. /**
  147111. * Adds a new velocity gradient
  147112. * @param gradient defines the gradient to use (between 0 and 1)
  147113. * @param factor defines the velocity to affect to the specified gradient
  147114. * @returns the current particle system
  147115. */
  147116. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  147117. /**
  147118. * Remove a specific velocity gradient
  147119. * @param gradient defines the gradient to remove
  147120. * @returns the current particle system
  147121. */
  147122. removeVelocityGradient(gradient: number): GPUParticleSystem;
  147123. /**
  147124. * Adds a new limit velocity gradient
  147125. * @param gradient defines the gradient to use (between 0 and 1)
  147126. * @param factor defines the limit velocity value to affect to the specified gradient
  147127. * @returns the current particle system
  147128. */
  147129. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  147130. /**
  147131. * Remove a specific limit velocity gradient
  147132. * @param gradient defines the gradient to remove
  147133. * @returns the current particle system
  147134. */
  147135. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  147136. /**
  147137. * Adds a new drag gradient
  147138. * @param gradient defines the gradient to use (between 0 and 1)
  147139. * @param factor defines the drag value to affect to the specified gradient
  147140. * @returns the current particle system
  147141. */
  147142. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  147143. /**
  147144. * Remove a specific drag gradient
  147145. * @param gradient defines the gradient to remove
  147146. * @returns the current particle system
  147147. */
  147148. removeDragGradient(gradient: number): GPUParticleSystem;
  147149. /**
  147150. * Not supported by GPUParticleSystem
  147151. * @param gradient defines the gradient to use (between 0 and 1)
  147152. * @param factor defines the emit rate value to affect to the specified gradient
  147153. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147154. * @returns the current particle system
  147155. */
  147156. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147157. /**
  147158. * Not supported by GPUParticleSystem
  147159. * @param gradient defines the gradient to remove
  147160. * @returns the current particle system
  147161. */
  147162. removeEmitRateGradient(gradient: number): IParticleSystem;
  147163. /**
  147164. * Not supported by GPUParticleSystem
  147165. * @param gradient defines the gradient to use (between 0 and 1)
  147166. * @param factor defines the start size value to affect to the specified gradient
  147167. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147168. * @returns the current particle system
  147169. */
  147170. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147171. /**
  147172. * Not supported by GPUParticleSystem
  147173. * @param gradient defines the gradient to remove
  147174. * @returns the current particle system
  147175. */
  147176. removeStartSizeGradient(gradient: number): IParticleSystem;
  147177. /**
  147178. * Not supported by GPUParticleSystem
  147179. * @param gradient defines the gradient to use (between 0 and 1)
  147180. * @param min defines the color remap minimal range
  147181. * @param max defines the color remap maximal range
  147182. * @returns the current particle system
  147183. */
  147184. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  147185. /**
  147186. * Not supported by GPUParticleSystem
  147187. * @param gradient defines the gradient to remove
  147188. * @returns the current particle system
  147189. */
  147190. removeColorRemapGradient(): IParticleSystem;
  147191. /**
  147192. * Not supported by GPUParticleSystem
  147193. * @param gradient defines the gradient to use (between 0 and 1)
  147194. * @param min defines the alpha remap minimal range
  147195. * @param max defines the alpha remap maximal range
  147196. * @returns the current particle system
  147197. */
  147198. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  147199. /**
  147200. * Not supported by GPUParticleSystem
  147201. * @param gradient defines the gradient to remove
  147202. * @returns the current particle system
  147203. */
  147204. removeAlphaRemapGradient(): IParticleSystem;
  147205. /**
  147206. * Not supported by GPUParticleSystem
  147207. * @param gradient defines the gradient to use (between 0 and 1)
  147208. * @param color defines the color to affect to the specified gradient
  147209. * @returns the current particle system
  147210. */
  147211. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  147212. /**
  147213. * Not supported by GPUParticleSystem
  147214. * @param gradient defines the gradient to remove
  147215. * @returns the current particle system
  147216. */
  147217. removeRampGradient(): IParticleSystem;
  147218. /**
  147219. * Not supported by GPUParticleSystem
  147220. * @returns the list of ramp gradients
  147221. */
  147222. getRampGradients(): Nullable<Array<Color3Gradient>>;
  147223. /**
  147224. * Not supported by GPUParticleSystem
  147225. * Gets or sets a boolean indicating that ramp gradients must be used
  147226. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  147227. */
  147228. get useRampGradients(): boolean;
  147229. set useRampGradients(value: boolean);
  147230. /**
  147231. * Not supported by GPUParticleSystem
  147232. * @param gradient defines the gradient to use (between 0 and 1)
  147233. * @param factor defines the life time factor to affect to the specified gradient
  147234. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147235. * @returns the current particle system
  147236. */
  147237. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147238. /**
  147239. * Not supported by GPUParticleSystem
  147240. * @param gradient defines the gradient to remove
  147241. * @returns the current particle system
  147242. */
  147243. removeLifeTimeGradient(gradient: number): IParticleSystem;
  147244. /**
  147245. * Instantiates a GPU particle system.
  147246. * 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.
  147247. * @param name The name of the particle system
  147248. * @param options The options used to create the system
  147249. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  147250. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  147251. * @param customEffect a custom effect used to change the way particles are rendered by default
  147252. */
  147253. constructor(name: string, options: Partial<{
  147254. capacity: number;
  147255. randomTextureSize: number;
  147256. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  147257. protected _reset(): void;
  147258. private _createUpdateVAO;
  147259. private _createRenderVAO;
  147260. private _initialize;
  147261. /** @hidden */
  147262. _recreateUpdateEffect(): void;
  147263. private _getEffect;
  147264. /**
  147265. * Fill the defines array according to the current settings of the particle system
  147266. * @param defines Array to be updated
  147267. * @param blendMode blend mode to take into account when updating the array
  147268. */
  147269. fillDefines(defines: Array<string>, blendMode?: number): void;
  147270. /**
  147271. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  147272. * @param uniforms Uniforms array to fill
  147273. * @param attributes Attributes array to fill
  147274. * @param samplers Samplers array to fill
  147275. */
  147276. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  147277. /** @hidden */
  147278. _recreateRenderEffect(): Effect;
  147279. /**
  147280. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  147281. * @param preWarm defines if we are in the pre-warmimg phase
  147282. */
  147283. animate(preWarm?: boolean): void;
  147284. private _createFactorGradientTexture;
  147285. private _createSizeGradientTexture;
  147286. private _createAngularSpeedGradientTexture;
  147287. private _createVelocityGradientTexture;
  147288. private _createLimitVelocityGradientTexture;
  147289. private _createDragGradientTexture;
  147290. private _createColorGradientTexture;
  147291. /**
  147292. * Renders the particle system in its current state
  147293. * @param preWarm defines if the system should only update the particles but not render them
  147294. * @returns the current number of particles
  147295. */
  147296. render(preWarm?: boolean): number;
  147297. /**
  147298. * Rebuilds the particle system
  147299. */
  147300. rebuild(): void;
  147301. private _releaseBuffers;
  147302. private _releaseVAOs;
  147303. /**
  147304. * Disposes the particle system and free the associated resources
  147305. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  147306. */
  147307. dispose(disposeTexture?: boolean): void;
  147308. /**
  147309. * Clones the particle system.
  147310. * @param name The name of the cloned object
  147311. * @param newEmitter The new emitter to use
  147312. * @returns the cloned particle system
  147313. */
  147314. clone(name: string, newEmitter: any): GPUParticleSystem;
  147315. /**
  147316. * Serializes the particle system to a JSON object
  147317. * @param serializeTexture defines if the texture must be serialized as well
  147318. * @returns the JSON object
  147319. */
  147320. serialize(serializeTexture?: boolean): any;
  147321. /**
  147322. * Parses a JSON object to create a GPU particle system.
  147323. * @param parsedParticleSystem The JSON object to parse
  147324. * @param sceneOrEngine The scene or the engine to create the particle system in
  147325. * @param rootUrl The root url to use to load external dependencies like texture
  147326. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  147327. * @returns the parsed GPU particle system
  147328. */
  147329. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  147330. }
  147331. }
  147332. declare module BABYLON {
  147333. /**
  147334. * Represents a set of particle systems working together to create a specific effect
  147335. */
  147336. export class ParticleSystemSet implements IDisposable {
  147337. /**
  147338. * Gets or sets base Assets URL
  147339. */
  147340. static BaseAssetsUrl: string;
  147341. private _emitterCreationOptions;
  147342. private _emitterNode;
  147343. /**
  147344. * Gets the particle system list
  147345. */
  147346. systems: IParticleSystem[];
  147347. /**
  147348. * Gets the emitter node used with this set
  147349. */
  147350. get emitterNode(): Nullable<TransformNode>;
  147351. /**
  147352. * Creates a new emitter mesh as a sphere
  147353. * @param options defines the options used to create the sphere
  147354. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  147355. * @param scene defines the hosting scene
  147356. */
  147357. setEmitterAsSphere(options: {
  147358. diameter: number;
  147359. segments: number;
  147360. color: Color3;
  147361. }, renderingGroupId: number, scene: Scene): void;
  147362. /**
  147363. * Starts all particle systems of the set
  147364. * @param emitter defines an optional mesh to use as emitter for the particle systems
  147365. */
  147366. start(emitter?: AbstractMesh): void;
  147367. /**
  147368. * Release all associated resources
  147369. */
  147370. dispose(): void;
  147371. /**
  147372. * Serialize the set into a JSON compatible object
  147373. * @param serializeTexture defines if the texture must be serialized as well
  147374. * @returns a JSON compatible representation of the set
  147375. */
  147376. serialize(serializeTexture?: boolean): any;
  147377. /**
  147378. * Parse a new ParticleSystemSet from a serialized source
  147379. * @param data defines a JSON compatible representation of the set
  147380. * @param scene defines the hosting scene
  147381. * @param gpu defines if we want GPU particles or CPU particles
  147382. * @returns a new ParticleSystemSet
  147383. */
  147384. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  147385. }
  147386. }
  147387. declare module BABYLON {
  147388. /**
  147389. * This class is made for on one-liner static method to help creating particle system set.
  147390. */
  147391. export class ParticleHelper {
  147392. /**
  147393. * Gets or sets base Assets URL
  147394. */
  147395. static BaseAssetsUrl: string;
  147396. /** Define the Url to load snippets */
  147397. static SnippetUrl: string;
  147398. /**
  147399. * Create a default particle system that you can tweak
  147400. * @param emitter defines the emitter to use
  147401. * @param capacity defines the system capacity (default is 500 particles)
  147402. * @param scene defines the hosting scene
  147403. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  147404. * @returns the new Particle system
  147405. */
  147406. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  147407. /**
  147408. * This is the main static method (one-liner) of this helper to create different particle systems
  147409. * @param type This string represents the type to the particle system to create
  147410. * @param scene The scene where the particle system should live
  147411. * @param gpu If the system will use gpu
  147412. * @returns the ParticleSystemSet created
  147413. */
  147414. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  147415. /**
  147416. * Static function used to export a particle system to a ParticleSystemSet variable.
  147417. * Please note that the emitter shape is not exported
  147418. * @param systems defines the particle systems to export
  147419. * @returns the created particle system set
  147420. */
  147421. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  147422. /**
  147423. * Creates a particle system from a snippet saved in a remote file
  147424. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  147425. * @param url defines the url to load from
  147426. * @param scene defines the hosting scene
  147427. * @param gpu If the system will use gpu
  147428. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  147429. * @returns a promise that will resolve to the new particle system
  147430. */
  147431. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  147432. /**
  147433. * Creates a particle system from a snippet saved by the particle system editor
  147434. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  147435. * @param scene defines the hosting scene
  147436. * @param gpu If the system will use gpu
  147437. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  147438. * @returns a promise that will resolve to the new particle system
  147439. */
  147440. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  147441. }
  147442. }
  147443. declare module BABYLON {
  147444. interface Engine {
  147445. /**
  147446. * Create an effect to use with particle systems.
  147447. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  147448. * the particle system for which you want to create a custom effect in the last parameter
  147449. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  147450. * @param uniformsNames defines a list of attribute names
  147451. * @param samplers defines an array of string used to represent textures
  147452. * @param defines defines the string containing the defines to use to compile the shaders
  147453. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  147454. * @param onCompiled defines a function to call when the effect creation is successful
  147455. * @param onError defines a function to call when the effect creation has failed
  147456. * @param particleSystem the particle system you want to create the effect for
  147457. * @returns the new Effect
  147458. */
  147459. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  147460. }
  147461. interface Mesh {
  147462. /**
  147463. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  147464. * @returns an array of IParticleSystem
  147465. */
  147466. getEmittedParticleSystems(): IParticleSystem[];
  147467. /**
  147468. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  147469. * @returns an array of IParticleSystem
  147470. */
  147471. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  147472. }
  147473. }
  147474. declare module BABYLON {
  147475. /** Defines the 4 color options */
  147476. export enum PointColor {
  147477. /** color value */
  147478. Color = 2,
  147479. /** uv value */
  147480. UV = 1,
  147481. /** random value */
  147482. Random = 0,
  147483. /** stated value */
  147484. Stated = 3
  147485. }
  147486. /**
  147487. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  147488. * 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.
  147489. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  147490. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  147491. *
  147492. * Full documentation here : TO BE ENTERED
  147493. */
  147494. export class PointsCloudSystem implements IDisposable {
  147495. /**
  147496. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  147497. * Example : var p = SPS.particles[i];
  147498. */
  147499. particles: CloudPoint[];
  147500. /**
  147501. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  147502. */
  147503. nbParticles: number;
  147504. /**
  147505. * This a counter for your own usage. It's not set by any SPS functions.
  147506. */
  147507. counter: number;
  147508. /**
  147509. * The PCS name. This name is also given to the underlying mesh.
  147510. */
  147511. name: string;
  147512. /**
  147513. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  147514. */
  147515. mesh: Mesh;
  147516. /**
  147517. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  147518. * Please read :
  147519. */
  147520. vars: any;
  147521. /**
  147522. * @hidden
  147523. */
  147524. _size: number;
  147525. private _scene;
  147526. private _promises;
  147527. private _positions;
  147528. private _indices;
  147529. private _normals;
  147530. private _colors;
  147531. private _uvs;
  147532. private _indices32;
  147533. private _positions32;
  147534. private _colors32;
  147535. private _uvs32;
  147536. private _updatable;
  147537. private _isVisibilityBoxLocked;
  147538. private _alwaysVisible;
  147539. private _groups;
  147540. private _groupCounter;
  147541. private _computeParticleColor;
  147542. private _computeParticleTexture;
  147543. private _computeParticleRotation;
  147544. private _computeBoundingBox;
  147545. private _isReady;
  147546. /**
  147547. * Creates a PCS (Points Cloud System) object
  147548. * @param name (String) is the PCS name, this will be the underlying mesh name
  147549. * @param pointSize (number) is the size for each point
  147550. * @param scene (Scene) is the scene in which the PCS is added
  147551. * @param options defines the options of the PCS e.g.
  147552. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  147553. */
  147554. constructor(name: string, pointSize: number, scene: Scene, options?: {
  147555. updatable?: boolean;
  147556. });
  147557. /**
  147558. * Builds the PCS underlying mesh. Returns a standard Mesh.
  147559. * If no points were added to the PCS, the returned mesh is just a single point.
  147560. * @returns a promise for the created mesh
  147561. */
  147562. buildMeshAsync(): Promise<Mesh>;
  147563. /**
  147564. * @hidden
  147565. */
  147566. private _buildMesh;
  147567. private _addParticle;
  147568. private _randomUnitVector;
  147569. private _getColorIndicesForCoord;
  147570. private _setPointsColorOrUV;
  147571. private _colorFromTexture;
  147572. private _calculateDensity;
  147573. /**
  147574. * Adds points to the PCS in random positions within a unit sphere
  147575. * @param nb (positive integer) the number of particles to be created from this model
  147576. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  147577. * @returns the number of groups in the system
  147578. */
  147579. addPoints(nb: number, pointFunction?: any): number;
  147580. /**
  147581. * Adds points to the PCS from the surface of the model shape
  147582. * @param mesh is any Mesh object that will be used as a surface model for the points
  147583. * @param nb (positive integer) the number of particles to be created from this model
  147584. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  147585. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  147586. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  147587. * @returns the number of groups in the system
  147588. */
  147589. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  147590. /**
  147591. * Adds points to the PCS inside the model shape
  147592. * @param mesh is any Mesh object that will be used as a surface model for the points
  147593. * @param nb (positive integer) the number of particles to be created from this model
  147594. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  147595. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  147596. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  147597. * @returns the number of groups in the system
  147598. */
  147599. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  147600. /**
  147601. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  147602. * This method calls `updateParticle()` for each particle of the SPS.
  147603. * For an animated SPS, it is usually called within the render loop.
  147604. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  147605. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  147606. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  147607. * @returns the PCS.
  147608. */
  147609. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  147610. /**
  147611. * Disposes the PCS.
  147612. */
  147613. dispose(): void;
  147614. /**
  147615. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  147616. * doc :
  147617. * @returns the PCS.
  147618. */
  147619. refreshVisibleSize(): PointsCloudSystem;
  147620. /**
  147621. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  147622. * @param size the size (float) of the visibility box
  147623. * note : this doesn't lock the PCS mesh bounding box.
  147624. * doc :
  147625. */
  147626. setVisibilityBox(size: number): void;
  147627. /**
  147628. * Gets whether the PCS is always visible or not
  147629. * doc :
  147630. */
  147631. get isAlwaysVisible(): boolean;
  147632. /**
  147633. * Sets the PCS as always visible or not
  147634. * doc :
  147635. */
  147636. set isAlwaysVisible(val: boolean);
  147637. /**
  147638. * Tells to `setParticles()` to compute the particle rotations or not
  147639. * Default value : false. The PCS is faster when it's set to false
  147640. * Note : particle rotations are only applied to parent particles
  147641. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  147642. */
  147643. set computeParticleRotation(val: boolean);
  147644. /**
  147645. * Tells to `setParticles()` to compute the particle colors or not.
  147646. * Default value : true. The PCS is faster when it's set to false.
  147647. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  147648. */
  147649. set computeParticleColor(val: boolean);
  147650. set computeParticleTexture(val: boolean);
  147651. /**
  147652. * Gets if `setParticles()` computes the particle colors or not.
  147653. * Default value : false. The PCS is faster when it's set to false.
  147654. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  147655. */
  147656. get computeParticleColor(): boolean;
  147657. /**
  147658. * Gets if `setParticles()` computes the particle textures or not.
  147659. * Default value : false. The PCS is faster when it's set to false.
  147660. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  147661. */
  147662. get computeParticleTexture(): boolean;
  147663. /**
  147664. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  147665. */
  147666. set computeBoundingBox(val: boolean);
  147667. /**
  147668. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  147669. */
  147670. get computeBoundingBox(): boolean;
  147671. /**
  147672. * This function does nothing. It may be overwritten to set all the particle first values.
  147673. * The PCS doesn't call this function, you may have to call it by your own.
  147674. * doc :
  147675. */
  147676. initParticles(): void;
  147677. /**
  147678. * This function does nothing. It may be overwritten to recycle a particle
  147679. * The PCS doesn't call this function, you can to call it
  147680. * doc :
  147681. * @param particle The particle to recycle
  147682. * @returns the recycled particle
  147683. */
  147684. recycleParticle(particle: CloudPoint): CloudPoint;
  147685. /**
  147686. * Updates a particle : this function should be overwritten by the user.
  147687. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  147688. * doc :
  147689. * @example : just set a particle position or velocity and recycle conditions
  147690. * @param particle The particle to update
  147691. * @returns the updated particle
  147692. */
  147693. updateParticle(particle: CloudPoint): CloudPoint;
  147694. /**
  147695. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  147696. * This does nothing and may be overwritten by the user.
  147697. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  147698. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  147699. * @param update the boolean update value actually passed to setParticles()
  147700. */
  147701. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  147702. /**
  147703. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  147704. * This will be passed three parameters.
  147705. * This does nothing and may be overwritten by the user.
  147706. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  147707. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  147708. * @param update the boolean update value actually passed to setParticles()
  147709. */
  147710. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  147711. }
  147712. }
  147713. declare module BABYLON {
  147714. /**
  147715. * Represents one particle of a points cloud system.
  147716. */
  147717. export class CloudPoint {
  147718. /**
  147719. * particle global index
  147720. */
  147721. idx: number;
  147722. /**
  147723. * The color of the particle
  147724. */
  147725. color: Nullable<Color4>;
  147726. /**
  147727. * The world space position of the particle.
  147728. */
  147729. position: Vector3;
  147730. /**
  147731. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  147732. */
  147733. rotation: Vector3;
  147734. /**
  147735. * The world space rotation quaternion of the particle.
  147736. */
  147737. rotationQuaternion: Nullable<Quaternion>;
  147738. /**
  147739. * The uv of the particle.
  147740. */
  147741. uv: Nullable<Vector2>;
  147742. /**
  147743. * The current speed of the particle.
  147744. */
  147745. velocity: Vector3;
  147746. /**
  147747. * The pivot point in the particle local space.
  147748. */
  147749. pivot: Vector3;
  147750. /**
  147751. * Must the particle be translated from its pivot point in its local space ?
  147752. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  147753. * Default : false
  147754. */
  147755. translateFromPivot: boolean;
  147756. /**
  147757. * Index of this particle in the global "positions" array (Internal use)
  147758. * @hidden
  147759. */
  147760. _pos: number;
  147761. /**
  147762. * @hidden Index of this particle in the global "indices" array (Internal use)
  147763. */
  147764. _ind: number;
  147765. /**
  147766. * Group this particle belongs to
  147767. */
  147768. _group: PointsGroup;
  147769. /**
  147770. * Group id of this particle
  147771. */
  147772. groupId: number;
  147773. /**
  147774. * Index of the particle in its group id (Internal use)
  147775. */
  147776. idxInGroup: number;
  147777. /**
  147778. * @hidden Particle BoundingInfo object (Internal use)
  147779. */
  147780. _boundingInfo: BoundingInfo;
  147781. /**
  147782. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  147783. */
  147784. _pcs: PointsCloudSystem;
  147785. /**
  147786. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  147787. */
  147788. _stillInvisible: boolean;
  147789. /**
  147790. * @hidden Last computed particle rotation matrix
  147791. */
  147792. _rotationMatrix: number[];
  147793. /**
  147794. * Parent particle Id, if any.
  147795. * Default null.
  147796. */
  147797. parentId: Nullable<number>;
  147798. /**
  147799. * @hidden Internal global position in the PCS.
  147800. */
  147801. _globalPosition: Vector3;
  147802. /**
  147803. * Creates a Point Cloud object.
  147804. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  147805. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  147806. * @param group (PointsGroup) is the group the particle belongs to
  147807. * @param groupId (integer) is the group identifier in the PCS.
  147808. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  147809. * @param pcs defines the PCS it is associated to
  147810. */
  147811. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  147812. /**
  147813. * get point size
  147814. */
  147815. get size(): Vector3;
  147816. /**
  147817. * Set point size
  147818. */
  147819. set size(scale: Vector3);
  147820. /**
  147821. * Legacy support, changed quaternion to rotationQuaternion
  147822. */
  147823. get quaternion(): Nullable<Quaternion>;
  147824. /**
  147825. * Legacy support, changed quaternion to rotationQuaternion
  147826. */
  147827. set quaternion(q: Nullable<Quaternion>);
  147828. /**
  147829. * Returns a boolean. True if the particle intersects a mesh, else false
  147830. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  147831. * @param target is the object (point or mesh) what the intersection is computed against
  147832. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  147833. * @returns true if it intersects
  147834. */
  147835. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  147836. /**
  147837. * get the rotation matrix of the particle
  147838. * @hidden
  147839. */
  147840. getRotationMatrix(m: Matrix): void;
  147841. }
  147842. /**
  147843. * Represents a group of points in a points cloud system
  147844. * * PCS internal tool, don't use it manually.
  147845. */
  147846. export class PointsGroup {
  147847. /**
  147848. * The group id
  147849. * @hidden
  147850. */
  147851. groupID: number;
  147852. /**
  147853. * image data for group (internal use)
  147854. * @hidden
  147855. */
  147856. _groupImageData: Nullable<ArrayBufferView>;
  147857. /**
  147858. * Image Width (internal use)
  147859. * @hidden
  147860. */
  147861. _groupImgWidth: number;
  147862. /**
  147863. * Image Height (internal use)
  147864. * @hidden
  147865. */
  147866. _groupImgHeight: number;
  147867. /**
  147868. * Custom position function (internal use)
  147869. * @hidden
  147870. */
  147871. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  147872. /**
  147873. * density per facet for surface points
  147874. * @hidden
  147875. */
  147876. _groupDensity: number[];
  147877. /**
  147878. * Only when points are colored by texture carries pointer to texture list array
  147879. * @hidden
  147880. */
  147881. _textureNb: number;
  147882. /**
  147883. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  147884. * PCS internal tool, don't use it manually.
  147885. * @hidden
  147886. */
  147887. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  147888. }
  147889. }
  147890. declare module BABYLON {
  147891. interface Scene {
  147892. /** @hidden (Backing field) */
  147893. _physicsEngine: Nullable<IPhysicsEngine>;
  147894. /** @hidden */
  147895. _physicsTimeAccumulator: number;
  147896. /**
  147897. * Gets the current physics engine
  147898. * @returns a IPhysicsEngine or null if none attached
  147899. */
  147900. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  147901. /**
  147902. * Enables physics to the current scene
  147903. * @param gravity defines the scene's gravity for the physics engine
  147904. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  147905. * @return a boolean indicating if the physics engine was initialized
  147906. */
  147907. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  147908. /**
  147909. * Disables and disposes the physics engine associated with the scene
  147910. */
  147911. disablePhysicsEngine(): void;
  147912. /**
  147913. * Gets a boolean indicating if there is an active physics engine
  147914. * @returns a boolean indicating if there is an active physics engine
  147915. */
  147916. isPhysicsEnabled(): boolean;
  147917. /**
  147918. * Deletes a physics compound impostor
  147919. * @param compound defines the compound to delete
  147920. */
  147921. deleteCompoundImpostor(compound: any): void;
  147922. /**
  147923. * An event triggered when physic simulation is about to be run
  147924. */
  147925. onBeforePhysicsObservable: Observable<Scene>;
  147926. /**
  147927. * An event triggered when physic simulation has been done
  147928. */
  147929. onAfterPhysicsObservable: Observable<Scene>;
  147930. }
  147931. interface AbstractMesh {
  147932. /** @hidden */
  147933. _physicsImpostor: Nullable<PhysicsImpostor>;
  147934. /**
  147935. * Gets or sets impostor used for physic simulation
  147936. * @see https://doc.babylonjs.com/features/physics_engine
  147937. */
  147938. physicsImpostor: Nullable<PhysicsImpostor>;
  147939. /**
  147940. * Gets the current physics impostor
  147941. * @see https://doc.babylonjs.com/features/physics_engine
  147942. * @returns a physics impostor or null
  147943. */
  147944. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  147945. /** Apply a physic impulse to the mesh
  147946. * @param force defines the force to apply
  147947. * @param contactPoint defines where to apply the force
  147948. * @returns the current mesh
  147949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  147950. */
  147951. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  147952. /**
  147953. * Creates a physic joint between two meshes
  147954. * @param otherMesh defines the other mesh to use
  147955. * @param pivot1 defines the pivot to use on this mesh
  147956. * @param pivot2 defines the pivot to use on the other mesh
  147957. * @param options defines additional options (can be plugin dependent)
  147958. * @returns the current mesh
  147959. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  147960. */
  147961. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  147962. /** @hidden */
  147963. _disposePhysicsObserver: Nullable<Observer<Node>>;
  147964. }
  147965. /**
  147966. * Defines the physics engine scene component responsible to manage a physics engine
  147967. */
  147968. export class PhysicsEngineSceneComponent implements ISceneComponent {
  147969. /**
  147970. * The component name helpful to identify the component in the list of scene components.
  147971. */
  147972. readonly name: string;
  147973. /**
  147974. * The scene the component belongs to.
  147975. */
  147976. scene: Scene;
  147977. /**
  147978. * Creates a new instance of the component for the given scene
  147979. * @param scene Defines the scene to register the component in
  147980. */
  147981. constructor(scene: Scene);
  147982. /**
  147983. * Registers the component in a given scene
  147984. */
  147985. register(): void;
  147986. /**
  147987. * Rebuilds the elements related to this component in case of
  147988. * context lost for instance.
  147989. */
  147990. rebuild(): void;
  147991. /**
  147992. * Disposes the component and the associated ressources
  147993. */
  147994. dispose(): void;
  147995. }
  147996. }
  147997. declare module BABYLON {
  147998. /**
  147999. * A helper for physics simulations
  148000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148001. */
  148002. export class PhysicsHelper {
  148003. private _scene;
  148004. private _physicsEngine;
  148005. /**
  148006. * Initializes the Physics helper
  148007. * @param scene Babylon.js scene
  148008. */
  148009. constructor(scene: Scene);
  148010. /**
  148011. * Applies a radial explosion impulse
  148012. * @param origin the origin of the explosion
  148013. * @param radiusOrEventOptions the radius or the options of radial explosion
  148014. * @param strength the explosion strength
  148015. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148016. * @returns A physics radial explosion event, or null
  148017. */
  148018. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148019. /**
  148020. * Applies a radial explosion force
  148021. * @param origin the origin of the explosion
  148022. * @param radiusOrEventOptions the radius or the options of radial explosion
  148023. * @param strength the explosion strength
  148024. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148025. * @returns A physics radial explosion event, or null
  148026. */
  148027. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148028. /**
  148029. * Creates a gravitational field
  148030. * @param origin the origin of the explosion
  148031. * @param radiusOrEventOptions the radius or the options of radial explosion
  148032. * @param strength the explosion strength
  148033. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148034. * @returns A physics gravitational field event, or null
  148035. */
  148036. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  148037. /**
  148038. * Creates a physics updraft event
  148039. * @param origin the origin of the updraft
  148040. * @param radiusOrEventOptions the radius or the options of the updraft
  148041. * @param strength the strength of the updraft
  148042. * @param height the height of the updraft
  148043. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  148044. * @returns A physics updraft event, or null
  148045. */
  148046. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  148047. /**
  148048. * Creates a physics vortex event
  148049. * @param origin the of the vortex
  148050. * @param radiusOrEventOptions the radius or the options of the vortex
  148051. * @param strength the strength of the vortex
  148052. * @param height the height of the vortex
  148053. * @returns a Physics vortex event, or null
  148054. * A physics vortex event or null
  148055. */
  148056. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  148057. }
  148058. /**
  148059. * Represents a physics radial explosion event
  148060. */
  148061. class PhysicsRadialExplosionEvent {
  148062. private _scene;
  148063. private _options;
  148064. private _sphere;
  148065. private _dataFetched;
  148066. /**
  148067. * Initializes a radial explosioin event
  148068. * @param _scene BabylonJS scene
  148069. * @param _options The options for the vortex event
  148070. */
  148071. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  148072. /**
  148073. * Returns the data related to the radial explosion event (sphere).
  148074. * @returns The radial explosion event data
  148075. */
  148076. getData(): PhysicsRadialExplosionEventData;
  148077. /**
  148078. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  148079. * @param impostor A physics imposter
  148080. * @param origin the origin of the explosion
  148081. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  148082. */
  148083. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  148084. /**
  148085. * Triggers affecterd impostors callbacks
  148086. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  148087. */
  148088. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  148089. /**
  148090. * Disposes the sphere.
  148091. * @param force Specifies if the sphere should be disposed by force
  148092. */
  148093. dispose(force?: boolean): void;
  148094. /*** Helpers ***/
  148095. private _prepareSphere;
  148096. private _intersectsWithSphere;
  148097. }
  148098. /**
  148099. * Represents a gravitational field event
  148100. */
  148101. class PhysicsGravitationalFieldEvent {
  148102. private _physicsHelper;
  148103. private _scene;
  148104. private _origin;
  148105. private _options;
  148106. private _tickCallback;
  148107. private _sphere;
  148108. private _dataFetched;
  148109. /**
  148110. * Initializes the physics gravitational field event
  148111. * @param _physicsHelper A physics helper
  148112. * @param _scene BabylonJS scene
  148113. * @param _origin The origin position of the gravitational field event
  148114. * @param _options The options for the vortex event
  148115. */
  148116. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  148117. /**
  148118. * Returns the data related to the gravitational field event (sphere).
  148119. * @returns A gravitational field event
  148120. */
  148121. getData(): PhysicsGravitationalFieldEventData;
  148122. /**
  148123. * Enables the gravitational field.
  148124. */
  148125. enable(): void;
  148126. /**
  148127. * Disables the gravitational field.
  148128. */
  148129. disable(): void;
  148130. /**
  148131. * Disposes the sphere.
  148132. * @param force The force to dispose from the gravitational field event
  148133. */
  148134. dispose(force?: boolean): void;
  148135. private _tick;
  148136. }
  148137. /**
  148138. * Represents a physics updraft event
  148139. */
  148140. class PhysicsUpdraftEvent {
  148141. private _scene;
  148142. private _origin;
  148143. private _options;
  148144. private _physicsEngine;
  148145. private _originTop;
  148146. private _originDirection;
  148147. private _tickCallback;
  148148. private _cylinder;
  148149. private _cylinderPosition;
  148150. private _dataFetched;
  148151. /**
  148152. * Initializes the physics updraft event
  148153. * @param _scene BabylonJS scene
  148154. * @param _origin The origin position of the updraft
  148155. * @param _options The options for the updraft event
  148156. */
  148157. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  148158. /**
  148159. * Returns the data related to the updraft event (cylinder).
  148160. * @returns A physics updraft event
  148161. */
  148162. getData(): PhysicsUpdraftEventData;
  148163. /**
  148164. * Enables the updraft.
  148165. */
  148166. enable(): void;
  148167. /**
  148168. * Disables the updraft.
  148169. */
  148170. disable(): void;
  148171. /**
  148172. * Disposes the cylinder.
  148173. * @param force Specifies if the updraft should be disposed by force
  148174. */
  148175. dispose(force?: boolean): void;
  148176. private getImpostorHitData;
  148177. private _tick;
  148178. /*** Helpers ***/
  148179. private _prepareCylinder;
  148180. private _intersectsWithCylinder;
  148181. }
  148182. /**
  148183. * Represents a physics vortex event
  148184. */
  148185. class PhysicsVortexEvent {
  148186. private _scene;
  148187. private _origin;
  148188. private _options;
  148189. private _physicsEngine;
  148190. private _originTop;
  148191. private _tickCallback;
  148192. private _cylinder;
  148193. private _cylinderPosition;
  148194. private _dataFetched;
  148195. /**
  148196. * Initializes the physics vortex event
  148197. * @param _scene The BabylonJS scene
  148198. * @param _origin The origin position of the vortex
  148199. * @param _options The options for the vortex event
  148200. */
  148201. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  148202. /**
  148203. * Returns the data related to the vortex event (cylinder).
  148204. * @returns The physics vortex event data
  148205. */
  148206. getData(): PhysicsVortexEventData;
  148207. /**
  148208. * Enables the vortex.
  148209. */
  148210. enable(): void;
  148211. /**
  148212. * Disables the cortex.
  148213. */
  148214. disable(): void;
  148215. /**
  148216. * Disposes the sphere.
  148217. * @param force
  148218. */
  148219. dispose(force?: boolean): void;
  148220. private getImpostorHitData;
  148221. private _tick;
  148222. /*** Helpers ***/
  148223. private _prepareCylinder;
  148224. private _intersectsWithCylinder;
  148225. }
  148226. /**
  148227. * Options fot the radial explosion event
  148228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148229. */
  148230. export class PhysicsRadialExplosionEventOptions {
  148231. /**
  148232. * The radius of the sphere for the radial explosion.
  148233. */
  148234. radius: number;
  148235. /**
  148236. * The strenth of the explosion.
  148237. */
  148238. strength: number;
  148239. /**
  148240. * The strenght of the force in correspondence to the distance of the affected object
  148241. */
  148242. falloff: PhysicsRadialImpulseFalloff;
  148243. /**
  148244. * Sphere options for the radial explosion.
  148245. */
  148246. sphere: {
  148247. segments: number;
  148248. diameter: number;
  148249. };
  148250. /**
  148251. * Sphere options for the radial explosion.
  148252. */
  148253. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  148254. }
  148255. /**
  148256. * Options fot the updraft event
  148257. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148258. */
  148259. export class PhysicsUpdraftEventOptions {
  148260. /**
  148261. * The radius of the cylinder for the vortex
  148262. */
  148263. radius: number;
  148264. /**
  148265. * The strenth of the updraft.
  148266. */
  148267. strength: number;
  148268. /**
  148269. * The height of the cylinder for the updraft.
  148270. */
  148271. height: number;
  148272. /**
  148273. * The mode for the the updraft.
  148274. */
  148275. updraftMode: PhysicsUpdraftMode;
  148276. }
  148277. /**
  148278. * Options fot the vortex event
  148279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148280. */
  148281. export class PhysicsVortexEventOptions {
  148282. /**
  148283. * The radius of the cylinder for the vortex
  148284. */
  148285. radius: number;
  148286. /**
  148287. * The strenth of the vortex.
  148288. */
  148289. strength: number;
  148290. /**
  148291. * The height of the cylinder for the vortex.
  148292. */
  148293. height: number;
  148294. /**
  148295. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  148296. */
  148297. centripetalForceThreshold: number;
  148298. /**
  148299. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  148300. */
  148301. centripetalForceMultiplier: number;
  148302. /**
  148303. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  148304. */
  148305. centrifugalForceMultiplier: number;
  148306. /**
  148307. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  148308. */
  148309. updraftForceMultiplier: number;
  148310. }
  148311. /**
  148312. * The strenght of the force in correspondence to the distance of the affected object
  148313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148314. */
  148315. export enum PhysicsRadialImpulseFalloff {
  148316. /** Defines that impulse is constant in strength across it's whole radius */
  148317. Constant = 0,
  148318. /** Defines that impulse gets weaker if it's further from the origin */
  148319. Linear = 1
  148320. }
  148321. /**
  148322. * The strength of the force in correspondence to the distance of the affected object
  148323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148324. */
  148325. export enum PhysicsUpdraftMode {
  148326. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  148327. Center = 0,
  148328. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  148329. Perpendicular = 1
  148330. }
  148331. /**
  148332. * Interface for a physics hit data
  148333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148334. */
  148335. export interface PhysicsHitData {
  148336. /**
  148337. * The force applied at the contact point
  148338. */
  148339. force: Vector3;
  148340. /**
  148341. * The contact point
  148342. */
  148343. contactPoint: Vector3;
  148344. /**
  148345. * The distance from the origin to the contact point
  148346. */
  148347. distanceFromOrigin: number;
  148348. }
  148349. /**
  148350. * Interface for radial explosion event data
  148351. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148352. */
  148353. export interface PhysicsRadialExplosionEventData {
  148354. /**
  148355. * A sphere used for the radial explosion event
  148356. */
  148357. sphere: Mesh;
  148358. }
  148359. /**
  148360. * Interface for gravitational field event data
  148361. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148362. */
  148363. export interface PhysicsGravitationalFieldEventData {
  148364. /**
  148365. * A sphere mesh used for the gravitational field event
  148366. */
  148367. sphere: Mesh;
  148368. }
  148369. /**
  148370. * Interface for updraft event data
  148371. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148372. */
  148373. export interface PhysicsUpdraftEventData {
  148374. /**
  148375. * A cylinder used for the updraft event
  148376. */
  148377. cylinder: Mesh;
  148378. }
  148379. /**
  148380. * Interface for vortex event data
  148381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148382. */
  148383. export interface PhysicsVortexEventData {
  148384. /**
  148385. * A cylinder used for the vortex event
  148386. */
  148387. cylinder: Mesh;
  148388. }
  148389. /**
  148390. * Interface for an affected physics impostor
  148391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148392. */
  148393. export interface PhysicsAffectedImpostorWithData {
  148394. /**
  148395. * The impostor affected by the effect
  148396. */
  148397. impostor: PhysicsImpostor;
  148398. /**
  148399. * The data about the hit/horce from the explosion
  148400. */
  148401. hitData: PhysicsHitData;
  148402. }
  148403. }
  148404. declare module BABYLON {
  148405. /** @hidden */
  148406. export var blackAndWhitePixelShader: {
  148407. name: string;
  148408. shader: string;
  148409. };
  148410. }
  148411. declare module BABYLON {
  148412. /**
  148413. * Post process used to render in black and white
  148414. */
  148415. export class BlackAndWhitePostProcess extends PostProcess {
  148416. /**
  148417. * Linear about to convert he result to black and white (default: 1)
  148418. */
  148419. degree: number;
  148420. /**
  148421. * Gets a string identifying the name of the class
  148422. * @returns "BlackAndWhitePostProcess" string
  148423. */
  148424. getClassName(): string;
  148425. /**
  148426. * Creates a black and white post process
  148427. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  148428. * @param name The name of the effect.
  148429. * @param options The required width/height ratio to downsize to before computing the render pass.
  148430. * @param camera The camera to apply the render pass to.
  148431. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148432. * @param engine The engine which the post process will be applied. (default: current engine)
  148433. * @param reusable If the post process can be reused on the same frame. (default: false)
  148434. */
  148435. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148436. /** @hidden */
  148437. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  148438. }
  148439. }
  148440. declare module BABYLON {
  148441. /**
  148442. * This represents a set of one or more post processes in Babylon.
  148443. * A post process can be used to apply a shader to a texture after it is rendered.
  148444. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148445. */
  148446. export class PostProcessRenderEffect {
  148447. private _postProcesses;
  148448. private _getPostProcesses;
  148449. private _singleInstance;
  148450. private _cameras;
  148451. private _indicesForCamera;
  148452. /**
  148453. * Name of the effect
  148454. * @hidden
  148455. */
  148456. _name: string;
  148457. /**
  148458. * Instantiates a post process render effect.
  148459. * A post process can be used to apply a shader to a texture after it is rendered.
  148460. * @param engine The engine the effect is tied to
  148461. * @param name The name of the effect
  148462. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  148463. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  148464. */
  148465. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  148466. /**
  148467. * Checks if all the post processes in the effect are supported.
  148468. */
  148469. get isSupported(): boolean;
  148470. /**
  148471. * Updates the current state of the effect
  148472. * @hidden
  148473. */
  148474. _update(): void;
  148475. /**
  148476. * Attaches the effect on cameras
  148477. * @param cameras The camera to attach to.
  148478. * @hidden
  148479. */
  148480. _attachCameras(cameras: Camera): void;
  148481. /**
  148482. * Attaches the effect on cameras
  148483. * @param cameras The camera to attach to.
  148484. * @hidden
  148485. */
  148486. _attachCameras(cameras: Camera[]): void;
  148487. /**
  148488. * Detaches the effect on cameras
  148489. * @param cameras The camera to detatch from.
  148490. * @hidden
  148491. */
  148492. _detachCameras(cameras: Camera): void;
  148493. /**
  148494. * Detatches the effect on cameras
  148495. * @param cameras The camera to detatch from.
  148496. * @hidden
  148497. */
  148498. _detachCameras(cameras: Camera[]): void;
  148499. /**
  148500. * Enables the effect on given cameras
  148501. * @param cameras The camera to enable.
  148502. * @hidden
  148503. */
  148504. _enable(cameras: Camera): void;
  148505. /**
  148506. * Enables the effect on given cameras
  148507. * @param cameras The camera to enable.
  148508. * @hidden
  148509. */
  148510. _enable(cameras: Nullable<Camera[]>): void;
  148511. /**
  148512. * Disables the effect on the given cameras
  148513. * @param cameras The camera to disable.
  148514. * @hidden
  148515. */
  148516. _disable(cameras: Camera): void;
  148517. /**
  148518. * Disables the effect on the given cameras
  148519. * @param cameras The camera to disable.
  148520. * @hidden
  148521. */
  148522. _disable(cameras: Nullable<Camera[]>): void;
  148523. /**
  148524. * Gets a list of the post processes contained in the effect.
  148525. * @param camera The camera to get the post processes on.
  148526. * @returns The list of the post processes in the effect.
  148527. */
  148528. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  148529. }
  148530. }
  148531. declare module BABYLON {
  148532. /** @hidden */
  148533. export var extractHighlightsPixelShader: {
  148534. name: string;
  148535. shader: string;
  148536. };
  148537. }
  148538. declare module BABYLON {
  148539. /**
  148540. * 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.
  148541. */
  148542. export class ExtractHighlightsPostProcess extends PostProcess {
  148543. /**
  148544. * The luminance threshold, pixels below this value will be set to black.
  148545. */
  148546. threshold: number;
  148547. /** @hidden */
  148548. _exposure: number;
  148549. /**
  148550. * Post process which has the input texture to be used when performing highlight extraction
  148551. * @hidden
  148552. */
  148553. _inputPostProcess: Nullable<PostProcess>;
  148554. /**
  148555. * Gets a string identifying the name of the class
  148556. * @returns "ExtractHighlightsPostProcess" string
  148557. */
  148558. getClassName(): string;
  148559. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148560. }
  148561. }
  148562. declare module BABYLON {
  148563. /** @hidden */
  148564. export var bloomMergePixelShader: {
  148565. name: string;
  148566. shader: string;
  148567. };
  148568. }
  148569. declare module BABYLON {
  148570. /**
  148571. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  148572. */
  148573. export class BloomMergePostProcess extends PostProcess {
  148574. /** Weight of the bloom to be added to the original input. */
  148575. weight: number;
  148576. /**
  148577. * Gets a string identifying the name of the class
  148578. * @returns "BloomMergePostProcess" string
  148579. */
  148580. getClassName(): string;
  148581. /**
  148582. * Creates a new instance of @see BloomMergePostProcess
  148583. * @param name The name of the effect.
  148584. * @param originalFromInput Post process which's input will be used for the merge.
  148585. * @param blurred Blurred highlights post process which's output will be used.
  148586. * @param weight Weight of the bloom to be added to the original input.
  148587. * @param options The required width/height ratio to downsize to before computing the render pass.
  148588. * @param camera The camera to apply the render pass to.
  148589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148590. * @param engine The engine which the post process will be applied. (default: current engine)
  148591. * @param reusable If the post process can be reused on the same frame. (default: false)
  148592. * @param textureType Type of textures used when performing the post process. (default: 0)
  148593. * @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)
  148594. */
  148595. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  148596. /** Weight of the bloom to be added to the original input. */
  148597. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148598. }
  148599. }
  148600. declare module BABYLON {
  148601. /**
  148602. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  148603. */
  148604. export class BloomEffect extends PostProcessRenderEffect {
  148605. private bloomScale;
  148606. /**
  148607. * @hidden Internal
  148608. */
  148609. _effects: Array<PostProcess>;
  148610. /**
  148611. * @hidden Internal
  148612. */
  148613. _downscale: ExtractHighlightsPostProcess;
  148614. private _blurX;
  148615. private _blurY;
  148616. private _merge;
  148617. /**
  148618. * The luminance threshold to find bright areas of the image to bloom.
  148619. */
  148620. get threshold(): number;
  148621. set threshold(value: number);
  148622. /**
  148623. * The strength of the bloom.
  148624. */
  148625. get weight(): number;
  148626. set weight(value: number);
  148627. /**
  148628. * Specifies the size of the bloom blur kernel, relative to the final output size
  148629. */
  148630. get kernel(): number;
  148631. set kernel(value: number);
  148632. /**
  148633. * Creates a new instance of @see BloomEffect
  148634. * @param scene The scene the effect belongs to.
  148635. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  148636. * @param bloomKernel The size of the kernel to be used when applying the blur.
  148637. * @param bloomWeight The the strength of bloom.
  148638. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  148639. * @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)
  148640. */
  148641. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  148642. /**
  148643. * Disposes each of the internal effects for a given camera.
  148644. * @param camera The camera to dispose the effect on.
  148645. */
  148646. disposeEffects(camera: Camera): void;
  148647. /**
  148648. * @hidden Internal
  148649. */
  148650. _updateEffects(): void;
  148651. /**
  148652. * Internal
  148653. * @returns if all the contained post processes are ready.
  148654. * @hidden
  148655. */
  148656. _isReady(): boolean;
  148657. }
  148658. }
  148659. declare module BABYLON {
  148660. /** @hidden */
  148661. export var chromaticAberrationPixelShader: {
  148662. name: string;
  148663. shader: string;
  148664. };
  148665. }
  148666. declare module BABYLON {
  148667. /**
  148668. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  148669. */
  148670. export class ChromaticAberrationPostProcess extends PostProcess {
  148671. /**
  148672. * The amount of seperation of rgb channels (default: 30)
  148673. */
  148674. aberrationAmount: number;
  148675. /**
  148676. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  148677. */
  148678. radialIntensity: number;
  148679. /**
  148680. * 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))
  148681. */
  148682. direction: Vector2;
  148683. /**
  148684. * 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))
  148685. */
  148686. centerPosition: Vector2;
  148687. /** The width of the screen to apply the effect on */
  148688. screenWidth: number;
  148689. /** The height of the screen to apply the effect on */
  148690. screenHeight: number;
  148691. /**
  148692. * Gets a string identifying the name of the class
  148693. * @returns "ChromaticAberrationPostProcess" string
  148694. */
  148695. getClassName(): string;
  148696. /**
  148697. * Creates a new instance ChromaticAberrationPostProcess
  148698. * @param name The name of the effect.
  148699. * @param screenWidth The width of the screen to apply the effect on.
  148700. * @param screenHeight The height of the screen to apply the effect on.
  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. * @param textureType Type of textures used when performing the post process. (default: 0)
  148707. * @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)
  148708. */
  148709. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148710. /** @hidden */
  148711. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  148712. }
  148713. }
  148714. declare module BABYLON {
  148715. /** @hidden */
  148716. export var circleOfConfusionPixelShader: {
  148717. name: string;
  148718. shader: string;
  148719. };
  148720. }
  148721. declare module BABYLON {
  148722. /**
  148723. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  148724. */
  148725. export class CircleOfConfusionPostProcess extends PostProcess {
  148726. /**
  148727. * 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.
  148728. */
  148729. lensSize: number;
  148730. /**
  148731. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  148732. */
  148733. fStop: number;
  148734. /**
  148735. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  148736. */
  148737. focusDistance: number;
  148738. /**
  148739. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  148740. */
  148741. focalLength: number;
  148742. /**
  148743. * Gets a string identifying the name of the class
  148744. * @returns "CircleOfConfusionPostProcess" string
  148745. */
  148746. getClassName(): string;
  148747. private _depthTexture;
  148748. /**
  148749. * Creates a new instance CircleOfConfusionPostProcess
  148750. * @param name The name of the effect.
  148751. * @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.
  148752. * @param options The required width/height ratio to downsize to before computing the render pass.
  148753. * @param camera The camera to apply the render pass to.
  148754. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148755. * @param engine The engine which the post process will be applied. (default: current engine)
  148756. * @param reusable If the post process can be reused on the same frame. (default: false)
  148757. * @param textureType Type of textures used when performing the post process. (default: 0)
  148758. * @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)
  148759. */
  148760. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148761. /**
  148762. * 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.
  148763. */
  148764. set depthTexture(value: RenderTargetTexture);
  148765. }
  148766. }
  148767. declare module BABYLON {
  148768. /** @hidden */
  148769. export var colorCorrectionPixelShader: {
  148770. name: string;
  148771. shader: string;
  148772. };
  148773. }
  148774. declare module BABYLON {
  148775. /**
  148776. *
  148777. * This post-process allows the modification of rendered colors by using
  148778. * a 'look-up table' (LUT). This effect is also called Color Grading.
  148779. *
  148780. * The object needs to be provided an url to a texture containing the color
  148781. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  148782. * Use an image editing software to tweak the LUT to match your needs.
  148783. *
  148784. * For an example of a color LUT, see here:
  148785. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  148786. * For explanations on color grading, see here:
  148787. * @see http://udn.epicgames.com/Three/ColorGrading.html
  148788. *
  148789. */
  148790. export class ColorCorrectionPostProcess extends PostProcess {
  148791. private _colorTableTexture;
  148792. /**
  148793. * Gets the color table url used to create the LUT texture
  148794. */
  148795. colorTableUrl: string;
  148796. /**
  148797. * Gets a string identifying the name of the class
  148798. * @returns "ColorCorrectionPostProcess" string
  148799. */
  148800. getClassName(): string;
  148801. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148802. /** @hidden */
  148803. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  148804. }
  148805. }
  148806. declare module BABYLON {
  148807. /** @hidden */
  148808. export var convolutionPixelShader: {
  148809. name: string;
  148810. shader: string;
  148811. };
  148812. }
  148813. declare module BABYLON {
  148814. /**
  148815. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  148816. * input texture to perform effects such as edge detection or sharpening
  148817. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  148818. */
  148819. export class ConvolutionPostProcess extends PostProcess {
  148820. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  148821. kernel: number[];
  148822. /**
  148823. * Gets a string identifying the name of the class
  148824. * @returns "ConvolutionPostProcess" string
  148825. */
  148826. getClassName(): string;
  148827. /**
  148828. * Creates a new instance ConvolutionPostProcess
  148829. * @param name The name of the effect.
  148830. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  148831. * @param options The required width/height ratio to downsize to before computing the render pass.
  148832. * @param camera The camera to apply the render pass to.
  148833. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148834. * @param engine The engine which the post process will be applied. (default: current engine)
  148835. * @param reusable If the post process can be reused on the same frame. (default: false)
  148836. * @param textureType Type of textures used when performing the post process. (default: 0)
  148837. */
  148838. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148839. /** @hidden */
  148840. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  148841. /**
  148842. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148843. */
  148844. static EdgeDetect0Kernel: number[];
  148845. /**
  148846. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148847. */
  148848. static EdgeDetect1Kernel: number[];
  148849. /**
  148850. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148851. */
  148852. static EdgeDetect2Kernel: number[];
  148853. /**
  148854. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148855. */
  148856. static SharpenKernel: number[];
  148857. /**
  148858. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148859. */
  148860. static EmbossKernel: number[];
  148861. /**
  148862. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148863. */
  148864. static GaussianKernel: number[];
  148865. }
  148866. }
  148867. declare module BABYLON {
  148868. /**
  148869. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  148870. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  148871. * based on samples that have a large difference in distance than the center pixel.
  148872. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  148873. */
  148874. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  148875. /**
  148876. * The direction the blur should be applied
  148877. */
  148878. direction: Vector2;
  148879. /**
  148880. * Gets a string identifying the name of the class
  148881. * @returns "DepthOfFieldBlurPostProcess" string
  148882. */
  148883. getClassName(): string;
  148884. /**
  148885. * Creates a new instance CircleOfConfusionPostProcess
  148886. * @param name The name of the effect.
  148887. * @param scene The scene the effect belongs to.
  148888. * @param direction The direction the blur should be applied.
  148889. * @param kernel The size of the kernel used to blur.
  148890. * @param options The required width/height ratio to downsize to before computing the render pass.
  148891. * @param camera The camera to apply the render pass to.
  148892. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  148893. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  148894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148895. * @param engine The engine which the post process will be applied. (default: current engine)
  148896. * @param reusable If the post process can be reused on the same frame. (default: false)
  148897. * @param textureType Type of textures used when performing the post process. (default: 0)
  148898. * @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)
  148899. */
  148900. 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);
  148901. }
  148902. }
  148903. declare module BABYLON {
  148904. /** @hidden */
  148905. export var depthOfFieldMergePixelShader: {
  148906. name: string;
  148907. shader: string;
  148908. };
  148909. }
  148910. declare module BABYLON {
  148911. /**
  148912. * Options to be set when merging outputs from the default pipeline.
  148913. */
  148914. export class DepthOfFieldMergePostProcessOptions {
  148915. /**
  148916. * The original image to merge on top of
  148917. */
  148918. originalFromInput: PostProcess;
  148919. /**
  148920. * Parameters to perform the merge of the depth of field effect
  148921. */
  148922. depthOfField?: {
  148923. circleOfConfusion: PostProcess;
  148924. blurSteps: Array<PostProcess>;
  148925. };
  148926. /**
  148927. * Parameters to perform the merge of bloom effect
  148928. */
  148929. bloom?: {
  148930. blurred: PostProcess;
  148931. weight: number;
  148932. };
  148933. }
  148934. /**
  148935. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  148936. */
  148937. export class DepthOfFieldMergePostProcess extends PostProcess {
  148938. private blurSteps;
  148939. /**
  148940. * Gets a string identifying the name of the class
  148941. * @returns "DepthOfFieldMergePostProcess" string
  148942. */
  148943. getClassName(): string;
  148944. /**
  148945. * Creates a new instance of DepthOfFieldMergePostProcess
  148946. * @param name The name of the effect.
  148947. * @param originalFromInput Post process which's input will be used for the merge.
  148948. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  148949. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  148950. * @param options The required width/height ratio to downsize to before computing the render pass.
  148951. * @param camera The camera to apply the render pass to.
  148952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148953. * @param engine The engine which the post process will be applied. (default: current engine)
  148954. * @param reusable If the post process can be reused on the same frame. (default: false)
  148955. * @param textureType Type of textures used when performing the post process. (default: 0)
  148956. * @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)
  148957. */
  148958. 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);
  148959. /**
  148960. * Updates the effect with the current post process compile time values and recompiles the shader.
  148961. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  148962. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  148963. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  148964. * @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
  148965. * @param onCompiled Called when the shader has been compiled.
  148966. * @param onError Called if there is an error when compiling a shader.
  148967. */
  148968. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  148969. }
  148970. }
  148971. declare module BABYLON {
  148972. /**
  148973. * Specifies the level of max blur that should be applied when using the depth of field effect
  148974. */
  148975. export enum DepthOfFieldEffectBlurLevel {
  148976. /**
  148977. * Subtle blur
  148978. */
  148979. Low = 0,
  148980. /**
  148981. * Medium blur
  148982. */
  148983. Medium = 1,
  148984. /**
  148985. * Large blur
  148986. */
  148987. High = 2
  148988. }
  148989. /**
  148990. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  148991. */
  148992. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  148993. private _circleOfConfusion;
  148994. /**
  148995. * @hidden Internal, blurs from high to low
  148996. */
  148997. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  148998. private _depthOfFieldBlurY;
  148999. private _dofMerge;
  149000. /**
  149001. * @hidden Internal post processes in depth of field effect
  149002. */
  149003. _effects: Array<PostProcess>;
  149004. /**
  149005. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  149006. */
  149007. set focalLength(value: number);
  149008. get focalLength(): number;
  149009. /**
  149010. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149011. */
  149012. set fStop(value: number);
  149013. get fStop(): number;
  149014. /**
  149015. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149016. */
  149017. set focusDistance(value: number);
  149018. get focusDistance(): number;
  149019. /**
  149020. * 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.
  149021. */
  149022. set lensSize(value: number);
  149023. get lensSize(): number;
  149024. /**
  149025. * Creates a new instance DepthOfFieldEffect
  149026. * @param scene The scene the effect belongs to.
  149027. * @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.
  149028. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149029. * @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)
  149030. */
  149031. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  149032. /**
  149033. * Get the current class name of the current effet
  149034. * @returns "DepthOfFieldEffect"
  149035. */
  149036. getClassName(): string;
  149037. /**
  149038. * 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.
  149039. */
  149040. set depthTexture(value: RenderTargetTexture);
  149041. /**
  149042. * Disposes each of the internal effects for a given camera.
  149043. * @param camera The camera to dispose the effect on.
  149044. */
  149045. disposeEffects(camera: Camera): void;
  149046. /**
  149047. * @hidden Internal
  149048. */
  149049. _updateEffects(): void;
  149050. /**
  149051. * Internal
  149052. * @returns if all the contained post processes are ready.
  149053. * @hidden
  149054. */
  149055. _isReady(): boolean;
  149056. }
  149057. }
  149058. declare module BABYLON {
  149059. /** @hidden */
  149060. export var displayPassPixelShader: {
  149061. name: string;
  149062. shader: string;
  149063. };
  149064. }
  149065. declare module BABYLON {
  149066. /**
  149067. * DisplayPassPostProcess which produces an output the same as it's input
  149068. */
  149069. export class DisplayPassPostProcess extends PostProcess {
  149070. /**
  149071. * Gets a string identifying the name of the class
  149072. * @returns "DisplayPassPostProcess" string
  149073. */
  149074. getClassName(): string;
  149075. /**
  149076. * Creates the DisplayPassPostProcess
  149077. * @param name The name of the effect.
  149078. * @param options The required width/height ratio to downsize to before computing the render pass.
  149079. * @param camera The camera to apply the render pass to.
  149080. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149081. * @param engine The engine which the post process will be applied. (default: current engine)
  149082. * @param reusable If the post process can be reused on the same frame. (default: false)
  149083. */
  149084. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149085. /** @hidden */
  149086. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  149087. }
  149088. }
  149089. declare module BABYLON {
  149090. /** @hidden */
  149091. export var filterPixelShader: {
  149092. name: string;
  149093. shader: string;
  149094. };
  149095. }
  149096. declare module BABYLON {
  149097. /**
  149098. * Applies a kernel filter to the image
  149099. */
  149100. export class FilterPostProcess extends PostProcess {
  149101. /** The matrix to be applied to the image */
  149102. kernelMatrix: Matrix;
  149103. /**
  149104. * Gets a string identifying the name of the class
  149105. * @returns "FilterPostProcess" string
  149106. */
  149107. getClassName(): string;
  149108. /**
  149109. *
  149110. * @param name The name of the effect.
  149111. * @param kernelMatrix The matrix to be applied to the image
  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. */
  149118. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149119. /** @hidden */
  149120. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  149121. }
  149122. }
  149123. declare module BABYLON {
  149124. /** @hidden */
  149125. export var fxaaPixelShader: {
  149126. name: string;
  149127. shader: string;
  149128. };
  149129. }
  149130. declare module BABYLON {
  149131. /** @hidden */
  149132. export var fxaaVertexShader: {
  149133. name: string;
  149134. shader: string;
  149135. };
  149136. }
  149137. declare module BABYLON {
  149138. /**
  149139. * Fxaa post process
  149140. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  149141. */
  149142. export class FxaaPostProcess extends PostProcess {
  149143. /**
  149144. * Gets a string identifying the name of the class
  149145. * @returns "FxaaPostProcess" string
  149146. */
  149147. getClassName(): string;
  149148. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149149. private _getDefines;
  149150. /** @hidden */
  149151. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  149152. }
  149153. }
  149154. declare module BABYLON {
  149155. /** @hidden */
  149156. export var grainPixelShader: {
  149157. name: string;
  149158. shader: string;
  149159. };
  149160. }
  149161. declare module BABYLON {
  149162. /**
  149163. * The GrainPostProcess adds noise to the image at mid luminance levels
  149164. */
  149165. export class GrainPostProcess extends PostProcess {
  149166. /**
  149167. * The intensity of the grain added (default: 30)
  149168. */
  149169. intensity: number;
  149170. /**
  149171. * If the grain should be randomized on every frame
  149172. */
  149173. animated: boolean;
  149174. /**
  149175. * Gets a string identifying the name of the class
  149176. * @returns "GrainPostProcess" string
  149177. */
  149178. getClassName(): string;
  149179. /**
  149180. * Creates a new instance of @see GrainPostProcess
  149181. * @param name The name of the effect.
  149182. * @param options The required width/height ratio to downsize to before computing the render pass.
  149183. * @param camera The camera to apply the render pass to.
  149184. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149185. * @param engine The engine which the post process will be applied. (default: current engine)
  149186. * @param reusable If the post process can be reused on the same frame. (default: false)
  149187. * @param textureType Type of textures used when performing the post process. (default: 0)
  149188. * @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)
  149189. */
  149190. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149191. /** @hidden */
  149192. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  149193. }
  149194. }
  149195. declare module BABYLON {
  149196. /** @hidden */
  149197. export var highlightsPixelShader: {
  149198. name: string;
  149199. shader: string;
  149200. };
  149201. }
  149202. declare module BABYLON {
  149203. /**
  149204. * Extracts highlights from the image
  149205. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  149206. */
  149207. export class HighlightsPostProcess extends PostProcess {
  149208. /**
  149209. * Gets a string identifying the name of the class
  149210. * @returns "HighlightsPostProcess" string
  149211. */
  149212. getClassName(): string;
  149213. /**
  149214. * Extracts highlights from the image
  149215. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  149216. * @param name The name of the effect.
  149217. * @param options The required width/height ratio to downsize to before computing the render pass.
  149218. * @param camera The camera to apply the render pass to.
  149219. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149220. * @param engine The engine which the post process will be applied. (default: current engine)
  149221. * @param reusable If the post process can be reused on the same frame. (default: false)
  149222. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  149223. */
  149224. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149225. }
  149226. }
  149227. declare module BABYLON {
  149228. /** @hidden */
  149229. export var mrtFragmentDeclaration: {
  149230. name: string;
  149231. shader: string;
  149232. };
  149233. }
  149234. declare module BABYLON {
  149235. /** @hidden */
  149236. export var geometryPixelShader: {
  149237. name: string;
  149238. shader: string;
  149239. };
  149240. }
  149241. declare module BABYLON {
  149242. /** @hidden */
  149243. export var geometryVertexShader: {
  149244. name: string;
  149245. shader: string;
  149246. };
  149247. }
  149248. declare module BABYLON {
  149249. /** @hidden */
  149250. interface ISavedTransformationMatrix {
  149251. world: Matrix;
  149252. viewProjection: Matrix;
  149253. }
  149254. /**
  149255. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  149256. */
  149257. export class GeometryBufferRenderer {
  149258. /**
  149259. * Constant used to retrieve the position texture index in the G-Buffer textures array
  149260. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  149261. */
  149262. static readonly POSITION_TEXTURE_TYPE: number;
  149263. /**
  149264. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  149265. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  149266. */
  149267. static readonly VELOCITY_TEXTURE_TYPE: number;
  149268. /**
  149269. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  149270. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  149271. */
  149272. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  149273. /**
  149274. * Dictionary used to store the previous transformation matrices of each rendered mesh
  149275. * in order to compute objects velocities when enableVelocity is set to "true"
  149276. * @hidden
  149277. */
  149278. _previousTransformationMatrices: {
  149279. [index: number]: ISavedTransformationMatrix;
  149280. };
  149281. /**
  149282. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  149283. * in order to compute objects velocities when enableVelocity is set to "true"
  149284. * @hidden
  149285. */
  149286. _previousBonesTransformationMatrices: {
  149287. [index: number]: Float32Array;
  149288. };
  149289. /**
  149290. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  149291. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  149292. */
  149293. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  149294. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  149295. renderTransparentMeshes: boolean;
  149296. private _scene;
  149297. private _resizeObserver;
  149298. private _multiRenderTarget;
  149299. private _ratio;
  149300. private _enablePosition;
  149301. private _enableVelocity;
  149302. private _enableReflectivity;
  149303. private _positionIndex;
  149304. private _velocityIndex;
  149305. private _reflectivityIndex;
  149306. protected _effect: Effect;
  149307. protected _cachedDefines: string;
  149308. /**
  149309. * Set the render list (meshes to be rendered) used in the G buffer.
  149310. */
  149311. set renderList(meshes: Mesh[]);
  149312. /**
  149313. * Gets wether or not G buffer are supported by the running hardware.
  149314. * This requires draw buffer supports
  149315. */
  149316. get isSupported(): boolean;
  149317. /**
  149318. * Returns the index of the given texture type in the G-Buffer textures array
  149319. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  149320. * @returns the index of the given texture type in the G-Buffer textures array
  149321. */
  149322. getTextureIndex(textureType: number): number;
  149323. /**
  149324. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  149325. */
  149326. get enablePosition(): boolean;
  149327. /**
  149328. * Sets whether or not objects positions are enabled for the G buffer.
  149329. */
  149330. set enablePosition(enable: boolean);
  149331. /**
  149332. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  149333. */
  149334. get enableVelocity(): boolean;
  149335. /**
  149336. * Sets wether or not objects velocities are enabled for the G buffer.
  149337. */
  149338. set enableVelocity(enable: boolean);
  149339. /**
  149340. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  149341. */
  149342. get enableReflectivity(): boolean;
  149343. /**
  149344. * Sets wether or not objects roughness are enabled for the G buffer.
  149345. */
  149346. set enableReflectivity(enable: boolean);
  149347. /**
  149348. * Gets the scene associated with the buffer.
  149349. */
  149350. get scene(): Scene;
  149351. /**
  149352. * Gets the ratio used by the buffer during its creation.
  149353. * How big is the buffer related to the main canvas.
  149354. */
  149355. get ratio(): number;
  149356. /** @hidden */
  149357. static _SceneComponentInitialization: (scene: Scene) => void;
  149358. /**
  149359. * Creates a new G Buffer for the scene
  149360. * @param scene The scene the buffer belongs to
  149361. * @param ratio How big is the buffer related to the main canvas.
  149362. */
  149363. constructor(scene: Scene, ratio?: number);
  149364. /**
  149365. * Checks wether everything is ready to render a submesh to the G buffer.
  149366. * @param subMesh the submesh to check readiness for
  149367. * @param useInstances is the mesh drawn using instance or not
  149368. * @returns true if ready otherwise false
  149369. */
  149370. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149371. /**
  149372. * Gets the current underlying G Buffer.
  149373. * @returns the buffer
  149374. */
  149375. getGBuffer(): MultiRenderTarget;
  149376. /**
  149377. * Gets the number of samples used to render the buffer (anti aliasing).
  149378. */
  149379. get samples(): number;
  149380. /**
  149381. * Sets the number of samples used to render the buffer (anti aliasing).
  149382. */
  149383. set samples(value: number);
  149384. /**
  149385. * Disposes the renderer and frees up associated resources.
  149386. */
  149387. dispose(): void;
  149388. protected _createRenderTargets(): void;
  149389. private _copyBonesTransformationMatrices;
  149390. }
  149391. }
  149392. declare module BABYLON {
  149393. interface Scene {
  149394. /** @hidden (Backing field) */
  149395. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  149396. /**
  149397. * Gets or Sets the current geometry buffer associated to the scene.
  149398. */
  149399. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  149400. /**
  149401. * Enables a GeometryBufferRender and associates it with the scene
  149402. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  149403. * @returns the GeometryBufferRenderer
  149404. */
  149405. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  149406. /**
  149407. * Disables the GeometryBufferRender associated with the scene
  149408. */
  149409. disableGeometryBufferRenderer(): void;
  149410. }
  149411. /**
  149412. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  149413. * in several rendering techniques.
  149414. */
  149415. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  149416. /**
  149417. * The component name helpful to identify the component in the list of scene components.
  149418. */
  149419. readonly name: string;
  149420. /**
  149421. * The scene the component belongs to.
  149422. */
  149423. scene: Scene;
  149424. /**
  149425. * Creates a new instance of the component for the given scene
  149426. * @param scene Defines the scene to register the component in
  149427. */
  149428. constructor(scene: Scene);
  149429. /**
  149430. * Registers the component in a given scene
  149431. */
  149432. register(): void;
  149433. /**
  149434. * Rebuilds the elements related to this component in case of
  149435. * context lost for instance.
  149436. */
  149437. rebuild(): void;
  149438. /**
  149439. * Disposes the component and the associated ressources
  149440. */
  149441. dispose(): void;
  149442. private _gatherRenderTargets;
  149443. }
  149444. }
  149445. declare module BABYLON {
  149446. /** @hidden */
  149447. export var motionBlurPixelShader: {
  149448. name: string;
  149449. shader: string;
  149450. };
  149451. }
  149452. declare module BABYLON {
  149453. /**
  149454. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  149455. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  149456. * As an example, all you have to do is to create the post-process:
  149457. * var mb = new BABYLON.MotionBlurPostProcess(
  149458. * 'mb', // The name of the effect.
  149459. * scene, // The scene containing the objects to blur according to their velocity.
  149460. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  149461. * camera // The camera to apply the render pass to.
  149462. * );
  149463. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  149464. */
  149465. export class MotionBlurPostProcess extends PostProcess {
  149466. /**
  149467. * Defines how much the image is blurred by the movement. Default value is equal to 1
  149468. */
  149469. motionStrength: number;
  149470. /**
  149471. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  149472. */
  149473. get motionBlurSamples(): number;
  149474. /**
  149475. * Sets the number of iterations to be used for motion blur quality
  149476. */
  149477. set motionBlurSamples(samples: number);
  149478. private _motionBlurSamples;
  149479. private _geometryBufferRenderer;
  149480. /**
  149481. * Gets a string identifying the name of the class
  149482. * @returns "MotionBlurPostProcess" string
  149483. */
  149484. getClassName(): string;
  149485. /**
  149486. * Creates a new instance MotionBlurPostProcess
  149487. * @param name The name of the effect.
  149488. * @param scene The scene containing the objects to blur according to their velocity.
  149489. * @param options The required width/height ratio to downsize to before computing the render pass.
  149490. * @param camera The camera to apply the render pass to.
  149491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149492. * @param engine The engine which the post process will be applied. (default: current engine)
  149493. * @param reusable If the post process can be reused on the same frame. (default: false)
  149494. * @param textureType Type of textures used when performing the post process. (default: 0)
  149495. * @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)
  149496. */
  149497. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149498. /**
  149499. * Excludes the given skinned mesh from computing bones velocities.
  149500. * 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.
  149501. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  149502. */
  149503. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  149504. /**
  149505. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  149506. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  149507. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  149508. */
  149509. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  149510. /**
  149511. * Disposes the post process.
  149512. * @param camera The camera to dispose the post process on.
  149513. */
  149514. dispose(camera?: Camera): void;
  149515. /** @hidden */
  149516. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  149517. }
  149518. }
  149519. declare module BABYLON {
  149520. /** @hidden */
  149521. export var refractionPixelShader: {
  149522. name: string;
  149523. shader: string;
  149524. };
  149525. }
  149526. declare module BABYLON {
  149527. /**
  149528. * Post process which applies a refractin texture
  149529. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  149530. */
  149531. export class RefractionPostProcess extends PostProcess {
  149532. private _refTexture;
  149533. private _ownRefractionTexture;
  149534. /** the base color of the refraction (used to taint the rendering) */
  149535. color: Color3;
  149536. /** simulated refraction depth */
  149537. depth: number;
  149538. /** the coefficient of the base color (0 to remove base color tainting) */
  149539. colorLevel: number;
  149540. /** Gets the url used to load the refraction texture */
  149541. refractionTextureUrl: string;
  149542. /**
  149543. * Gets or sets the refraction texture
  149544. * Please note that you are responsible for disposing the texture if you set it manually
  149545. */
  149546. get refractionTexture(): Texture;
  149547. set refractionTexture(value: Texture);
  149548. /**
  149549. * Gets a string identifying the name of the class
  149550. * @returns "RefractionPostProcess" string
  149551. */
  149552. getClassName(): string;
  149553. /**
  149554. * Initializes the RefractionPostProcess
  149555. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  149556. * @param name The name of the effect.
  149557. * @param refractionTextureUrl Url of the refraction texture to use
  149558. * @param color the base color of the refraction (used to taint the rendering)
  149559. * @param depth simulated refraction depth
  149560. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  149561. * @param camera The camera to apply the render pass to.
  149562. * @param options The required width/height ratio to downsize to before computing the render pass.
  149563. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149564. * @param engine The engine which the post process will be applied. (default: current engine)
  149565. * @param reusable If the post process can be reused on the same frame. (default: false)
  149566. */
  149567. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149568. /**
  149569. * Disposes of the post process
  149570. * @param camera Camera to dispose post process on
  149571. */
  149572. dispose(camera: Camera): void;
  149573. /** @hidden */
  149574. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  149575. }
  149576. }
  149577. declare module BABYLON {
  149578. /** @hidden */
  149579. export var sharpenPixelShader: {
  149580. name: string;
  149581. shader: string;
  149582. };
  149583. }
  149584. declare module BABYLON {
  149585. /**
  149586. * The SharpenPostProcess applies a sharpen kernel to every pixel
  149587. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  149588. */
  149589. export class SharpenPostProcess extends PostProcess {
  149590. /**
  149591. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  149592. */
  149593. colorAmount: number;
  149594. /**
  149595. * How much sharpness should be applied (default: 0.3)
  149596. */
  149597. edgeAmount: number;
  149598. /**
  149599. * Gets a string identifying the name of the class
  149600. * @returns "SharpenPostProcess" string
  149601. */
  149602. getClassName(): string;
  149603. /**
  149604. * Creates a new instance ConvolutionPostProcess
  149605. * @param name The name of the effect.
  149606. * @param options The required width/height ratio to downsize to before computing the render pass.
  149607. * @param camera The camera to apply the render pass to.
  149608. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149609. * @param engine The engine which the post process will be applied. (default: current engine)
  149610. * @param reusable If the post process can be reused on the same frame. (default: false)
  149611. * @param textureType Type of textures used when performing the post process. (default: 0)
  149612. * @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)
  149613. */
  149614. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149615. /** @hidden */
  149616. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  149617. }
  149618. }
  149619. declare module BABYLON {
  149620. /**
  149621. * PostProcessRenderPipeline
  149622. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149623. */
  149624. export class PostProcessRenderPipeline {
  149625. private engine;
  149626. private _renderEffects;
  149627. private _renderEffectsForIsolatedPass;
  149628. /**
  149629. * List of inspectable custom properties (used by the Inspector)
  149630. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  149631. */
  149632. inspectableCustomProperties: IInspectable[];
  149633. /**
  149634. * @hidden
  149635. */
  149636. protected _cameras: Camera[];
  149637. /** @hidden */
  149638. _name: string;
  149639. /**
  149640. * Gets pipeline name
  149641. */
  149642. get name(): string;
  149643. /** Gets the list of attached cameras */
  149644. get cameras(): Camera[];
  149645. /**
  149646. * Initializes a PostProcessRenderPipeline
  149647. * @param engine engine to add the pipeline to
  149648. * @param name name of the pipeline
  149649. */
  149650. constructor(engine: Engine, name: string);
  149651. /**
  149652. * Gets the class name
  149653. * @returns "PostProcessRenderPipeline"
  149654. */
  149655. getClassName(): string;
  149656. /**
  149657. * If all the render effects in the pipeline are supported
  149658. */
  149659. get isSupported(): boolean;
  149660. /**
  149661. * Adds an effect to the pipeline
  149662. * @param renderEffect the effect to add
  149663. */
  149664. addEffect(renderEffect: PostProcessRenderEffect): void;
  149665. /** @hidden */
  149666. _rebuild(): void;
  149667. /** @hidden */
  149668. _enableEffect(renderEffectName: string, cameras: Camera): void;
  149669. /** @hidden */
  149670. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  149671. /** @hidden */
  149672. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  149673. /** @hidden */
  149674. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  149675. /** @hidden */
  149676. _attachCameras(cameras: Camera, unique: boolean): void;
  149677. /** @hidden */
  149678. _attachCameras(cameras: Camera[], unique: boolean): void;
  149679. /** @hidden */
  149680. _detachCameras(cameras: Camera): void;
  149681. /** @hidden */
  149682. _detachCameras(cameras: Nullable<Camera[]>): void;
  149683. /** @hidden */
  149684. _update(): void;
  149685. /** @hidden */
  149686. _reset(): void;
  149687. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  149688. /**
  149689. * Sets the required values to the prepass renderer.
  149690. * @param prePassRenderer defines the prepass renderer to setup.
  149691. * @returns true if the pre pass is needed.
  149692. */
  149693. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  149694. /**
  149695. * Disposes of the pipeline
  149696. */
  149697. dispose(): void;
  149698. }
  149699. }
  149700. declare module BABYLON {
  149701. /**
  149702. * PostProcessRenderPipelineManager class
  149703. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149704. */
  149705. export class PostProcessRenderPipelineManager {
  149706. private _renderPipelines;
  149707. /**
  149708. * Initializes a PostProcessRenderPipelineManager
  149709. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149710. */
  149711. constructor();
  149712. /**
  149713. * Gets the list of supported render pipelines
  149714. */
  149715. get supportedPipelines(): PostProcessRenderPipeline[];
  149716. /**
  149717. * Adds a pipeline to the manager
  149718. * @param renderPipeline The pipeline to add
  149719. */
  149720. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  149721. /**
  149722. * Attaches a camera to the pipeline
  149723. * @param renderPipelineName The name of the pipeline to attach to
  149724. * @param cameras the camera to attach
  149725. * @param unique if the camera can be attached multiple times to the pipeline
  149726. */
  149727. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  149728. /**
  149729. * Detaches a camera from the pipeline
  149730. * @param renderPipelineName The name of the pipeline to detach from
  149731. * @param cameras the camera to detach
  149732. */
  149733. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  149734. /**
  149735. * Enables an effect by name on a pipeline
  149736. * @param renderPipelineName the name of the pipeline to enable the effect in
  149737. * @param renderEffectName the name of the effect to enable
  149738. * @param cameras the cameras that the effect should be enabled on
  149739. */
  149740. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  149741. /**
  149742. * Disables an effect by name on a pipeline
  149743. * @param renderPipelineName the name of the pipeline to disable the effect in
  149744. * @param renderEffectName the name of the effect to disable
  149745. * @param cameras the cameras that the effect should be disabled on
  149746. */
  149747. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  149748. /**
  149749. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  149750. */
  149751. update(): void;
  149752. /** @hidden */
  149753. _rebuild(): void;
  149754. /**
  149755. * Disposes of the manager and pipelines
  149756. */
  149757. dispose(): void;
  149758. }
  149759. }
  149760. declare module BABYLON {
  149761. interface Scene {
  149762. /** @hidden (Backing field) */
  149763. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  149764. /**
  149765. * Gets the postprocess render pipeline manager
  149766. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149767. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  149768. */
  149769. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  149770. }
  149771. /**
  149772. * Defines the Render Pipeline scene component responsible to rendering pipelines
  149773. */
  149774. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  149775. /**
  149776. * The component name helpfull to identify the component in the list of scene components.
  149777. */
  149778. readonly name: string;
  149779. /**
  149780. * The scene the component belongs to.
  149781. */
  149782. scene: Scene;
  149783. /**
  149784. * Creates a new instance of the component for the given scene
  149785. * @param scene Defines the scene to register the component in
  149786. */
  149787. constructor(scene: Scene);
  149788. /**
  149789. * Registers the component in a given scene
  149790. */
  149791. register(): void;
  149792. /**
  149793. * Rebuilds the elements related to this component in case of
  149794. * context lost for instance.
  149795. */
  149796. rebuild(): void;
  149797. /**
  149798. * Disposes the component and the associated ressources
  149799. */
  149800. dispose(): void;
  149801. private _gatherRenderTargets;
  149802. }
  149803. }
  149804. declare module BABYLON {
  149805. /**
  149806. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  149807. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  149808. */
  149809. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  149810. private _scene;
  149811. private _camerasToBeAttached;
  149812. /**
  149813. * ID of the sharpen post process,
  149814. */
  149815. private readonly SharpenPostProcessId;
  149816. /**
  149817. * @ignore
  149818. * ID of the image processing post process;
  149819. */
  149820. readonly ImageProcessingPostProcessId: string;
  149821. /**
  149822. * @ignore
  149823. * ID of the Fast Approximate Anti-Aliasing post process;
  149824. */
  149825. readonly FxaaPostProcessId: string;
  149826. /**
  149827. * ID of the chromatic aberration post process,
  149828. */
  149829. private readonly ChromaticAberrationPostProcessId;
  149830. /**
  149831. * ID of the grain post process
  149832. */
  149833. private readonly GrainPostProcessId;
  149834. /**
  149835. * Sharpen post process which will apply a sharpen convolution to enhance edges
  149836. */
  149837. sharpen: SharpenPostProcess;
  149838. private _sharpenEffect;
  149839. private bloom;
  149840. /**
  149841. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  149842. */
  149843. depthOfField: DepthOfFieldEffect;
  149844. /**
  149845. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  149846. */
  149847. fxaa: FxaaPostProcess;
  149848. /**
  149849. * Image post processing pass used to perform operations such as tone mapping or color grading.
  149850. */
  149851. imageProcessing: ImageProcessingPostProcess;
  149852. /**
  149853. * Chromatic aberration post process which will shift rgb colors in the image
  149854. */
  149855. chromaticAberration: ChromaticAberrationPostProcess;
  149856. private _chromaticAberrationEffect;
  149857. /**
  149858. * Grain post process which add noise to the image
  149859. */
  149860. grain: GrainPostProcess;
  149861. private _grainEffect;
  149862. /**
  149863. * Glow post process which adds a glow to emissive areas of the image
  149864. */
  149865. private _glowLayer;
  149866. /**
  149867. * Animations which can be used to tweak settings over a period of time
  149868. */
  149869. animations: Animation[];
  149870. private _imageProcessingConfigurationObserver;
  149871. private _sharpenEnabled;
  149872. private _bloomEnabled;
  149873. private _depthOfFieldEnabled;
  149874. private _depthOfFieldBlurLevel;
  149875. private _fxaaEnabled;
  149876. private _imageProcessingEnabled;
  149877. private _defaultPipelineTextureType;
  149878. private _bloomScale;
  149879. private _chromaticAberrationEnabled;
  149880. private _grainEnabled;
  149881. private _buildAllowed;
  149882. /**
  149883. * Gets active scene
  149884. */
  149885. get scene(): Scene;
  149886. /**
  149887. * Enable or disable the sharpen process from the pipeline
  149888. */
  149889. set sharpenEnabled(enabled: boolean);
  149890. get sharpenEnabled(): boolean;
  149891. private _resizeObserver;
  149892. private _hardwareScaleLevel;
  149893. private _bloomKernel;
  149894. /**
  149895. * Specifies the size of the bloom blur kernel, relative to the final output size
  149896. */
  149897. get bloomKernel(): number;
  149898. set bloomKernel(value: number);
  149899. /**
  149900. * Specifies the weight of the bloom in the final rendering
  149901. */
  149902. private _bloomWeight;
  149903. /**
  149904. * Specifies the luma threshold for the area that will be blurred by the bloom
  149905. */
  149906. private _bloomThreshold;
  149907. private _hdr;
  149908. /**
  149909. * The strength of the bloom.
  149910. */
  149911. set bloomWeight(value: number);
  149912. get bloomWeight(): number;
  149913. /**
  149914. * The strength of the bloom.
  149915. */
  149916. set bloomThreshold(value: number);
  149917. get bloomThreshold(): number;
  149918. /**
  149919. * The scale of the bloom, lower value will provide better performance.
  149920. */
  149921. set bloomScale(value: number);
  149922. get bloomScale(): number;
  149923. /**
  149924. * Enable or disable the bloom from the pipeline
  149925. */
  149926. set bloomEnabled(enabled: boolean);
  149927. get bloomEnabled(): boolean;
  149928. private _rebuildBloom;
  149929. /**
  149930. * If the depth of field is enabled.
  149931. */
  149932. get depthOfFieldEnabled(): boolean;
  149933. set depthOfFieldEnabled(enabled: boolean);
  149934. /**
  149935. * Blur level of the depth of field effect. (Higher blur will effect performance)
  149936. */
  149937. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  149938. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  149939. /**
  149940. * If the anti aliasing is enabled.
  149941. */
  149942. set fxaaEnabled(enabled: boolean);
  149943. get fxaaEnabled(): boolean;
  149944. private _samples;
  149945. /**
  149946. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  149947. */
  149948. set samples(sampleCount: number);
  149949. get samples(): number;
  149950. /**
  149951. * If image processing is enabled.
  149952. */
  149953. set imageProcessingEnabled(enabled: boolean);
  149954. get imageProcessingEnabled(): boolean;
  149955. /**
  149956. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  149957. */
  149958. set glowLayerEnabled(enabled: boolean);
  149959. get glowLayerEnabled(): boolean;
  149960. /**
  149961. * Gets the glow layer (or null if not defined)
  149962. */
  149963. get glowLayer(): Nullable<GlowLayer>;
  149964. /**
  149965. * Enable or disable the chromaticAberration process from the pipeline
  149966. */
  149967. set chromaticAberrationEnabled(enabled: boolean);
  149968. get chromaticAberrationEnabled(): boolean;
  149969. /**
  149970. * Enable or disable the grain process from the pipeline
  149971. */
  149972. set grainEnabled(enabled: boolean);
  149973. get grainEnabled(): boolean;
  149974. /**
  149975. * @constructor
  149976. * @param name - The rendering pipeline name (default: "")
  149977. * @param hdr - If high dynamic range textures should be used (default: true)
  149978. * @param scene - The scene linked to this pipeline (default: the last created scene)
  149979. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  149980. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  149981. */
  149982. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  149983. /**
  149984. * Get the class name
  149985. * @returns "DefaultRenderingPipeline"
  149986. */
  149987. getClassName(): string;
  149988. /**
  149989. * Force the compilation of the entire pipeline.
  149990. */
  149991. prepare(): void;
  149992. private _hasCleared;
  149993. private _prevPostProcess;
  149994. private _prevPrevPostProcess;
  149995. private _setAutoClearAndTextureSharing;
  149996. private _depthOfFieldSceneObserver;
  149997. private _buildPipeline;
  149998. private _disposePostProcesses;
  149999. /**
  150000. * Adds a camera to the pipeline
  150001. * @param camera the camera to be added
  150002. */
  150003. addCamera(camera: Camera): void;
  150004. /**
  150005. * Removes a camera from the pipeline
  150006. * @param camera the camera to remove
  150007. */
  150008. removeCamera(camera: Camera): void;
  150009. /**
  150010. * Dispose of the pipeline and stop all post processes
  150011. */
  150012. dispose(): void;
  150013. /**
  150014. * Serialize the rendering pipeline (Used when exporting)
  150015. * @returns the serialized object
  150016. */
  150017. serialize(): any;
  150018. /**
  150019. * Parse the serialized pipeline
  150020. * @param source Source pipeline.
  150021. * @param scene The scene to load the pipeline to.
  150022. * @param rootUrl The URL of the serialized pipeline.
  150023. * @returns An instantiated pipeline from the serialized object.
  150024. */
  150025. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  150026. }
  150027. }
  150028. declare module BABYLON {
  150029. /** @hidden */
  150030. export var lensHighlightsPixelShader: {
  150031. name: string;
  150032. shader: string;
  150033. };
  150034. }
  150035. declare module BABYLON {
  150036. /** @hidden */
  150037. export var depthOfFieldPixelShader: {
  150038. name: string;
  150039. shader: string;
  150040. };
  150041. }
  150042. declare module BABYLON {
  150043. /**
  150044. * BABYLON.JS Chromatic Aberration GLSL Shader
  150045. * Author: Olivier Guyot
  150046. * Separates very slightly R, G and B colors on the edges of the screen
  150047. * Inspired by Francois Tarlier & Martins Upitis
  150048. */
  150049. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  150050. /**
  150051. * @ignore
  150052. * The chromatic aberration PostProcess id in the pipeline
  150053. */
  150054. LensChromaticAberrationEffect: string;
  150055. /**
  150056. * @ignore
  150057. * The highlights enhancing PostProcess id in the pipeline
  150058. */
  150059. HighlightsEnhancingEffect: string;
  150060. /**
  150061. * @ignore
  150062. * The depth-of-field PostProcess id in the pipeline
  150063. */
  150064. LensDepthOfFieldEffect: string;
  150065. private _scene;
  150066. private _depthTexture;
  150067. private _grainTexture;
  150068. private _chromaticAberrationPostProcess;
  150069. private _highlightsPostProcess;
  150070. private _depthOfFieldPostProcess;
  150071. private _edgeBlur;
  150072. private _grainAmount;
  150073. private _chromaticAberration;
  150074. private _distortion;
  150075. private _highlightsGain;
  150076. private _highlightsThreshold;
  150077. private _dofDistance;
  150078. private _dofAperture;
  150079. private _dofDarken;
  150080. private _dofPentagon;
  150081. private _blurNoise;
  150082. /**
  150083. * @constructor
  150084. *
  150085. * Effect parameters are as follow:
  150086. * {
  150087. * chromatic_aberration: number; // from 0 to x (1 for realism)
  150088. * edge_blur: number; // from 0 to x (1 for realism)
  150089. * distortion: number; // from 0 to x (1 for realism)
  150090. * grain_amount: number; // from 0 to 1
  150091. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  150092. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  150093. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  150094. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  150095. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  150096. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  150097. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  150098. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  150099. * }
  150100. * Note: if an effect parameter is unset, effect is disabled
  150101. *
  150102. * @param name The rendering pipeline name
  150103. * @param parameters - An object containing all parameters (see above)
  150104. * @param scene The scene linked to this pipeline
  150105. * @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)
  150106. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150107. */
  150108. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  150109. /**
  150110. * Get the class name
  150111. * @returns "LensRenderingPipeline"
  150112. */
  150113. getClassName(): string;
  150114. /**
  150115. * Gets associated scene
  150116. */
  150117. get scene(): Scene;
  150118. /**
  150119. * Gets or sets the edge blur
  150120. */
  150121. get edgeBlur(): number;
  150122. set edgeBlur(value: number);
  150123. /**
  150124. * Gets or sets the grain amount
  150125. */
  150126. get grainAmount(): number;
  150127. set grainAmount(value: number);
  150128. /**
  150129. * Gets or sets the chromatic aberration amount
  150130. */
  150131. get chromaticAberration(): number;
  150132. set chromaticAberration(value: number);
  150133. /**
  150134. * Gets or sets the depth of field aperture
  150135. */
  150136. get dofAperture(): number;
  150137. set dofAperture(value: number);
  150138. /**
  150139. * Gets or sets the edge distortion
  150140. */
  150141. get edgeDistortion(): number;
  150142. set edgeDistortion(value: number);
  150143. /**
  150144. * Gets or sets the depth of field distortion
  150145. */
  150146. get dofDistortion(): number;
  150147. set dofDistortion(value: number);
  150148. /**
  150149. * Gets or sets the darken out of focus amount
  150150. */
  150151. get darkenOutOfFocus(): number;
  150152. set darkenOutOfFocus(value: number);
  150153. /**
  150154. * Gets or sets a boolean indicating if blur noise is enabled
  150155. */
  150156. get blurNoise(): boolean;
  150157. set blurNoise(value: boolean);
  150158. /**
  150159. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  150160. */
  150161. get pentagonBokeh(): boolean;
  150162. set pentagonBokeh(value: boolean);
  150163. /**
  150164. * Gets or sets the highlight grain amount
  150165. */
  150166. get highlightsGain(): number;
  150167. set highlightsGain(value: number);
  150168. /**
  150169. * Gets or sets the highlight threshold
  150170. */
  150171. get highlightsThreshold(): number;
  150172. set highlightsThreshold(value: number);
  150173. /**
  150174. * Sets the amount of blur at the edges
  150175. * @param amount blur amount
  150176. */
  150177. setEdgeBlur(amount: number): void;
  150178. /**
  150179. * Sets edge blur to 0
  150180. */
  150181. disableEdgeBlur(): void;
  150182. /**
  150183. * Sets the amout of grain
  150184. * @param amount Amount of grain
  150185. */
  150186. setGrainAmount(amount: number): void;
  150187. /**
  150188. * Set grain amount to 0
  150189. */
  150190. disableGrain(): void;
  150191. /**
  150192. * Sets the chromatic aberration amount
  150193. * @param amount amount of chromatic aberration
  150194. */
  150195. setChromaticAberration(amount: number): void;
  150196. /**
  150197. * Sets chromatic aberration amount to 0
  150198. */
  150199. disableChromaticAberration(): void;
  150200. /**
  150201. * Sets the EdgeDistortion amount
  150202. * @param amount amount of EdgeDistortion
  150203. */
  150204. setEdgeDistortion(amount: number): void;
  150205. /**
  150206. * Sets edge distortion to 0
  150207. */
  150208. disableEdgeDistortion(): void;
  150209. /**
  150210. * Sets the FocusDistance amount
  150211. * @param amount amount of FocusDistance
  150212. */
  150213. setFocusDistance(amount: number): void;
  150214. /**
  150215. * Disables depth of field
  150216. */
  150217. disableDepthOfField(): void;
  150218. /**
  150219. * Sets the Aperture amount
  150220. * @param amount amount of Aperture
  150221. */
  150222. setAperture(amount: number): void;
  150223. /**
  150224. * Sets the DarkenOutOfFocus amount
  150225. * @param amount amount of DarkenOutOfFocus
  150226. */
  150227. setDarkenOutOfFocus(amount: number): void;
  150228. private _pentagonBokehIsEnabled;
  150229. /**
  150230. * Creates a pentagon bokeh effect
  150231. */
  150232. enablePentagonBokeh(): void;
  150233. /**
  150234. * Disables the pentagon bokeh effect
  150235. */
  150236. disablePentagonBokeh(): void;
  150237. /**
  150238. * Enables noise blur
  150239. */
  150240. enableNoiseBlur(): void;
  150241. /**
  150242. * Disables noise blur
  150243. */
  150244. disableNoiseBlur(): void;
  150245. /**
  150246. * Sets the HighlightsGain amount
  150247. * @param amount amount of HighlightsGain
  150248. */
  150249. setHighlightsGain(amount: number): void;
  150250. /**
  150251. * Sets the HighlightsThreshold amount
  150252. * @param amount amount of HighlightsThreshold
  150253. */
  150254. setHighlightsThreshold(amount: number): void;
  150255. /**
  150256. * Disables highlights
  150257. */
  150258. disableHighlights(): void;
  150259. /**
  150260. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  150261. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  150262. */
  150263. dispose(disableDepthRender?: boolean): void;
  150264. private _createChromaticAberrationPostProcess;
  150265. private _createHighlightsPostProcess;
  150266. private _createDepthOfFieldPostProcess;
  150267. private _createGrainTexture;
  150268. }
  150269. }
  150270. declare module BABYLON {
  150271. /** @hidden */
  150272. export var ssao2PixelShader: {
  150273. name: string;
  150274. shader: string;
  150275. };
  150276. }
  150277. declare module BABYLON {
  150278. /** @hidden */
  150279. export var ssaoCombinePixelShader: {
  150280. name: string;
  150281. shader: string;
  150282. };
  150283. }
  150284. declare module BABYLON {
  150285. /**
  150286. * Render pipeline to produce ssao effect
  150287. */
  150288. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  150289. /**
  150290. * @ignore
  150291. * The PassPostProcess id in the pipeline that contains the original scene color
  150292. */
  150293. SSAOOriginalSceneColorEffect: string;
  150294. /**
  150295. * @ignore
  150296. * The SSAO PostProcess id in the pipeline
  150297. */
  150298. SSAORenderEffect: string;
  150299. /**
  150300. * @ignore
  150301. * The horizontal blur PostProcess id in the pipeline
  150302. */
  150303. SSAOBlurHRenderEffect: string;
  150304. /**
  150305. * @ignore
  150306. * The vertical blur PostProcess id in the pipeline
  150307. */
  150308. SSAOBlurVRenderEffect: string;
  150309. /**
  150310. * @ignore
  150311. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  150312. */
  150313. SSAOCombineRenderEffect: string;
  150314. /**
  150315. * The output strength of the SSAO post-process. Default value is 1.0.
  150316. */
  150317. totalStrength: number;
  150318. /**
  150319. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  150320. */
  150321. maxZ: number;
  150322. /**
  150323. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  150324. */
  150325. minZAspect: number;
  150326. private _samples;
  150327. /**
  150328. * Number of samples used for the SSAO calculations. Default value is 8
  150329. */
  150330. set samples(n: number);
  150331. get samples(): number;
  150332. private _textureSamples;
  150333. /**
  150334. * Number of samples to use for antialiasing
  150335. */
  150336. set textureSamples(n: number);
  150337. get textureSamples(): number;
  150338. /**
  150339. * Force rendering the geometry through geometry buffer
  150340. */
  150341. private _forceGeometryBuffer;
  150342. /**
  150343. * Ratio object used for SSAO ratio and blur ratio
  150344. */
  150345. private _ratio;
  150346. /**
  150347. * Dynamically generated sphere sampler.
  150348. */
  150349. private _sampleSphere;
  150350. /**
  150351. * Blur filter offsets
  150352. */
  150353. private _samplerOffsets;
  150354. private _expensiveBlur;
  150355. /**
  150356. * If bilateral blur should be used
  150357. */
  150358. set expensiveBlur(b: boolean);
  150359. get expensiveBlur(): boolean;
  150360. /**
  150361. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  150362. */
  150363. radius: number;
  150364. /**
  150365. * The base color of the SSAO post-process
  150366. * The final result is "base + ssao" between [0, 1]
  150367. */
  150368. base: number;
  150369. /**
  150370. * Support test.
  150371. */
  150372. static get IsSupported(): boolean;
  150373. private _scene;
  150374. private _randomTexture;
  150375. private _originalColorPostProcess;
  150376. private _ssaoPostProcess;
  150377. private _blurHPostProcess;
  150378. private _blurVPostProcess;
  150379. private _ssaoCombinePostProcess;
  150380. private _prePassRenderer;
  150381. /**
  150382. * Gets active scene
  150383. */
  150384. get scene(): Scene;
  150385. /**
  150386. * @constructor
  150387. * @param name The rendering pipeline name
  150388. * @param scene The scene linked to this pipeline
  150389. * @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 }
  150390. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150391. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  150392. */
  150393. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  150394. /**
  150395. * Get the class name
  150396. * @returns "SSAO2RenderingPipeline"
  150397. */
  150398. getClassName(): string;
  150399. /**
  150400. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  150401. */
  150402. dispose(disableGeometryBufferRenderer?: boolean): void;
  150403. private _createBlurPostProcess;
  150404. /** @hidden */
  150405. _rebuild(): void;
  150406. private _bits;
  150407. private _radicalInverse_VdC;
  150408. private _hammersley;
  150409. private _hemisphereSample_uniform;
  150410. private _generateHemisphere;
  150411. private _getDefinesForSSAO;
  150412. private _createSSAOPostProcess;
  150413. private _createSSAOCombinePostProcess;
  150414. private _createRandomTexture;
  150415. /**
  150416. * Serialize the rendering pipeline (Used when exporting)
  150417. * @returns the serialized object
  150418. */
  150419. serialize(): any;
  150420. /**
  150421. * Parse the serialized pipeline
  150422. * @param source Source pipeline.
  150423. * @param scene The scene to load the pipeline to.
  150424. * @param rootUrl The URL of the serialized pipeline.
  150425. * @returns An instantiated pipeline from the serialized object.
  150426. */
  150427. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  150428. /**
  150429. * Sets the required values to the prepass renderer.
  150430. * @param prePassRenderer defines the prepass renderer to setup
  150431. * @returns true if the pre pass is needed.
  150432. */
  150433. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150434. }
  150435. }
  150436. declare module BABYLON {
  150437. /** @hidden */
  150438. export var ssaoPixelShader: {
  150439. name: string;
  150440. shader: string;
  150441. };
  150442. }
  150443. declare module BABYLON {
  150444. /**
  150445. * Render pipeline to produce ssao effect
  150446. */
  150447. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  150448. /**
  150449. * @ignore
  150450. * The PassPostProcess id in the pipeline that contains the original scene color
  150451. */
  150452. SSAOOriginalSceneColorEffect: string;
  150453. /**
  150454. * @ignore
  150455. * The SSAO PostProcess id in the pipeline
  150456. */
  150457. SSAORenderEffect: string;
  150458. /**
  150459. * @ignore
  150460. * The horizontal blur PostProcess id in the pipeline
  150461. */
  150462. SSAOBlurHRenderEffect: string;
  150463. /**
  150464. * @ignore
  150465. * The vertical blur PostProcess id in the pipeline
  150466. */
  150467. SSAOBlurVRenderEffect: string;
  150468. /**
  150469. * @ignore
  150470. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  150471. */
  150472. SSAOCombineRenderEffect: string;
  150473. /**
  150474. * The output strength of the SSAO post-process. Default value is 1.0.
  150475. */
  150476. totalStrength: number;
  150477. /**
  150478. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  150479. */
  150480. radius: number;
  150481. /**
  150482. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  150483. * Must not be equal to fallOff and superior to fallOff.
  150484. * Default value is 0.0075
  150485. */
  150486. area: number;
  150487. /**
  150488. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  150489. * Must not be equal to area and inferior to area.
  150490. * Default value is 0.000001
  150491. */
  150492. fallOff: number;
  150493. /**
  150494. * The base color of the SSAO post-process
  150495. * The final result is "base + ssao" between [0, 1]
  150496. */
  150497. base: number;
  150498. private _scene;
  150499. private _depthTexture;
  150500. private _randomTexture;
  150501. private _originalColorPostProcess;
  150502. private _ssaoPostProcess;
  150503. private _blurHPostProcess;
  150504. private _blurVPostProcess;
  150505. private _ssaoCombinePostProcess;
  150506. private _firstUpdate;
  150507. /**
  150508. * Gets active scene
  150509. */
  150510. get scene(): Scene;
  150511. /**
  150512. * @constructor
  150513. * @param name - The rendering pipeline name
  150514. * @param scene - The scene linked to this pipeline
  150515. * @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 }
  150516. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  150517. */
  150518. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  150519. /**
  150520. * Get the class name
  150521. * @returns "SSAORenderingPipeline"
  150522. */
  150523. getClassName(): string;
  150524. /**
  150525. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  150526. */
  150527. dispose(disableDepthRender?: boolean): void;
  150528. private _createBlurPostProcess;
  150529. /** @hidden */
  150530. _rebuild(): void;
  150531. private _createSSAOPostProcess;
  150532. private _createSSAOCombinePostProcess;
  150533. private _createRandomTexture;
  150534. }
  150535. }
  150536. declare module BABYLON {
  150537. /** @hidden */
  150538. export var screenSpaceReflectionPixelShader: {
  150539. name: string;
  150540. shader: string;
  150541. };
  150542. }
  150543. declare module BABYLON {
  150544. /**
  150545. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  150546. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  150547. */
  150548. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  150549. /**
  150550. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  150551. */
  150552. threshold: number;
  150553. /**
  150554. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  150555. */
  150556. strength: number;
  150557. /**
  150558. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  150559. */
  150560. reflectionSpecularFalloffExponent: number;
  150561. /**
  150562. * 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]
  150563. */
  150564. step: number;
  150565. /**
  150566. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  150567. */
  150568. roughnessFactor: number;
  150569. private _geometryBufferRenderer;
  150570. private _enableSmoothReflections;
  150571. private _reflectionSamples;
  150572. private _smoothSteps;
  150573. /**
  150574. * Gets a string identifying the name of the class
  150575. * @returns "ScreenSpaceReflectionPostProcess" string
  150576. */
  150577. getClassName(): string;
  150578. /**
  150579. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  150580. * @param name The name of the effect.
  150581. * @param scene The scene containing the objects to calculate reflections.
  150582. * @param options The required width/height ratio to downsize to before computing the render pass.
  150583. * @param camera The camera to apply the render pass to.
  150584. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150585. * @param engine The engine which the post process will be applied. (default: current engine)
  150586. * @param reusable If the post process can be reused on the same frame. (default: false)
  150587. * @param textureType Type of textures used when performing the post process. (default: 0)
  150588. * @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)
  150589. */
  150590. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150591. /**
  150592. * Gets wether or not smoothing reflections is enabled.
  150593. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  150594. */
  150595. get enableSmoothReflections(): boolean;
  150596. /**
  150597. * Sets wether or not smoothing reflections is enabled.
  150598. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  150599. */
  150600. set enableSmoothReflections(enabled: boolean);
  150601. /**
  150602. * Gets the number of samples taken while computing reflections. More samples count is high,
  150603. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  150604. */
  150605. get reflectionSamples(): number;
  150606. /**
  150607. * Sets the number of samples taken while computing reflections. More samples count is high,
  150608. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  150609. */
  150610. set reflectionSamples(samples: number);
  150611. /**
  150612. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  150613. * more the post-process will require GPU power and can generate a drop in FPS.
  150614. * Default value (5.0) work pretty well in all cases but can be adjusted.
  150615. */
  150616. get smoothSteps(): number;
  150617. set smoothSteps(steps: number);
  150618. private _updateEffectDefines;
  150619. /** @hidden */
  150620. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  150621. }
  150622. }
  150623. declare module BABYLON {
  150624. /** @hidden */
  150625. export var standardPixelShader: {
  150626. name: string;
  150627. shader: string;
  150628. };
  150629. }
  150630. declare module BABYLON {
  150631. /**
  150632. * Standard rendering pipeline
  150633. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  150634. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  150635. */
  150636. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  150637. /**
  150638. * Public members
  150639. */
  150640. /**
  150641. * Post-process which contains the original scene color before the pipeline applies all the effects
  150642. */
  150643. originalPostProcess: Nullable<PostProcess>;
  150644. /**
  150645. * Post-process used to down scale an image x4
  150646. */
  150647. downSampleX4PostProcess: Nullable<PostProcess>;
  150648. /**
  150649. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  150650. */
  150651. brightPassPostProcess: Nullable<PostProcess>;
  150652. /**
  150653. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  150654. */
  150655. blurHPostProcesses: PostProcess[];
  150656. /**
  150657. * Post-process array storing all the vertical blur post-processes used by the pipeline
  150658. */
  150659. blurVPostProcesses: PostProcess[];
  150660. /**
  150661. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  150662. */
  150663. textureAdderPostProcess: Nullable<PostProcess>;
  150664. /**
  150665. * Post-process used to create volumetric lighting effect
  150666. */
  150667. volumetricLightPostProcess: Nullable<PostProcess>;
  150668. /**
  150669. * Post-process used to smooth the previous volumetric light post-process on the X axis
  150670. */
  150671. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  150672. /**
  150673. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  150674. */
  150675. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  150676. /**
  150677. * Post-process used to merge the volumetric light effect and the real scene color
  150678. */
  150679. volumetricLightMergePostProces: Nullable<PostProcess>;
  150680. /**
  150681. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  150682. */
  150683. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  150684. /**
  150685. * Base post-process used to calculate the average luminance of the final image for HDR
  150686. */
  150687. luminancePostProcess: Nullable<PostProcess>;
  150688. /**
  150689. * Post-processes used to create down sample post-processes in order to get
  150690. * the average luminance of the final image for HDR
  150691. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  150692. */
  150693. luminanceDownSamplePostProcesses: PostProcess[];
  150694. /**
  150695. * Post-process used to create a HDR effect (light adaptation)
  150696. */
  150697. hdrPostProcess: Nullable<PostProcess>;
  150698. /**
  150699. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  150700. */
  150701. textureAdderFinalPostProcess: Nullable<PostProcess>;
  150702. /**
  150703. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  150704. */
  150705. lensFlareFinalPostProcess: Nullable<PostProcess>;
  150706. /**
  150707. * Post-process used to merge the final HDR post-process and the real scene color
  150708. */
  150709. hdrFinalPostProcess: Nullable<PostProcess>;
  150710. /**
  150711. * Post-process used to create a lens flare effect
  150712. */
  150713. lensFlarePostProcess: Nullable<PostProcess>;
  150714. /**
  150715. * Post-process that merges the result of the lens flare post-process and the real scene color
  150716. */
  150717. lensFlareComposePostProcess: Nullable<PostProcess>;
  150718. /**
  150719. * Post-process used to create a motion blur effect
  150720. */
  150721. motionBlurPostProcess: Nullable<PostProcess>;
  150722. /**
  150723. * Post-process used to create a depth of field effect
  150724. */
  150725. depthOfFieldPostProcess: Nullable<PostProcess>;
  150726. /**
  150727. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  150728. */
  150729. fxaaPostProcess: Nullable<FxaaPostProcess>;
  150730. /**
  150731. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  150732. */
  150733. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  150734. /**
  150735. * Represents the brightness threshold in order to configure the illuminated surfaces
  150736. */
  150737. brightThreshold: number;
  150738. /**
  150739. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  150740. */
  150741. blurWidth: number;
  150742. /**
  150743. * Sets if the blur for highlighted surfaces must be only horizontal
  150744. */
  150745. horizontalBlur: boolean;
  150746. /**
  150747. * Gets the overall exposure used by the pipeline
  150748. */
  150749. get exposure(): number;
  150750. /**
  150751. * Sets the overall exposure used by the pipeline
  150752. */
  150753. set exposure(value: number);
  150754. /**
  150755. * Texture used typically to simulate "dirty" on camera lens
  150756. */
  150757. lensTexture: Nullable<Texture>;
  150758. /**
  150759. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  150760. */
  150761. volumetricLightCoefficient: number;
  150762. /**
  150763. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  150764. */
  150765. volumetricLightPower: number;
  150766. /**
  150767. * Used the set the blur intensity to smooth the volumetric lights
  150768. */
  150769. volumetricLightBlurScale: number;
  150770. /**
  150771. * Light (spot or directional) used to generate the volumetric lights rays
  150772. * The source light must have a shadow generate so the pipeline can get its
  150773. * depth map
  150774. */
  150775. sourceLight: Nullable<SpotLight | DirectionalLight>;
  150776. /**
  150777. * For eye adaptation, represents the minimum luminance the eye can see
  150778. */
  150779. hdrMinimumLuminance: number;
  150780. /**
  150781. * For eye adaptation, represents the decrease luminance speed
  150782. */
  150783. hdrDecreaseRate: number;
  150784. /**
  150785. * For eye adaptation, represents the increase luminance speed
  150786. */
  150787. hdrIncreaseRate: number;
  150788. /**
  150789. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  150790. */
  150791. get hdrAutoExposure(): boolean;
  150792. /**
  150793. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  150794. */
  150795. set hdrAutoExposure(value: boolean);
  150796. /**
  150797. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  150798. */
  150799. lensColorTexture: Nullable<Texture>;
  150800. /**
  150801. * The overall strengh for the lens flare effect
  150802. */
  150803. lensFlareStrength: number;
  150804. /**
  150805. * Dispersion coefficient for lens flare ghosts
  150806. */
  150807. lensFlareGhostDispersal: number;
  150808. /**
  150809. * Main lens flare halo width
  150810. */
  150811. lensFlareHaloWidth: number;
  150812. /**
  150813. * Based on the lens distortion effect, defines how much the lens flare result
  150814. * is distorted
  150815. */
  150816. lensFlareDistortionStrength: number;
  150817. /**
  150818. * Configures the blur intensity used for for lens flare (halo)
  150819. */
  150820. lensFlareBlurWidth: number;
  150821. /**
  150822. * Lens star texture must be used to simulate rays on the flares and is available
  150823. * in the documentation
  150824. */
  150825. lensStarTexture: Nullable<Texture>;
  150826. /**
  150827. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  150828. * flare effect by taking account of the dirt texture
  150829. */
  150830. lensFlareDirtTexture: Nullable<Texture>;
  150831. /**
  150832. * Represents the focal length for the depth of field effect
  150833. */
  150834. depthOfFieldDistance: number;
  150835. /**
  150836. * Represents the blur intensity for the blurred part of the depth of field effect
  150837. */
  150838. depthOfFieldBlurWidth: number;
  150839. /**
  150840. * Gets how much the image is blurred by the movement while using the motion blur post-process
  150841. */
  150842. get motionStrength(): number;
  150843. /**
  150844. * Sets how much the image is blurred by the movement while using the motion blur post-process
  150845. */
  150846. set motionStrength(strength: number);
  150847. /**
  150848. * Gets wether or not the motion blur post-process is object based or screen based.
  150849. */
  150850. get objectBasedMotionBlur(): boolean;
  150851. /**
  150852. * Sets wether or not the motion blur post-process should be object based or screen based
  150853. */
  150854. set objectBasedMotionBlur(value: boolean);
  150855. /**
  150856. * List of animations for the pipeline (IAnimatable implementation)
  150857. */
  150858. animations: Animation[];
  150859. /**
  150860. * Private members
  150861. */
  150862. private _scene;
  150863. private _currentDepthOfFieldSource;
  150864. private _basePostProcess;
  150865. private _fixedExposure;
  150866. private _currentExposure;
  150867. private _hdrAutoExposure;
  150868. private _hdrCurrentLuminance;
  150869. private _motionStrength;
  150870. private _isObjectBasedMotionBlur;
  150871. private _floatTextureType;
  150872. private _camerasToBeAttached;
  150873. private _ratio;
  150874. private _bloomEnabled;
  150875. private _depthOfFieldEnabled;
  150876. private _vlsEnabled;
  150877. private _lensFlareEnabled;
  150878. private _hdrEnabled;
  150879. private _motionBlurEnabled;
  150880. private _fxaaEnabled;
  150881. private _screenSpaceReflectionsEnabled;
  150882. private _motionBlurSamples;
  150883. private _volumetricLightStepsCount;
  150884. private _samples;
  150885. /**
  150886. * @ignore
  150887. * Specifies if the bloom pipeline is enabled
  150888. */
  150889. get BloomEnabled(): boolean;
  150890. set BloomEnabled(enabled: boolean);
  150891. /**
  150892. * @ignore
  150893. * Specifies if the depth of field pipeline is enabed
  150894. */
  150895. get DepthOfFieldEnabled(): boolean;
  150896. set DepthOfFieldEnabled(enabled: boolean);
  150897. /**
  150898. * @ignore
  150899. * Specifies if the lens flare pipeline is enabed
  150900. */
  150901. get LensFlareEnabled(): boolean;
  150902. set LensFlareEnabled(enabled: boolean);
  150903. /**
  150904. * @ignore
  150905. * Specifies if the HDR pipeline is enabled
  150906. */
  150907. get HDREnabled(): boolean;
  150908. set HDREnabled(enabled: boolean);
  150909. /**
  150910. * @ignore
  150911. * Specifies if the volumetric lights scattering effect is enabled
  150912. */
  150913. get VLSEnabled(): boolean;
  150914. set VLSEnabled(enabled: boolean);
  150915. /**
  150916. * @ignore
  150917. * Specifies if the motion blur effect is enabled
  150918. */
  150919. get MotionBlurEnabled(): boolean;
  150920. set MotionBlurEnabled(enabled: boolean);
  150921. /**
  150922. * Specifies if anti-aliasing is enabled
  150923. */
  150924. get fxaaEnabled(): boolean;
  150925. set fxaaEnabled(enabled: boolean);
  150926. /**
  150927. * Specifies if screen space reflections are enabled.
  150928. */
  150929. get screenSpaceReflectionsEnabled(): boolean;
  150930. set screenSpaceReflectionsEnabled(enabled: boolean);
  150931. /**
  150932. * Specifies the number of steps used to calculate the volumetric lights
  150933. * Typically in interval [50, 200]
  150934. */
  150935. get volumetricLightStepsCount(): number;
  150936. set volumetricLightStepsCount(count: number);
  150937. /**
  150938. * Specifies the number of samples used for the motion blur effect
  150939. * Typically in interval [16, 64]
  150940. */
  150941. get motionBlurSamples(): number;
  150942. set motionBlurSamples(samples: number);
  150943. /**
  150944. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  150945. */
  150946. get samples(): number;
  150947. set samples(sampleCount: number);
  150948. /**
  150949. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  150950. * @constructor
  150951. * @param name The rendering pipeline name
  150952. * @param scene The scene linked to this pipeline
  150953. * @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)
  150954. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  150955. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150956. */
  150957. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  150958. private _buildPipeline;
  150959. private _createDownSampleX4PostProcess;
  150960. private _createBrightPassPostProcess;
  150961. private _createBlurPostProcesses;
  150962. private _createTextureAdderPostProcess;
  150963. private _createVolumetricLightPostProcess;
  150964. private _createLuminancePostProcesses;
  150965. private _createHdrPostProcess;
  150966. private _createLensFlarePostProcess;
  150967. private _createDepthOfFieldPostProcess;
  150968. private _createMotionBlurPostProcess;
  150969. private _getDepthTexture;
  150970. private _disposePostProcesses;
  150971. /**
  150972. * Dispose of the pipeline and stop all post processes
  150973. */
  150974. dispose(): void;
  150975. /**
  150976. * Serialize the rendering pipeline (Used when exporting)
  150977. * @returns the serialized object
  150978. */
  150979. serialize(): any;
  150980. /**
  150981. * Parse the serialized pipeline
  150982. * @param source Source pipeline.
  150983. * @param scene The scene to load the pipeline to.
  150984. * @param rootUrl The URL of the serialized pipeline.
  150985. * @returns An instantiated pipeline from the serialized object.
  150986. */
  150987. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  150988. /**
  150989. * Luminance steps
  150990. */
  150991. static LuminanceSteps: number;
  150992. }
  150993. }
  150994. declare module BABYLON {
  150995. /** @hidden */
  150996. export var stereoscopicInterlacePixelShader: {
  150997. name: string;
  150998. shader: string;
  150999. };
  151000. }
  151001. declare module BABYLON {
  151002. /**
  151003. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  151004. */
  151005. export class StereoscopicInterlacePostProcessI extends PostProcess {
  151006. private _stepSize;
  151007. private _passedProcess;
  151008. /**
  151009. * Gets a string identifying the name of the class
  151010. * @returns "StereoscopicInterlacePostProcessI" string
  151011. */
  151012. getClassName(): string;
  151013. /**
  151014. * Initializes a StereoscopicInterlacePostProcessI
  151015. * @param name The name of the effect.
  151016. * @param rigCameras The rig cameras to be appled to the post process
  151017. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  151018. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  151019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151020. * @param engine The engine which the post process will be applied. (default: current engine)
  151021. * @param reusable If the post process can be reused on the same frame. (default: false)
  151022. */
  151023. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151024. }
  151025. /**
  151026. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  151027. */
  151028. export class StereoscopicInterlacePostProcess extends PostProcess {
  151029. private _stepSize;
  151030. private _passedProcess;
  151031. /**
  151032. * Gets a string identifying the name of the class
  151033. * @returns "StereoscopicInterlacePostProcess" string
  151034. */
  151035. getClassName(): string;
  151036. /**
  151037. * Initializes a StereoscopicInterlacePostProcess
  151038. * @param name The name of the effect.
  151039. * @param rigCameras The rig cameras to be appled to the post process
  151040. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  151041. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151042. * @param engine The engine which the post process will be applied. (default: current engine)
  151043. * @param reusable If the post process can be reused on the same frame. (default: false)
  151044. */
  151045. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151046. }
  151047. }
  151048. declare module BABYLON {
  151049. /** @hidden */
  151050. export var tonemapPixelShader: {
  151051. name: string;
  151052. shader: string;
  151053. };
  151054. }
  151055. declare module BABYLON {
  151056. /** Defines operator used for tonemapping */
  151057. export enum TonemappingOperator {
  151058. /** Hable */
  151059. Hable = 0,
  151060. /** Reinhard */
  151061. Reinhard = 1,
  151062. /** HejiDawson */
  151063. HejiDawson = 2,
  151064. /** Photographic */
  151065. Photographic = 3
  151066. }
  151067. /**
  151068. * Defines a post process to apply tone mapping
  151069. */
  151070. export class TonemapPostProcess extends PostProcess {
  151071. private _operator;
  151072. /** Defines the required exposure adjustement */
  151073. exposureAdjustment: number;
  151074. /**
  151075. * Gets a string identifying the name of the class
  151076. * @returns "TonemapPostProcess" string
  151077. */
  151078. getClassName(): string;
  151079. /**
  151080. * Creates a new TonemapPostProcess
  151081. * @param name defines the name of the postprocess
  151082. * @param _operator defines the operator to use
  151083. * @param exposureAdjustment defines the required exposure adjustement
  151084. * @param camera defines the camera to use (can be null)
  151085. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  151086. * @param engine defines the hosting engine (can be ignore if camera is set)
  151087. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  151088. */
  151089. constructor(name: string, _operator: TonemappingOperator,
  151090. /** Defines the required exposure adjustement */
  151091. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  151092. }
  151093. }
  151094. declare module BABYLON {
  151095. /** @hidden */
  151096. export var volumetricLightScatteringPixelShader: {
  151097. name: string;
  151098. shader: string;
  151099. };
  151100. }
  151101. declare module BABYLON {
  151102. /** @hidden */
  151103. export var volumetricLightScatteringPassVertexShader: {
  151104. name: string;
  151105. shader: string;
  151106. };
  151107. }
  151108. declare module BABYLON {
  151109. /** @hidden */
  151110. export var volumetricLightScatteringPassPixelShader: {
  151111. name: string;
  151112. shader: string;
  151113. };
  151114. }
  151115. declare module BABYLON {
  151116. /**
  151117. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  151118. */
  151119. export class VolumetricLightScatteringPostProcess extends PostProcess {
  151120. private _volumetricLightScatteringPass;
  151121. private _volumetricLightScatteringRTT;
  151122. private _viewPort;
  151123. private _screenCoordinates;
  151124. private _cachedDefines;
  151125. /**
  151126. * If not undefined, the mesh position is computed from the attached node position
  151127. */
  151128. attachedNode: {
  151129. position: Vector3;
  151130. };
  151131. /**
  151132. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  151133. */
  151134. customMeshPosition: Vector3;
  151135. /**
  151136. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  151137. */
  151138. useCustomMeshPosition: boolean;
  151139. /**
  151140. * If the post-process should inverse the light scattering direction
  151141. */
  151142. invert: boolean;
  151143. /**
  151144. * The internal mesh used by the post-process
  151145. */
  151146. mesh: Mesh;
  151147. /**
  151148. * @hidden
  151149. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  151150. */
  151151. get useDiffuseColor(): boolean;
  151152. set useDiffuseColor(useDiffuseColor: boolean);
  151153. /**
  151154. * Array containing the excluded meshes not rendered in the internal pass
  151155. */
  151156. excludedMeshes: AbstractMesh[];
  151157. /**
  151158. * Controls the overall intensity of the post-process
  151159. */
  151160. exposure: number;
  151161. /**
  151162. * Dissipates each sample's contribution in range [0, 1]
  151163. */
  151164. decay: number;
  151165. /**
  151166. * Controls the overall intensity of each sample
  151167. */
  151168. weight: number;
  151169. /**
  151170. * Controls the density of each sample
  151171. */
  151172. density: number;
  151173. /**
  151174. * @constructor
  151175. * @param name The post-process name
  151176. * @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)
  151177. * @param camera The camera that the post-process will be attached to
  151178. * @param mesh The mesh used to create the light scattering
  151179. * @param samples The post-process quality, default 100
  151180. * @param samplingModeThe post-process filtering mode
  151181. * @param engine The babylon engine
  151182. * @param reusable If the post-process is reusable
  151183. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  151184. */
  151185. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  151186. /**
  151187. * Returns the string "VolumetricLightScatteringPostProcess"
  151188. * @returns "VolumetricLightScatteringPostProcess"
  151189. */
  151190. getClassName(): string;
  151191. private _isReady;
  151192. /**
  151193. * Sets the new light position for light scattering effect
  151194. * @param position The new custom light position
  151195. */
  151196. setCustomMeshPosition(position: Vector3): void;
  151197. /**
  151198. * Returns the light position for light scattering effect
  151199. * @return Vector3 The custom light position
  151200. */
  151201. getCustomMeshPosition(): Vector3;
  151202. /**
  151203. * Disposes the internal assets and detaches the post-process from the camera
  151204. */
  151205. dispose(camera: Camera): void;
  151206. /**
  151207. * Returns the render target texture used by the post-process
  151208. * @return the render target texture used by the post-process
  151209. */
  151210. getPass(): RenderTargetTexture;
  151211. private _meshExcluded;
  151212. private _createPass;
  151213. private _updateMeshScreenCoordinates;
  151214. /**
  151215. * Creates a default mesh for the Volumeric Light Scattering post-process
  151216. * @param name The mesh name
  151217. * @param scene The scene where to create the mesh
  151218. * @return the default mesh
  151219. */
  151220. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  151221. }
  151222. }
  151223. declare module BABYLON {
  151224. /** @hidden */
  151225. export var screenSpaceCurvaturePixelShader: {
  151226. name: string;
  151227. shader: string;
  151228. };
  151229. }
  151230. declare module BABYLON {
  151231. /**
  151232. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  151233. */
  151234. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  151235. /**
  151236. * Defines how much ridge the curvature effect displays.
  151237. */
  151238. ridge: number;
  151239. /**
  151240. * Defines how much valley the curvature effect displays.
  151241. */
  151242. valley: number;
  151243. private _geometryBufferRenderer;
  151244. /**
  151245. * Gets a string identifying the name of the class
  151246. * @returns "ScreenSpaceCurvaturePostProcess" string
  151247. */
  151248. getClassName(): string;
  151249. /**
  151250. * Creates a new instance ScreenSpaceCurvaturePostProcess
  151251. * @param name The name of the effect.
  151252. * @param scene The scene containing the objects to blur according to their velocity.
  151253. * @param options The required width/height ratio to downsize to before computing the render pass.
  151254. * @param camera The camera to apply the render pass to.
  151255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151256. * @param engine The engine which the post process will be applied. (default: current engine)
  151257. * @param reusable If the post process can be reused on the same frame. (default: false)
  151258. * @param textureType Type of textures used when performing the post process. (default: 0)
  151259. * @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)
  151260. */
  151261. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151262. /**
  151263. * Support test.
  151264. */
  151265. static get IsSupported(): boolean;
  151266. /** @hidden */
  151267. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  151268. }
  151269. }
  151270. declare module BABYLON {
  151271. interface Scene {
  151272. /** @hidden (Backing field) */
  151273. _boundingBoxRenderer: BoundingBoxRenderer;
  151274. /** @hidden (Backing field) */
  151275. _forceShowBoundingBoxes: boolean;
  151276. /**
  151277. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  151278. */
  151279. forceShowBoundingBoxes: boolean;
  151280. /**
  151281. * Gets the bounding box renderer associated with the scene
  151282. * @returns a BoundingBoxRenderer
  151283. */
  151284. getBoundingBoxRenderer(): BoundingBoxRenderer;
  151285. }
  151286. interface AbstractMesh {
  151287. /** @hidden (Backing field) */
  151288. _showBoundingBox: boolean;
  151289. /**
  151290. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  151291. */
  151292. showBoundingBox: boolean;
  151293. }
  151294. /**
  151295. * Component responsible of rendering the bounding box of the meshes in a scene.
  151296. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  151297. */
  151298. export class BoundingBoxRenderer implements ISceneComponent {
  151299. /**
  151300. * The component name helpfull to identify the component in the list of scene components.
  151301. */
  151302. readonly name: string;
  151303. /**
  151304. * The scene the component belongs to.
  151305. */
  151306. scene: Scene;
  151307. /**
  151308. * Color of the bounding box lines placed in front of an object
  151309. */
  151310. frontColor: Color3;
  151311. /**
  151312. * Color of the bounding box lines placed behind an object
  151313. */
  151314. backColor: Color3;
  151315. /**
  151316. * Defines if the renderer should show the back lines or not
  151317. */
  151318. showBackLines: boolean;
  151319. /**
  151320. * Observable raised before rendering a bounding box
  151321. */
  151322. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  151323. /**
  151324. * Observable raised after rendering a bounding box
  151325. */
  151326. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  151327. /**
  151328. * @hidden
  151329. */
  151330. renderList: SmartArray<BoundingBox>;
  151331. private _colorShader;
  151332. private _vertexBuffers;
  151333. private _indexBuffer;
  151334. private _fillIndexBuffer;
  151335. private _fillIndexData;
  151336. /**
  151337. * Instantiates a new bounding box renderer in a scene.
  151338. * @param scene the scene the renderer renders in
  151339. */
  151340. constructor(scene: Scene);
  151341. /**
  151342. * Registers the component in a given scene
  151343. */
  151344. register(): void;
  151345. private _evaluateSubMesh;
  151346. private _activeMesh;
  151347. private _prepareRessources;
  151348. private _createIndexBuffer;
  151349. /**
  151350. * Rebuilds the elements related to this component in case of
  151351. * context lost for instance.
  151352. */
  151353. rebuild(): void;
  151354. /**
  151355. * @hidden
  151356. */
  151357. reset(): void;
  151358. /**
  151359. * Render the bounding boxes of a specific rendering group
  151360. * @param renderingGroupId defines the rendering group to render
  151361. */
  151362. render(renderingGroupId: number): void;
  151363. /**
  151364. * In case of occlusion queries, we can render the occlusion bounding box through this method
  151365. * @param mesh Define the mesh to render the occlusion bounding box for
  151366. */
  151367. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  151368. /**
  151369. * Dispose and release the resources attached to this renderer.
  151370. */
  151371. dispose(): void;
  151372. }
  151373. }
  151374. declare module BABYLON {
  151375. interface Scene {
  151376. /** @hidden (Backing field) */
  151377. _depthRenderer: {
  151378. [id: string]: DepthRenderer;
  151379. };
  151380. /**
  151381. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  151382. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  151383. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  151384. * @returns the created depth renderer
  151385. */
  151386. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  151387. /**
  151388. * Disables a depth renderer for a given camera
  151389. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  151390. */
  151391. disableDepthRenderer(camera?: Nullable<Camera>): void;
  151392. }
  151393. /**
  151394. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  151395. * in several rendering techniques.
  151396. */
  151397. export class DepthRendererSceneComponent implements ISceneComponent {
  151398. /**
  151399. * The component name helpfull to identify the component in the list of scene components.
  151400. */
  151401. readonly name: string;
  151402. /**
  151403. * The scene the component belongs to.
  151404. */
  151405. scene: Scene;
  151406. /**
  151407. * Creates a new instance of the component for the given scene
  151408. * @param scene Defines the scene to register the component in
  151409. */
  151410. constructor(scene: Scene);
  151411. /**
  151412. * Registers the component in a given scene
  151413. */
  151414. register(): void;
  151415. /**
  151416. * Rebuilds the elements related to this component in case of
  151417. * context lost for instance.
  151418. */
  151419. rebuild(): void;
  151420. /**
  151421. * Disposes the component and the associated ressources
  151422. */
  151423. dispose(): void;
  151424. private _gatherRenderTargets;
  151425. private _gatherActiveCameraRenderTargets;
  151426. }
  151427. }
  151428. declare module BABYLON {
  151429. interface AbstractScene {
  151430. /** @hidden (Backing field) */
  151431. _prePassRenderer: Nullable<PrePassRenderer>;
  151432. /**
  151433. * Gets or Sets the current prepass renderer associated to the scene.
  151434. */
  151435. prePassRenderer: Nullable<PrePassRenderer>;
  151436. /**
  151437. * Enables the prepass and associates it with the scene
  151438. * @returns the PrePassRenderer
  151439. */
  151440. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  151441. /**
  151442. * Disables the prepass associated with the scene
  151443. */
  151444. disablePrePassRenderer(): void;
  151445. }
  151446. /**
  151447. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  151448. * in several rendering techniques.
  151449. */
  151450. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  151451. /**
  151452. * The component name helpful to identify the component in the list of scene components.
  151453. */
  151454. readonly name: string;
  151455. /**
  151456. * The scene the component belongs to.
  151457. */
  151458. scene: Scene;
  151459. /**
  151460. * Creates a new instance of the component for the given scene
  151461. * @param scene Defines the scene to register the component in
  151462. */
  151463. constructor(scene: Scene);
  151464. /**
  151465. * Registers the component in a given scene
  151466. */
  151467. register(): void;
  151468. private _beforeCameraDraw;
  151469. private _afterCameraDraw;
  151470. private _beforeClearStage;
  151471. /**
  151472. * Serializes the component data to the specified json object
  151473. * @param serializationObject The object to serialize to
  151474. */
  151475. serialize(serializationObject: any): void;
  151476. /**
  151477. * Adds all the elements from the container to the scene
  151478. * @param container the container holding the elements
  151479. */
  151480. addFromContainer(container: AbstractScene): void;
  151481. /**
  151482. * Removes all the elements in the container from the scene
  151483. * @param container contains the elements to remove
  151484. * @param dispose if the removed element should be disposed (default: false)
  151485. */
  151486. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  151487. /**
  151488. * Rebuilds the elements related to this component in case of
  151489. * context lost for instance.
  151490. */
  151491. rebuild(): void;
  151492. /**
  151493. * Disposes the component and the associated ressources
  151494. */
  151495. dispose(): void;
  151496. }
  151497. }
  151498. declare module BABYLON {
  151499. /** @hidden */
  151500. export var outlinePixelShader: {
  151501. name: string;
  151502. shader: string;
  151503. };
  151504. }
  151505. declare module BABYLON {
  151506. /** @hidden */
  151507. export var outlineVertexShader: {
  151508. name: string;
  151509. shader: string;
  151510. };
  151511. }
  151512. declare module BABYLON {
  151513. interface Scene {
  151514. /** @hidden */
  151515. _outlineRenderer: OutlineRenderer;
  151516. /**
  151517. * Gets the outline renderer associated with the scene
  151518. * @returns a OutlineRenderer
  151519. */
  151520. getOutlineRenderer(): OutlineRenderer;
  151521. }
  151522. interface AbstractMesh {
  151523. /** @hidden (Backing field) */
  151524. _renderOutline: boolean;
  151525. /**
  151526. * Gets or sets a boolean indicating if the outline must be rendered as well
  151527. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  151528. */
  151529. renderOutline: boolean;
  151530. /** @hidden (Backing field) */
  151531. _renderOverlay: boolean;
  151532. /**
  151533. * Gets or sets a boolean indicating if the overlay must be rendered as well
  151534. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  151535. */
  151536. renderOverlay: boolean;
  151537. }
  151538. /**
  151539. * This class is responsible to draw bothe outline/overlay of meshes.
  151540. * It should not be used directly but through the available method on mesh.
  151541. */
  151542. export class OutlineRenderer implements ISceneComponent {
  151543. /**
  151544. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  151545. */
  151546. private static _StencilReference;
  151547. /**
  151548. * The name of the component. Each component must have a unique name.
  151549. */
  151550. name: string;
  151551. /**
  151552. * The scene the component belongs to.
  151553. */
  151554. scene: Scene;
  151555. /**
  151556. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  151557. */
  151558. zOffset: number;
  151559. private _engine;
  151560. private _effect;
  151561. private _cachedDefines;
  151562. private _savedDepthWrite;
  151563. /**
  151564. * Instantiates a new outline renderer. (There could be only one per scene).
  151565. * @param scene Defines the scene it belongs to
  151566. */
  151567. constructor(scene: Scene);
  151568. /**
  151569. * Register the component to one instance of a scene.
  151570. */
  151571. register(): void;
  151572. /**
  151573. * Rebuilds the elements related to this component in case of
  151574. * context lost for instance.
  151575. */
  151576. rebuild(): void;
  151577. /**
  151578. * Disposes the component and the associated ressources.
  151579. */
  151580. dispose(): void;
  151581. /**
  151582. * Renders the outline in the canvas.
  151583. * @param subMesh Defines the sumesh to render
  151584. * @param batch Defines the batch of meshes in case of instances
  151585. * @param useOverlay Defines if the rendering is for the overlay or the outline
  151586. */
  151587. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  151588. /**
  151589. * Returns whether or not the outline renderer is ready for a given submesh.
  151590. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  151591. * @param subMesh Defines the submesh to check readyness for
  151592. * @param useInstances Defines wheter wee are trying to render instances or not
  151593. * @returns true if ready otherwise false
  151594. */
  151595. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  151596. private _beforeRenderingMesh;
  151597. private _afterRenderingMesh;
  151598. }
  151599. }
  151600. declare module BABYLON {
  151601. /**
  151602. * Defines the basic options interface of a Sprite Frame Source Size.
  151603. */
  151604. export interface ISpriteJSONSpriteSourceSize {
  151605. /**
  151606. * number of the original width of the Frame
  151607. */
  151608. w: number;
  151609. /**
  151610. * number of the original height of the Frame
  151611. */
  151612. h: number;
  151613. }
  151614. /**
  151615. * Defines the basic options interface of a Sprite Frame Data.
  151616. */
  151617. export interface ISpriteJSONSpriteFrameData {
  151618. /**
  151619. * number of the x offset of the Frame
  151620. */
  151621. x: number;
  151622. /**
  151623. * number of the y offset of the Frame
  151624. */
  151625. y: number;
  151626. /**
  151627. * number of the width of the Frame
  151628. */
  151629. w: number;
  151630. /**
  151631. * number of the height of the Frame
  151632. */
  151633. h: number;
  151634. }
  151635. /**
  151636. * Defines the basic options interface of a JSON Sprite.
  151637. */
  151638. export interface ISpriteJSONSprite {
  151639. /**
  151640. * string name of the Frame
  151641. */
  151642. filename: string;
  151643. /**
  151644. * ISpriteJSONSpriteFrame basic object of the frame data
  151645. */
  151646. frame: ISpriteJSONSpriteFrameData;
  151647. /**
  151648. * boolean to flag is the frame was rotated.
  151649. */
  151650. rotated: boolean;
  151651. /**
  151652. * boolean to flag is the frame was trimmed.
  151653. */
  151654. trimmed: boolean;
  151655. /**
  151656. * ISpriteJSONSpriteFrame basic object of the source data
  151657. */
  151658. spriteSourceSize: ISpriteJSONSpriteFrameData;
  151659. /**
  151660. * ISpriteJSONSpriteFrame basic object of the source data
  151661. */
  151662. sourceSize: ISpriteJSONSpriteSourceSize;
  151663. }
  151664. /**
  151665. * Defines the basic options interface of a JSON atlas.
  151666. */
  151667. export interface ISpriteJSONAtlas {
  151668. /**
  151669. * Array of objects that contain the frame data.
  151670. */
  151671. frames: Array<ISpriteJSONSprite>;
  151672. /**
  151673. * object basic object containing the sprite meta data.
  151674. */
  151675. meta?: object;
  151676. }
  151677. }
  151678. declare module BABYLON {
  151679. /** @hidden */
  151680. export var spriteMapPixelShader: {
  151681. name: string;
  151682. shader: string;
  151683. };
  151684. }
  151685. declare module BABYLON {
  151686. /** @hidden */
  151687. export var spriteMapVertexShader: {
  151688. name: string;
  151689. shader: string;
  151690. };
  151691. }
  151692. declare module BABYLON {
  151693. /**
  151694. * Defines the basic options interface of a SpriteMap
  151695. */
  151696. export interface ISpriteMapOptions {
  151697. /**
  151698. * Vector2 of the number of cells in the grid.
  151699. */
  151700. stageSize?: Vector2;
  151701. /**
  151702. * Vector2 of the size of the output plane in World Units.
  151703. */
  151704. outputSize?: Vector2;
  151705. /**
  151706. * Vector3 of the position of the output plane in World Units.
  151707. */
  151708. outputPosition?: Vector3;
  151709. /**
  151710. * Vector3 of the rotation of the output plane.
  151711. */
  151712. outputRotation?: Vector3;
  151713. /**
  151714. * number of layers that the system will reserve in resources.
  151715. */
  151716. layerCount?: number;
  151717. /**
  151718. * number of max animation frames a single cell will reserve in resources.
  151719. */
  151720. maxAnimationFrames?: number;
  151721. /**
  151722. * number cell index of the base tile when the system compiles.
  151723. */
  151724. baseTile?: number;
  151725. /**
  151726. * boolean flip the sprite after its been repositioned by the framing data.
  151727. */
  151728. flipU?: boolean;
  151729. /**
  151730. * Vector3 scalar of the global RGB values of the SpriteMap.
  151731. */
  151732. colorMultiply?: Vector3;
  151733. }
  151734. /**
  151735. * Defines the IDisposable interface in order to be cleanable from resources.
  151736. */
  151737. export interface ISpriteMap extends IDisposable {
  151738. /**
  151739. * String name of the SpriteMap.
  151740. */
  151741. name: string;
  151742. /**
  151743. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  151744. */
  151745. atlasJSON: ISpriteJSONAtlas;
  151746. /**
  151747. * Texture of the SpriteMap.
  151748. */
  151749. spriteSheet: Texture;
  151750. /**
  151751. * The parameters to initialize the SpriteMap with.
  151752. */
  151753. options: ISpriteMapOptions;
  151754. }
  151755. /**
  151756. * Class used to manage a grid restricted sprite deployment on an Output plane.
  151757. */
  151758. export class SpriteMap implements ISpriteMap {
  151759. /** The Name of the spriteMap */
  151760. name: string;
  151761. /** The JSON file with the frame and meta data */
  151762. atlasJSON: ISpriteJSONAtlas;
  151763. /** The systems Sprite Sheet Texture */
  151764. spriteSheet: Texture;
  151765. /** Arguments passed with the Constructor */
  151766. options: ISpriteMapOptions;
  151767. /** Public Sprite Storage array, parsed from atlasJSON */
  151768. sprites: Array<ISpriteJSONSprite>;
  151769. /** Returns the Number of Sprites in the System */
  151770. get spriteCount(): number;
  151771. /** Returns the Position of Output Plane*/
  151772. get position(): Vector3;
  151773. /** Returns the Position of Output Plane*/
  151774. set position(v: Vector3);
  151775. /** Returns the Rotation of Output Plane*/
  151776. get rotation(): Vector3;
  151777. /** Returns the Rotation of Output Plane*/
  151778. set rotation(v: Vector3);
  151779. /** Sets the AnimationMap*/
  151780. get animationMap(): RawTexture;
  151781. /** Sets the AnimationMap*/
  151782. set animationMap(v: RawTexture);
  151783. /** Scene that the SpriteMap was created in */
  151784. private _scene;
  151785. /** Texture Buffer of Float32 that holds tile frame data*/
  151786. private _frameMap;
  151787. /** Texture Buffers of Float32 that holds tileMap data*/
  151788. private _tileMaps;
  151789. /** Texture Buffer of Float32 that holds Animation Data*/
  151790. private _animationMap;
  151791. /** Custom ShaderMaterial Central to the System*/
  151792. private _material;
  151793. /** Custom ShaderMaterial Central to the System*/
  151794. private _output;
  151795. /** Systems Time Ticker*/
  151796. private _time;
  151797. /**
  151798. * Creates a new SpriteMap
  151799. * @param name defines the SpriteMaps Name
  151800. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  151801. * @param spriteSheet is the Texture that the Sprites are on.
  151802. * @param options a basic deployment configuration
  151803. * @param scene The Scene that the map is deployed on
  151804. */
  151805. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  151806. /**
  151807. * Returns tileID location
  151808. * @returns Vector2 the cell position ID
  151809. */
  151810. getTileID(): Vector2;
  151811. /**
  151812. * Gets the UV location of the mouse over the SpriteMap.
  151813. * @returns Vector2 the UV position of the mouse interaction
  151814. */
  151815. getMousePosition(): Vector2;
  151816. /**
  151817. * Creates the "frame" texture Buffer
  151818. * -------------------------------------
  151819. * Structure of frames
  151820. * "filename": "Falling-Water-2.png",
  151821. * "frame": {"x":69,"y":103,"w":24,"h":32},
  151822. * "rotated": true,
  151823. * "trimmed": true,
  151824. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  151825. * "sourceSize": {"w":32,"h":32}
  151826. * @returns RawTexture of the frameMap
  151827. */
  151828. private _createFrameBuffer;
  151829. /**
  151830. * Creates the tileMap texture Buffer
  151831. * @param buffer normally and array of numbers, or a false to generate from scratch
  151832. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  151833. * @returns RawTexture of the tileMap
  151834. */
  151835. private _createTileBuffer;
  151836. /**
  151837. * Modifies the data of the tileMaps
  151838. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  151839. * @param pos is the iVector2 Coordinates of the Tile
  151840. * @param tile The SpriteIndex of the new Tile
  151841. */
  151842. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  151843. /**
  151844. * Creates the animationMap texture Buffer
  151845. * @param buffer normally and array of numbers, or a false to generate from scratch
  151846. * @returns RawTexture of the animationMap
  151847. */
  151848. private _createTileAnimationBuffer;
  151849. /**
  151850. * Modifies the data of the animationMap
  151851. * @param cellID is the Index of the Sprite
  151852. * @param _frame is the target Animation frame
  151853. * @param toCell is the Target Index of the next frame of the animation
  151854. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  151855. * @param speed is a global scalar of the time variable on the map.
  151856. */
  151857. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  151858. /**
  151859. * Exports the .tilemaps file
  151860. */
  151861. saveTileMaps(): void;
  151862. /**
  151863. * Imports the .tilemaps file
  151864. * @param url of the .tilemaps file
  151865. */
  151866. loadTileMaps(url: string): void;
  151867. /**
  151868. * Release associated resources
  151869. */
  151870. dispose(): void;
  151871. }
  151872. }
  151873. declare module BABYLON {
  151874. /**
  151875. * Class used to manage multiple sprites of different sizes on the same spritesheet
  151876. * @see https://doc.babylonjs.com/babylon101/sprites
  151877. */
  151878. export class SpritePackedManager extends SpriteManager {
  151879. /** defines the packed manager's name */
  151880. name: string;
  151881. /**
  151882. * Creates a new sprite manager from a packed sprite sheet
  151883. * @param name defines the manager's name
  151884. * @param imgUrl defines the sprite sheet url
  151885. * @param capacity defines the maximum allowed number of sprites
  151886. * @param scene defines the hosting scene
  151887. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  151888. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  151889. * @param samplingMode defines the smapling mode to use with spritesheet
  151890. * @param fromPacked set to true; do not alter
  151891. */
  151892. constructor(
  151893. /** defines the packed manager's name */
  151894. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  151895. }
  151896. }
  151897. declare module BABYLON {
  151898. /**
  151899. * Defines the list of states available for a task inside a AssetsManager
  151900. */
  151901. export enum AssetTaskState {
  151902. /**
  151903. * Initialization
  151904. */
  151905. INIT = 0,
  151906. /**
  151907. * Running
  151908. */
  151909. RUNNING = 1,
  151910. /**
  151911. * Done
  151912. */
  151913. DONE = 2,
  151914. /**
  151915. * Error
  151916. */
  151917. ERROR = 3
  151918. }
  151919. /**
  151920. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  151921. */
  151922. export abstract class AbstractAssetTask {
  151923. /**
  151924. * Task name
  151925. */ name: string;
  151926. /**
  151927. * Callback called when the task is successful
  151928. */
  151929. onSuccess: (task: any) => void;
  151930. /**
  151931. * Callback called when the task is not successful
  151932. */
  151933. onError: (task: any, message?: string, exception?: any) => void;
  151934. /**
  151935. * Creates a new AssetsManager
  151936. * @param name defines the name of the task
  151937. */
  151938. constructor(
  151939. /**
  151940. * Task name
  151941. */ name: string);
  151942. private _isCompleted;
  151943. private _taskState;
  151944. private _errorObject;
  151945. /**
  151946. * Get if the task is completed
  151947. */
  151948. get isCompleted(): boolean;
  151949. /**
  151950. * Gets the current state of the task
  151951. */
  151952. get taskState(): AssetTaskState;
  151953. /**
  151954. * Gets the current error object (if task is in error)
  151955. */
  151956. get errorObject(): {
  151957. message?: string;
  151958. exception?: any;
  151959. };
  151960. /**
  151961. * Internal only
  151962. * @hidden
  151963. */
  151964. _setErrorObject(message?: string, exception?: any): void;
  151965. /**
  151966. * Execute the current task
  151967. * @param scene defines the scene where you want your assets to be loaded
  151968. * @param onSuccess is a callback called when the task is successfully executed
  151969. * @param onError is a callback called if an error occurs
  151970. */
  151971. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151972. /**
  151973. * Execute the current task
  151974. * @param scene defines the scene where you want your assets to be loaded
  151975. * @param onSuccess is a callback called when the task is successfully executed
  151976. * @param onError is a callback called if an error occurs
  151977. */
  151978. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151979. /**
  151980. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  151981. * This can be used with failed tasks that have the reason for failure fixed.
  151982. */
  151983. reset(): void;
  151984. private onErrorCallback;
  151985. private onDoneCallback;
  151986. }
  151987. /**
  151988. * Define the interface used by progress events raised during assets loading
  151989. */
  151990. export interface IAssetsProgressEvent {
  151991. /**
  151992. * Defines the number of remaining tasks to process
  151993. */
  151994. remainingCount: number;
  151995. /**
  151996. * Defines the total number of tasks
  151997. */
  151998. totalCount: number;
  151999. /**
  152000. * Defines the task that was just processed
  152001. */
  152002. task: AbstractAssetTask;
  152003. }
  152004. /**
  152005. * Class used to share progress information about assets loading
  152006. */
  152007. export class AssetsProgressEvent implements IAssetsProgressEvent {
  152008. /**
  152009. * Defines the number of remaining tasks to process
  152010. */
  152011. remainingCount: number;
  152012. /**
  152013. * Defines the total number of tasks
  152014. */
  152015. totalCount: number;
  152016. /**
  152017. * Defines the task that was just processed
  152018. */
  152019. task: AbstractAssetTask;
  152020. /**
  152021. * Creates a AssetsProgressEvent
  152022. * @param remainingCount defines the number of remaining tasks to process
  152023. * @param totalCount defines the total number of tasks
  152024. * @param task defines the task that was just processed
  152025. */
  152026. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  152027. }
  152028. /**
  152029. * Define a task used by AssetsManager to load assets into a container
  152030. */
  152031. export class ContainerAssetTask extends AbstractAssetTask {
  152032. /**
  152033. * Defines the name of the task
  152034. */
  152035. name: string;
  152036. /**
  152037. * Defines the list of mesh's names you want to load
  152038. */
  152039. meshesNames: any;
  152040. /**
  152041. * Defines the root url to use as a base to load your meshes and associated resources
  152042. */
  152043. rootUrl: string;
  152044. /**
  152045. * Defines the filename or File of the scene to load from
  152046. */
  152047. sceneFilename: string | File;
  152048. /**
  152049. * Get the loaded asset container
  152050. */
  152051. loadedContainer: AssetContainer;
  152052. /**
  152053. * Gets the list of loaded meshes
  152054. */
  152055. loadedMeshes: Array<AbstractMesh>;
  152056. /**
  152057. * Gets the list of loaded particle systems
  152058. */
  152059. loadedParticleSystems: Array<IParticleSystem>;
  152060. /**
  152061. * Gets the list of loaded skeletons
  152062. */
  152063. loadedSkeletons: Array<Skeleton>;
  152064. /**
  152065. * Gets the list of loaded animation groups
  152066. */
  152067. loadedAnimationGroups: Array<AnimationGroup>;
  152068. /**
  152069. * Callback called when the task is successful
  152070. */
  152071. onSuccess: (task: ContainerAssetTask) => void;
  152072. /**
  152073. * Callback called when the task is successful
  152074. */
  152075. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  152076. /**
  152077. * Creates a new ContainerAssetTask
  152078. * @param name defines the name of the task
  152079. * @param meshesNames defines the list of mesh's names you want to load
  152080. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  152081. * @param sceneFilename defines the filename or File of the scene to load from
  152082. */
  152083. constructor(
  152084. /**
  152085. * Defines the name of the task
  152086. */
  152087. name: string,
  152088. /**
  152089. * Defines the list of mesh's names you want to load
  152090. */
  152091. meshesNames: any,
  152092. /**
  152093. * Defines the root url to use as a base to load your meshes and associated resources
  152094. */
  152095. rootUrl: string,
  152096. /**
  152097. * Defines the filename or File of the scene to load from
  152098. */
  152099. sceneFilename: string | File);
  152100. /**
  152101. * Execute the current task
  152102. * @param scene defines the scene where you want your assets to be loaded
  152103. * @param onSuccess is a callback called when the task is successfully executed
  152104. * @param onError is a callback called if an error occurs
  152105. */
  152106. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152107. }
  152108. /**
  152109. * Define a task used by AssetsManager to load meshes
  152110. */
  152111. export class MeshAssetTask extends AbstractAssetTask {
  152112. /**
  152113. * Defines the name of the task
  152114. */
  152115. name: string;
  152116. /**
  152117. * Defines the list of mesh's names you want to load
  152118. */
  152119. meshesNames: any;
  152120. /**
  152121. * Defines the root url to use as a base to load your meshes and associated resources
  152122. */
  152123. rootUrl: string;
  152124. /**
  152125. * Defines the filename or File of the scene to load from
  152126. */
  152127. sceneFilename: string | File;
  152128. /**
  152129. * Gets the list of loaded meshes
  152130. */
  152131. loadedMeshes: Array<AbstractMesh>;
  152132. /**
  152133. * Gets the list of loaded particle systems
  152134. */
  152135. loadedParticleSystems: Array<IParticleSystem>;
  152136. /**
  152137. * Gets the list of loaded skeletons
  152138. */
  152139. loadedSkeletons: Array<Skeleton>;
  152140. /**
  152141. * Gets the list of loaded animation groups
  152142. */
  152143. loadedAnimationGroups: Array<AnimationGroup>;
  152144. /**
  152145. * Callback called when the task is successful
  152146. */
  152147. onSuccess: (task: MeshAssetTask) => void;
  152148. /**
  152149. * Callback called when the task is successful
  152150. */
  152151. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  152152. /**
  152153. * Creates a new MeshAssetTask
  152154. * @param name defines the name of the task
  152155. * @param meshesNames defines the list of mesh's names you want to load
  152156. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  152157. * @param sceneFilename defines the filename or File of the scene to load from
  152158. */
  152159. constructor(
  152160. /**
  152161. * Defines the name of the task
  152162. */
  152163. name: string,
  152164. /**
  152165. * Defines the list of mesh's names you want to load
  152166. */
  152167. meshesNames: any,
  152168. /**
  152169. * Defines the root url to use as a base to load your meshes and associated resources
  152170. */
  152171. rootUrl: string,
  152172. /**
  152173. * Defines the filename or File of the scene to load from
  152174. */
  152175. sceneFilename: string | File);
  152176. /**
  152177. * Execute the current task
  152178. * @param scene defines the scene where you want your assets to be loaded
  152179. * @param onSuccess is a callback called when the task is successfully executed
  152180. * @param onError is a callback called if an error occurs
  152181. */
  152182. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152183. }
  152184. /**
  152185. * Define a task used by AssetsManager to load text content
  152186. */
  152187. export class TextFileAssetTask extends AbstractAssetTask {
  152188. /**
  152189. * Defines the name of the task
  152190. */
  152191. name: string;
  152192. /**
  152193. * Defines the location of the file to load
  152194. */
  152195. url: string;
  152196. /**
  152197. * Gets the loaded text string
  152198. */
  152199. text: string;
  152200. /**
  152201. * Callback called when the task is successful
  152202. */
  152203. onSuccess: (task: TextFileAssetTask) => void;
  152204. /**
  152205. * Callback called when the task is successful
  152206. */
  152207. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  152208. /**
  152209. * Creates a new TextFileAssetTask object
  152210. * @param name defines the name of the task
  152211. * @param url defines the location of the file to load
  152212. */
  152213. constructor(
  152214. /**
  152215. * Defines the name of the task
  152216. */
  152217. name: string,
  152218. /**
  152219. * Defines the location of the file to load
  152220. */
  152221. url: string);
  152222. /**
  152223. * Execute the current task
  152224. * @param scene defines the scene where you want your assets to be loaded
  152225. * @param onSuccess is a callback called when the task is successfully executed
  152226. * @param onError is a callback called if an error occurs
  152227. */
  152228. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152229. }
  152230. /**
  152231. * Define a task used by AssetsManager to load binary data
  152232. */
  152233. export class BinaryFileAssetTask extends AbstractAssetTask {
  152234. /**
  152235. * Defines the name of the task
  152236. */
  152237. name: string;
  152238. /**
  152239. * Defines the location of the file to load
  152240. */
  152241. url: string;
  152242. /**
  152243. * Gets the lodaded data (as an array buffer)
  152244. */
  152245. data: ArrayBuffer;
  152246. /**
  152247. * Callback called when the task is successful
  152248. */
  152249. onSuccess: (task: BinaryFileAssetTask) => void;
  152250. /**
  152251. * Callback called when the task is successful
  152252. */
  152253. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  152254. /**
  152255. * Creates a new BinaryFileAssetTask object
  152256. * @param name defines the name of the new task
  152257. * @param url defines the location of the file to load
  152258. */
  152259. constructor(
  152260. /**
  152261. * Defines the name of the task
  152262. */
  152263. name: string,
  152264. /**
  152265. * Defines the location of the file to load
  152266. */
  152267. url: string);
  152268. /**
  152269. * Execute the current task
  152270. * @param scene defines the scene where you want your assets to be loaded
  152271. * @param onSuccess is a callback called when the task is successfully executed
  152272. * @param onError is a callback called if an error occurs
  152273. */
  152274. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152275. }
  152276. /**
  152277. * Define a task used by AssetsManager to load images
  152278. */
  152279. export class ImageAssetTask extends AbstractAssetTask {
  152280. /**
  152281. * Defines the name of the task
  152282. */
  152283. name: string;
  152284. /**
  152285. * Defines the location of the image to load
  152286. */
  152287. url: string;
  152288. /**
  152289. * Gets the loaded images
  152290. */
  152291. image: HTMLImageElement;
  152292. /**
  152293. * Callback called when the task is successful
  152294. */
  152295. onSuccess: (task: ImageAssetTask) => void;
  152296. /**
  152297. * Callback called when the task is successful
  152298. */
  152299. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  152300. /**
  152301. * Creates a new ImageAssetTask
  152302. * @param name defines the name of the task
  152303. * @param url defines the location of the image to load
  152304. */
  152305. constructor(
  152306. /**
  152307. * Defines the name of the task
  152308. */
  152309. name: string,
  152310. /**
  152311. * Defines the location of the image to load
  152312. */
  152313. url: string);
  152314. /**
  152315. * Execute the current task
  152316. * @param scene defines the scene where you want your assets to be loaded
  152317. * @param onSuccess is a callback called when the task is successfully executed
  152318. * @param onError is a callback called if an error occurs
  152319. */
  152320. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152321. }
  152322. /**
  152323. * Defines the interface used by texture loading tasks
  152324. */
  152325. export interface ITextureAssetTask<TEX extends BaseTexture> {
  152326. /**
  152327. * Gets the loaded texture
  152328. */
  152329. texture: TEX;
  152330. }
  152331. /**
  152332. * Define a task used by AssetsManager to load 2D textures
  152333. */
  152334. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  152335. /**
  152336. * Defines the name of the task
  152337. */
  152338. name: string;
  152339. /**
  152340. * Defines the location of the file to load
  152341. */
  152342. url: string;
  152343. /**
  152344. * Defines if mipmap should not be generated (default is false)
  152345. */
  152346. noMipmap?: boolean | undefined;
  152347. /**
  152348. * Defines if texture must be inverted on Y axis (default is true)
  152349. */
  152350. invertY: boolean;
  152351. /**
  152352. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152353. */
  152354. samplingMode: number;
  152355. /**
  152356. * Gets the loaded texture
  152357. */
  152358. texture: Texture;
  152359. /**
  152360. * Callback called when the task is successful
  152361. */
  152362. onSuccess: (task: TextureAssetTask) => void;
  152363. /**
  152364. * Callback called when the task is successful
  152365. */
  152366. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  152367. /**
  152368. * Creates a new TextureAssetTask object
  152369. * @param name defines the name of the task
  152370. * @param url defines the location of the file to load
  152371. * @param noMipmap defines if mipmap should not be generated (default is false)
  152372. * @param invertY defines if texture must be inverted on Y axis (default is true)
  152373. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152374. */
  152375. constructor(
  152376. /**
  152377. * Defines the name of the task
  152378. */
  152379. name: string,
  152380. /**
  152381. * Defines the location of the file to load
  152382. */
  152383. url: string,
  152384. /**
  152385. * Defines if mipmap should not be generated (default is false)
  152386. */
  152387. noMipmap?: boolean | undefined,
  152388. /**
  152389. * Defines if texture must be inverted on Y axis (default is true)
  152390. */
  152391. invertY?: boolean,
  152392. /**
  152393. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152394. */
  152395. samplingMode?: number);
  152396. /**
  152397. * Execute the current task
  152398. * @param scene defines the scene where you want your assets to be loaded
  152399. * @param onSuccess is a callback called when the task is successfully executed
  152400. * @param onError is a callback called if an error occurs
  152401. */
  152402. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152403. }
  152404. /**
  152405. * Define a task used by AssetsManager to load cube textures
  152406. */
  152407. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  152408. /**
  152409. * Defines the name of the task
  152410. */
  152411. name: string;
  152412. /**
  152413. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152414. */
  152415. url: string;
  152416. /**
  152417. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152418. */
  152419. extensions?: string[] | undefined;
  152420. /**
  152421. * Defines if mipmaps should not be generated (default is false)
  152422. */
  152423. noMipmap?: boolean | undefined;
  152424. /**
  152425. * Defines the explicit list of files (undefined by default)
  152426. */
  152427. files?: string[] | undefined;
  152428. /**
  152429. * Gets the loaded texture
  152430. */
  152431. texture: CubeTexture;
  152432. /**
  152433. * Callback called when the task is successful
  152434. */
  152435. onSuccess: (task: CubeTextureAssetTask) => void;
  152436. /**
  152437. * Callback called when the task is successful
  152438. */
  152439. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  152440. /**
  152441. * Creates a new CubeTextureAssetTask
  152442. * @param name defines the name of the task
  152443. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152444. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152445. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152446. * @param files defines the explicit list of files (undefined by default)
  152447. */
  152448. constructor(
  152449. /**
  152450. * Defines the name of the task
  152451. */
  152452. name: string,
  152453. /**
  152454. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152455. */
  152456. url: string,
  152457. /**
  152458. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152459. */
  152460. extensions?: string[] | undefined,
  152461. /**
  152462. * Defines if mipmaps should not be generated (default is false)
  152463. */
  152464. noMipmap?: boolean | undefined,
  152465. /**
  152466. * Defines the explicit list of files (undefined by default)
  152467. */
  152468. files?: string[] | undefined);
  152469. /**
  152470. * Execute the current task
  152471. * @param scene defines the scene where you want your assets to be loaded
  152472. * @param onSuccess is a callback called when the task is successfully executed
  152473. * @param onError is a callback called if an error occurs
  152474. */
  152475. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152476. }
  152477. /**
  152478. * Define a task used by AssetsManager to load HDR cube textures
  152479. */
  152480. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  152481. /**
  152482. * Defines the name of the task
  152483. */
  152484. name: string;
  152485. /**
  152486. * Defines the location of the file to load
  152487. */
  152488. url: string;
  152489. /**
  152490. * Defines the desired size (the more it increases the longer the generation will be)
  152491. */
  152492. size: number;
  152493. /**
  152494. * Defines if mipmaps should not be generated (default is false)
  152495. */
  152496. noMipmap: boolean;
  152497. /**
  152498. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152499. */
  152500. generateHarmonics: boolean;
  152501. /**
  152502. * 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)
  152503. */
  152504. gammaSpace: boolean;
  152505. /**
  152506. * Internal Use Only
  152507. */
  152508. reserved: boolean;
  152509. /**
  152510. * Gets the loaded texture
  152511. */
  152512. texture: HDRCubeTexture;
  152513. /**
  152514. * Callback called when the task is successful
  152515. */
  152516. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  152517. /**
  152518. * Callback called when the task is successful
  152519. */
  152520. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  152521. /**
  152522. * Creates a new HDRCubeTextureAssetTask object
  152523. * @param name defines the name of the task
  152524. * @param url defines the location of the file to load
  152525. * @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.
  152526. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152527. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152528. * @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)
  152529. * @param reserved Internal use only
  152530. */
  152531. constructor(
  152532. /**
  152533. * Defines the name of the task
  152534. */
  152535. name: string,
  152536. /**
  152537. * Defines the location of the file to load
  152538. */
  152539. url: string,
  152540. /**
  152541. * Defines the desired size (the more it increases the longer the generation will be)
  152542. */
  152543. size: number,
  152544. /**
  152545. * Defines if mipmaps should not be generated (default is false)
  152546. */
  152547. noMipmap?: boolean,
  152548. /**
  152549. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152550. */
  152551. generateHarmonics?: boolean,
  152552. /**
  152553. * 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)
  152554. */
  152555. gammaSpace?: boolean,
  152556. /**
  152557. * Internal Use Only
  152558. */
  152559. reserved?: boolean);
  152560. /**
  152561. * Execute the current task
  152562. * @param scene defines the scene where you want your assets to be loaded
  152563. * @param onSuccess is a callback called when the task is successfully executed
  152564. * @param onError is a callback called if an error occurs
  152565. */
  152566. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152567. }
  152568. /**
  152569. * Define a task used by AssetsManager to load Equirectangular cube textures
  152570. */
  152571. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  152572. /**
  152573. * Defines the name of the task
  152574. */
  152575. name: string;
  152576. /**
  152577. * Defines the location of the file to load
  152578. */
  152579. url: string;
  152580. /**
  152581. * Defines the desired size (the more it increases the longer the generation will be)
  152582. */
  152583. size: number;
  152584. /**
  152585. * Defines if mipmaps should not be generated (default is false)
  152586. */
  152587. noMipmap: boolean;
  152588. /**
  152589. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  152590. * but the standard material would require them in Gamma space) (default is true)
  152591. */
  152592. gammaSpace: boolean;
  152593. /**
  152594. * Gets the loaded texture
  152595. */
  152596. texture: EquiRectangularCubeTexture;
  152597. /**
  152598. * Callback called when the task is successful
  152599. */
  152600. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  152601. /**
  152602. * Callback called when the task is successful
  152603. */
  152604. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  152605. /**
  152606. * Creates a new EquiRectangularCubeTextureAssetTask object
  152607. * @param name defines the name of the task
  152608. * @param url defines the location of the file to load
  152609. * @param size defines the desired size (the more it increases the longer the generation will be)
  152610. * If the size is omitted this implies you are using a preprocessed cubemap.
  152611. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152612. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  152613. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  152614. * (default is true)
  152615. */
  152616. constructor(
  152617. /**
  152618. * Defines the name of the task
  152619. */
  152620. name: string,
  152621. /**
  152622. * Defines the location of the file to load
  152623. */
  152624. url: string,
  152625. /**
  152626. * Defines the desired size (the more it increases the longer the generation will be)
  152627. */
  152628. size: number,
  152629. /**
  152630. * Defines if mipmaps should not be generated (default is false)
  152631. */
  152632. noMipmap?: boolean,
  152633. /**
  152634. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  152635. * but the standard material would require them in Gamma space) (default is true)
  152636. */
  152637. gammaSpace?: boolean);
  152638. /**
  152639. * Execute the current task
  152640. * @param scene defines the scene where you want your assets to be loaded
  152641. * @param onSuccess is a callback called when the task is successfully executed
  152642. * @param onError is a callback called if an error occurs
  152643. */
  152644. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152645. }
  152646. /**
  152647. * This class can be used to easily import assets into a scene
  152648. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  152649. */
  152650. export class AssetsManager {
  152651. private _scene;
  152652. private _isLoading;
  152653. protected _tasks: AbstractAssetTask[];
  152654. protected _waitingTasksCount: number;
  152655. protected _totalTasksCount: number;
  152656. /**
  152657. * Callback called when all tasks are processed
  152658. */
  152659. onFinish: (tasks: AbstractAssetTask[]) => void;
  152660. /**
  152661. * Callback called when a task is successful
  152662. */
  152663. onTaskSuccess: (task: AbstractAssetTask) => void;
  152664. /**
  152665. * Callback called when a task had an error
  152666. */
  152667. onTaskError: (task: AbstractAssetTask) => void;
  152668. /**
  152669. * Callback called when a task is done (whatever the result is)
  152670. */
  152671. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  152672. /**
  152673. * Observable called when all tasks are processed
  152674. */
  152675. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  152676. /**
  152677. * Observable called when a task had an error
  152678. */
  152679. onTaskErrorObservable: Observable<AbstractAssetTask>;
  152680. /**
  152681. * Observable called when all tasks were executed
  152682. */
  152683. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  152684. /**
  152685. * Observable called when a task is done (whatever the result is)
  152686. */
  152687. onProgressObservable: Observable<IAssetsProgressEvent>;
  152688. /**
  152689. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  152690. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  152691. */
  152692. useDefaultLoadingScreen: boolean;
  152693. /**
  152694. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  152695. * when all assets have been downloaded.
  152696. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  152697. */
  152698. autoHideLoadingUI: boolean;
  152699. /**
  152700. * Creates a new AssetsManager
  152701. * @param scene defines the scene to work on
  152702. */
  152703. constructor(scene: Scene);
  152704. /**
  152705. * Add a ContainerAssetTask to the list of active tasks
  152706. * @param taskName defines the name of the new task
  152707. * @param meshesNames defines the name of meshes to load
  152708. * @param rootUrl defines the root url to use to locate files
  152709. * @param sceneFilename defines the filename of the scene file
  152710. * @returns a new ContainerAssetTask object
  152711. */
  152712. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  152713. /**
  152714. * Add a MeshAssetTask to the list of active tasks
  152715. * @param taskName defines the name of the new task
  152716. * @param meshesNames defines the name of meshes to load
  152717. * @param rootUrl defines the root url to use to locate files
  152718. * @param sceneFilename defines the filename of the scene file
  152719. * @returns a new MeshAssetTask object
  152720. */
  152721. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  152722. /**
  152723. * Add a TextFileAssetTask to the list of active tasks
  152724. * @param taskName defines the name of the new task
  152725. * @param url defines the url of the file to load
  152726. * @returns a new TextFileAssetTask object
  152727. */
  152728. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  152729. /**
  152730. * Add a BinaryFileAssetTask to the list of active tasks
  152731. * @param taskName defines the name of the new task
  152732. * @param url defines the url of the file to load
  152733. * @returns a new BinaryFileAssetTask object
  152734. */
  152735. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  152736. /**
  152737. * Add a ImageAssetTask to the list of active tasks
  152738. * @param taskName defines the name of the new task
  152739. * @param url defines the url of the file to load
  152740. * @returns a new ImageAssetTask object
  152741. */
  152742. addImageTask(taskName: string, url: string): ImageAssetTask;
  152743. /**
  152744. * Add a TextureAssetTask to the list of active tasks
  152745. * @param taskName defines the name of the new task
  152746. * @param url defines the url of the file to load
  152747. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  152748. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  152749. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  152750. * @returns a new TextureAssetTask object
  152751. */
  152752. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  152753. /**
  152754. * Add a CubeTextureAssetTask to the list of active tasks
  152755. * @param taskName defines the name of the new task
  152756. * @param url defines the url of the file to load
  152757. * @param extensions defines the extension to use to load the cube map (can be null)
  152758. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  152759. * @param files defines the list of files to load (can be null)
  152760. * @returns a new CubeTextureAssetTask object
  152761. */
  152762. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  152763. /**
  152764. *
  152765. * Add a HDRCubeTextureAssetTask to the list of active tasks
  152766. * @param taskName defines the name of the new task
  152767. * @param url defines the url of the file to load
  152768. * @param size defines the size you want for the cubemap (can be null)
  152769. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  152770. * @param generateHarmonics defines if you want to automatically generate (true by default)
  152771. * @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)
  152772. * @param reserved Internal use only
  152773. * @returns a new HDRCubeTextureAssetTask object
  152774. */
  152775. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  152776. /**
  152777. *
  152778. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  152779. * @param taskName defines the name of the new task
  152780. * @param url defines the url of the file to load
  152781. * @param size defines the size you want for the cubemap (can be null)
  152782. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  152783. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  152784. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  152785. * @returns a new EquiRectangularCubeTextureAssetTask object
  152786. */
  152787. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  152788. /**
  152789. * Remove a task from the assets manager.
  152790. * @param task the task to remove
  152791. */
  152792. removeTask(task: AbstractAssetTask): void;
  152793. private _decreaseWaitingTasksCount;
  152794. private _runTask;
  152795. /**
  152796. * Reset the AssetsManager and remove all tasks
  152797. * @return the current instance of the AssetsManager
  152798. */
  152799. reset(): AssetsManager;
  152800. /**
  152801. * Start the loading process
  152802. * @return the current instance of the AssetsManager
  152803. */
  152804. load(): AssetsManager;
  152805. /**
  152806. * Start the loading process as an async operation
  152807. * @return a promise returning the list of failed tasks
  152808. */
  152809. loadAsync(): Promise<void>;
  152810. }
  152811. }
  152812. declare module BABYLON {
  152813. /**
  152814. * Wrapper class for promise with external resolve and reject.
  152815. */
  152816. export class Deferred<T> {
  152817. /**
  152818. * The promise associated with this deferred object.
  152819. */
  152820. readonly promise: Promise<T>;
  152821. private _resolve;
  152822. private _reject;
  152823. /**
  152824. * The resolve method of the promise associated with this deferred object.
  152825. */
  152826. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  152827. /**
  152828. * The reject method of the promise associated with this deferred object.
  152829. */
  152830. get reject(): (reason?: any) => void;
  152831. /**
  152832. * Constructor for this deferred object.
  152833. */
  152834. constructor();
  152835. }
  152836. }
  152837. declare module BABYLON {
  152838. /**
  152839. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  152840. */
  152841. export class MeshExploder {
  152842. private _centerMesh;
  152843. private _meshes;
  152844. private _meshesOrigins;
  152845. private _toCenterVectors;
  152846. private _scaledDirection;
  152847. private _newPosition;
  152848. private _centerPosition;
  152849. /**
  152850. * Explodes meshes from a center mesh.
  152851. * @param meshes The meshes to explode.
  152852. * @param centerMesh The mesh to be center of explosion.
  152853. */
  152854. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  152855. private _setCenterMesh;
  152856. /**
  152857. * Get class name
  152858. * @returns "MeshExploder"
  152859. */
  152860. getClassName(): string;
  152861. /**
  152862. * "Exploded meshes"
  152863. * @returns Array of meshes with the centerMesh at index 0.
  152864. */
  152865. getMeshes(): Array<Mesh>;
  152866. /**
  152867. * Explodes meshes giving a specific direction
  152868. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  152869. */
  152870. explode(direction?: number): void;
  152871. }
  152872. }
  152873. declare module BABYLON {
  152874. /**
  152875. * Class used to help managing file picking and drag'n'drop
  152876. */
  152877. export class FilesInput {
  152878. /**
  152879. * List of files ready to be loaded
  152880. */
  152881. static get FilesToLoad(): {
  152882. [key: string]: File;
  152883. };
  152884. /**
  152885. * Callback called when a file is processed
  152886. */
  152887. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  152888. private _engine;
  152889. private _currentScene;
  152890. private _sceneLoadedCallback;
  152891. private _progressCallback;
  152892. private _additionalRenderLoopLogicCallback;
  152893. private _textureLoadingCallback;
  152894. private _startingProcessingFilesCallback;
  152895. private _onReloadCallback;
  152896. private _errorCallback;
  152897. private _elementToMonitor;
  152898. private _sceneFileToLoad;
  152899. private _filesToLoad;
  152900. /**
  152901. * Creates a new FilesInput
  152902. * @param engine defines the rendering engine
  152903. * @param scene defines the hosting scene
  152904. * @param sceneLoadedCallback callback called when scene is loaded
  152905. * @param progressCallback callback called to track progress
  152906. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  152907. * @param textureLoadingCallback callback called when a texture is loading
  152908. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  152909. * @param onReloadCallback callback called when a reload is requested
  152910. * @param errorCallback callback call if an error occurs
  152911. */
  152912. 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>);
  152913. private _dragEnterHandler;
  152914. private _dragOverHandler;
  152915. private _dropHandler;
  152916. /**
  152917. * Calls this function to listen to drag'n'drop events on a specific DOM element
  152918. * @param elementToMonitor defines the DOM element to track
  152919. */
  152920. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  152921. /** Gets the current list of files to load */
  152922. get filesToLoad(): File[];
  152923. /**
  152924. * Release all associated resources
  152925. */
  152926. dispose(): void;
  152927. private renderFunction;
  152928. private drag;
  152929. private drop;
  152930. private _traverseFolder;
  152931. private _processFiles;
  152932. /**
  152933. * Load files from a drop event
  152934. * @param event defines the drop event to use as source
  152935. */
  152936. loadFiles(event: any): void;
  152937. private _processReload;
  152938. /**
  152939. * Reload the current scene from the loaded files
  152940. */
  152941. reload(): void;
  152942. }
  152943. }
  152944. declare module BABYLON {
  152945. /**
  152946. * Defines the root class used to create scene optimization to use with SceneOptimizer
  152947. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152948. */
  152949. export class SceneOptimization {
  152950. /**
  152951. * Defines the priority of this optimization (0 by default which means first in the list)
  152952. */
  152953. priority: number;
  152954. /**
  152955. * Gets a string describing the action executed by the current optimization
  152956. * @returns description string
  152957. */
  152958. getDescription(): string;
  152959. /**
  152960. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152961. * @param scene defines the current scene where to apply this optimization
  152962. * @param optimizer defines the current optimizer
  152963. * @returns true if everything that can be done was applied
  152964. */
  152965. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152966. /**
  152967. * Creates the SceneOptimization object
  152968. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152969. * @param desc defines the description associated with the optimization
  152970. */
  152971. constructor(
  152972. /**
  152973. * Defines the priority of this optimization (0 by default which means first in the list)
  152974. */
  152975. priority?: number);
  152976. }
  152977. /**
  152978. * Defines an optimization used to reduce the size of render target textures
  152979. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152980. */
  152981. export class TextureOptimization extends SceneOptimization {
  152982. /**
  152983. * Defines the priority of this optimization (0 by default which means first in the list)
  152984. */
  152985. priority: number;
  152986. /**
  152987. * 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
  152988. */
  152989. maximumSize: number;
  152990. /**
  152991. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  152992. */
  152993. step: number;
  152994. /**
  152995. * Gets a string describing the action executed by the current optimization
  152996. * @returns description string
  152997. */
  152998. getDescription(): string;
  152999. /**
  153000. * Creates the TextureOptimization object
  153001. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153002. * @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
  153003. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153004. */
  153005. constructor(
  153006. /**
  153007. * Defines the priority of this optimization (0 by default which means first in the list)
  153008. */
  153009. priority?: number,
  153010. /**
  153011. * 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
  153012. */
  153013. maximumSize?: number,
  153014. /**
  153015. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153016. */
  153017. step?: number);
  153018. /**
  153019. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153020. * @param scene defines the current scene where to apply this optimization
  153021. * @param optimizer defines the current optimizer
  153022. * @returns true if everything that can be done was applied
  153023. */
  153024. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153025. }
  153026. /**
  153027. * Defines an optimization used to increase or decrease the rendering resolution
  153028. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153029. */
  153030. export class HardwareScalingOptimization extends SceneOptimization {
  153031. /**
  153032. * Defines the priority of this optimization (0 by default which means first in the list)
  153033. */
  153034. priority: number;
  153035. /**
  153036. * Defines the maximum scale to use (2 by default)
  153037. */
  153038. maximumScale: number;
  153039. /**
  153040. * Defines the step to use between two passes (0.5 by default)
  153041. */
  153042. step: number;
  153043. private _currentScale;
  153044. private _directionOffset;
  153045. /**
  153046. * Gets a string describing the action executed by the current optimization
  153047. * @return description string
  153048. */
  153049. getDescription(): string;
  153050. /**
  153051. * Creates the HardwareScalingOptimization object
  153052. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153053. * @param maximumScale defines the maximum scale to use (2 by default)
  153054. * @param step defines the step to use between two passes (0.5 by default)
  153055. */
  153056. constructor(
  153057. /**
  153058. * Defines the priority of this optimization (0 by default which means first in the list)
  153059. */
  153060. priority?: number,
  153061. /**
  153062. * Defines the maximum scale to use (2 by default)
  153063. */
  153064. maximumScale?: number,
  153065. /**
  153066. * Defines the step to use between two passes (0.5 by default)
  153067. */
  153068. step?: number);
  153069. /**
  153070. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153071. * @param scene defines the current scene where to apply this optimization
  153072. * @param optimizer defines the current optimizer
  153073. * @returns true if everything that can be done was applied
  153074. */
  153075. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153076. }
  153077. /**
  153078. * Defines an optimization used to remove shadows
  153079. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153080. */
  153081. export class ShadowsOptimization extends SceneOptimization {
  153082. /**
  153083. * Gets a string describing the action executed by the current optimization
  153084. * @return description string
  153085. */
  153086. getDescription(): string;
  153087. /**
  153088. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153089. * @param scene defines the current scene where to apply this optimization
  153090. * @param optimizer defines the current optimizer
  153091. * @returns true if everything that can be done was applied
  153092. */
  153093. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153094. }
  153095. /**
  153096. * Defines an optimization used to turn post-processes off
  153097. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153098. */
  153099. export class PostProcessesOptimization extends SceneOptimization {
  153100. /**
  153101. * Gets a string describing the action executed by the current optimization
  153102. * @return description string
  153103. */
  153104. getDescription(): string;
  153105. /**
  153106. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153107. * @param scene defines the current scene where to apply this optimization
  153108. * @param optimizer defines the current optimizer
  153109. * @returns true if everything that can be done was applied
  153110. */
  153111. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153112. }
  153113. /**
  153114. * Defines an optimization used to turn lens flares off
  153115. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153116. */
  153117. export class LensFlaresOptimization extends SceneOptimization {
  153118. /**
  153119. * Gets a string describing the action executed by the current optimization
  153120. * @return description string
  153121. */
  153122. getDescription(): string;
  153123. /**
  153124. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153125. * @param scene defines the current scene where to apply this optimization
  153126. * @param optimizer defines the current optimizer
  153127. * @returns true if everything that can be done was applied
  153128. */
  153129. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153130. }
  153131. /**
  153132. * Defines an optimization based on user defined callback.
  153133. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153134. */
  153135. export class CustomOptimization extends SceneOptimization {
  153136. /**
  153137. * Callback called to apply the custom optimization.
  153138. */
  153139. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  153140. /**
  153141. * Callback called to get custom description
  153142. */
  153143. onGetDescription: () => string;
  153144. /**
  153145. * Gets a string describing the action executed by the current optimization
  153146. * @returns description string
  153147. */
  153148. getDescription(): string;
  153149. /**
  153150. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153151. * @param scene defines the current scene where to apply this optimization
  153152. * @param optimizer defines the current optimizer
  153153. * @returns true if everything that can be done was applied
  153154. */
  153155. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153156. }
  153157. /**
  153158. * Defines an optimization used to turn particles off
  153159. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153160. */
  153161. export class ParticlesOptimization extends SceneOptimization {
  153162. /**
  153163. * Gets a string describing the action executed by the current optimization
  153164. * @return description string
  153165. */
  153166. getDescription(): string;
  153167. /**
  153168. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153169. * @param scene defines the current scene where to apply this optimization
  153170. * @param optimizer defines the current optimizer
  153171. * @returns true if everything that can be done was applied
  153172. */
  153173. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153174. }
  153175. /**
  153176. * Defines an optimization used to turn render targets off
  153177. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153178. */
  153179. export class RenderTargetsOptimization extends SceneOptimization {
  153180. /**
  153181. * Gets a string describing the action executed by the current optimization
  153182. * @return description string
  153183. */
  153184. getDescription(): string;
  153185. /**
  153186. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153187. * @param scene defines the current scene where to apply this optimization
  153188. * @param optimizer defines the current optimizer
  153189. * @returns true if everything that can be done was applied
  153190. */
  153191. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153192. }
  153193. /**
  153194. * Defines an optimization used to merge meshes with compatible materials
  153195. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153196. */
  153197. export class MergeMeshesOptimization extends SceneOptimization {
  153198. private static _UpdateSelectionTree;
  153199. /**
  153200. * Gets or sets a boolean which defines if optimization octree has to be updated
  153201. */
  153202. static get UpdateSelectionTree(): boolean;
  153203. /**
  153204. * Gets or sets a boolean which defines if optimization octree has to be updated
  153205. */
  153206. static set UpdateSelectionTree(value: boolean);
  153207. /**
  153208. * Gets a string describing the action executed by the current optimization
  153209. * @return description string
  153210. */
  153211. getDescription(): string;
  153212. private _canBeMerged;
  153213. /**
  153214. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153215. * @param scene defines the current scene where to apply this optimization
  153216. * @param optimizer defines the current optimizer
  153217. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  153218. * @returns true if everything that can be done was applied
  153219. */
  153220. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  153221. }
  153222. /**
  153223. * Defines a list of options used by SceneOptimizer
  153224. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153225. */
  153226. export class SceneOptimizerOptions {
  153227. /**
  153228. * Defines the target frame rate to reach (60 by default)
  153229. */
  153230. targetFrameRate: number;
  153231. /**
  153232. * Defines the interval between two checkes (2000ms by default)
  153233. */
  153234. trackerDuration: number;
  153235. /**
  153236. * Gets the list of optimizations to apply
  153237. */
  153238. optimizations: SceneOptimization[];
  153239. /**
  153240. * Creates a new list of options used by SceneOptimizer
  153241. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  153242. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  153243. */
  153244. constructor(
  153245. /**
  153246. * Defines the target frame rate to reach (60 by default)
  153247. */
  153248. targetFrameRate?: number,
  153249. /**
  153250. * Defines the interval between two checkes (2000ms by default)
  153251. */
  153252. trackerDuration?: number);
  153253. /**
  153254. * Add a new optimization
  153255. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  153256. * @returns the current SceneOptimizerOptions
  153257. */
  153258. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  153259. /**
  153260. * Add a new custom optimization
  153261. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  153262. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  153263. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153264. * @returns the current SceneOptimizerOptions
  153265. */
  153266. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  153267. /**
  153268. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  153269. * @param targetFrameRate defines the target frame rate (60 by default)
  153270. * @returns a SceneOptimizerOptions object
  153271. */
  153272. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153273. /**
  153274. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  153275. * @param targetFrameRate defines the target frame rate (60 by default)
  153276. * @returns a SceneOptimizerOptions object
  153277. */
  153278. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153279. /**
  153280. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  153281. * @param targetFrameRate defines the target frame rate (60 by default)
  153282. * @returns a SceneOptimizerOptions object
  153283. */
  153284. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153285. }
  153286. /**
  153287. * Class used to run optimizations in order to reach a target frame rate
  153288. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153289. */
  153290. export class SceneOptimizer implements IDisposable {
  153291. private _isRunning;
  153292. private _options;
  153293. private _scene;
  153294. private _currentPriorityLevel;
  153295. private _targetFrameRate;
  153296. private _trackerDuration;
  153297. private _currentFrameRate;
  153298. private _sceneDisposeObserver;
  153299. private _improvementMode;
  153300. /**
  153301. * Defines an observable called when the optimizer reaches the target frame rate
  153302. */
  153303. onSuccessObservable: Observable<SceneOptimizer>;
  153304. /**
  153305. * Defines an observable called when the optimizer enables an optimization
  153306. */
  153307. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  153308. /**
  153309. * Defines an observable called when the optimizer is not able to reach the target frame rate
  153310. */
  153311. onFailureObservable: Observable<SceneOptimizer>;
  153312. /**
  153313. * Gets a boolean indicating if the optimizer is in improvement mode
  153314. */
  153315. get isInImprovementMode(): boolean;
  153316. /**
  153317. * Gets the current priority level (0 at start)
  153318. */
  153319. get currentPriorityLevel(): number;
  153320. /**
  153321. * Gets the current frame rate checked by the SceneOptimizer
  153322. */
  153323. get currentFrameRate(): number;
  153324. /**
  153325. * Gets or sets the current target frame rate (60 by default)
  153326. */
  153327. get targetFrameRate(): number;
  153328. /**
  153329. * Gets or sets the current target frame rate (60 by default)
  153330. */
  153331. set targetFrameRate(value: number);
  153332. /**
  153333. * Gets or sets the current interval between two checks (every 2000ms by default)
  153334. */
  153335. get trackerDuration(): number;
  153336. /**
  153337. * Gets or sets the current interval between two checks (every 2000ms by default)
  153338. */
  153339. set trackerDuration(value: number);
  153340. /**
  153341. * Gets the list of active optimizations
  153342. */
  153343. get optimizations(): SceneOptimization[];
  153344. /**
  153345. * Creates a new SceneOptimizer
  153346. * @param scene defines the scene to work on
  153347. * @param options defines the options to use with the SceneOptimizer
  153348. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  153349. * @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)
  153350. */
  153351. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  153352. /**
  153353. * Stops the current optimizer
  153354. */
  153355. stop(): void;
  153356. /**
  153357. * Reset the optimizer to initial step (current priority level = 0)
  153358. */
  153359. reset(): void;
  153360. /**
  153361. * Start the optimizer. By default it will try to reach a specific framerate
  153362. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  153363. */
  153364. start(): void;
  153365. private _checkCurrentState;
  153366. /**
  153367. * Release all resources
  153368. */
  153369. dispose(): void;
  153370. /**
  153371. * Helper function to create a SceneOptimizer with one single line of code
  153372. * @param scene defines the scene to work on
  153373. * @param options defines the options to use with the SceneOptimizer
  153374. * @param onSuccess defines a callback to call on success
  153375. * @param onFailure defines a callback to call on failure
  153376. * @returns the new SceneOptimizer object
  153377. */
  153378. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  153379. }
  153380. }
  153381. declare module BABYLON {
  153382. /**
  153383. * Class used to serialize a scene into a string
  153384. */
  153385. export class SceneSerializer {
  153386. /**
  153387. * Clear cache used by a previous serialization
  153388. */
  153389. static ClearCache(): void;
  153390. /**
  153391. * Serialize a scene into a JSON compatible object
  153392. * @param scene defines the scene to serialize
  153393. * @returns a JSON compatible object
  153394. */
  153395. static Serialize(scene: Scene): any;
  153396. /**
  153397. * Serialize a mesh into a JSON compatible object
  153398. * @param toSerialize defines the mesh to serialize
  153399. * @param withParents defines if parents must be serialized as well
  153400. * @param withChildren defines if children must be serialized as well
  153401. * @returns a JSON compatible object
  153402. */
  153403. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  153404. }
  153405. }
  153406. declare module BABYLON {
  153407. /**
  153408. * Class used to host texture specific utilities
  153409. */
  153410. export class TextureTools {
  153411. /**
  153412. * Uses the GPU to create a copy texture rescaled at a given size
  153413. * @param texture Texture to copy from
  153414. * @param width defines the desired width
  153415. * @param height defines the desired height
  153416. * @param useBilinearMode defines if bilinear mode has to be used
  153417. * @return the generated texture
  153418. */
  153419. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  153420. }
  153421. }
  153422. declare module BABYLON {
  153423. /**
  153424. * This represents the different options available for the video capture.
  153425. */
  153426. export interface VideoRecorderOptions {
  153427. /** Defines the mime type of the video. */
  153428. mimeType: string;
  153429. /** Defines the FPS the video should be recorded at. */
  153430. fps: number;
  153431. /** Defines the chunk size for the recording data. */
  153432. recordChunckSize: number;
  153433. /** The audio tracks to attach to the recording. */
  153434. audioTracks?: MediaStreamTrack[];
  153435. }
  153436. /**
  153437. * This can help with recording videos from BabylonJS.
  153438. * This is based on the available WebRTC functionalities of the browser.
  153439. *
  153440. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  153441. */
  153442. export class VideoRecorder {
  153443. private static readonly _defaultOptions;
  153444. /**
  153445. * Returns whether or not the VideoRecorder is available in your browser.
  153446. * @param engine Defines the Babylon Engine.
  153447. * @returns true if supported otherwise false.
  153448. */
  153449. static IsSupported(engine: Engine): boolean;
  153450. private readonly _options;
  153451. private _canvas;
  153452. private _mediaRecorder;
  153453. private _recordedChunks;
  153454. private _fileName;
  153455. private _resolve;
  153456. private _reject;
  153457. /**
  153458. * True when a recording is already in progress.
  153459. */
  153460. get isRecording(): boolean;
  153461. /**
  153462. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  153463. * @param engine Defines the BabylonJS Engine you wish to record.
  153464. * @param options Defines options that can be used to customize the capture.
  153465. */
  153466. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  153467. /**
  153468. * Stops the current recording before the default capture timeout passed in the startRecording function.
  153469. */
  153470. stopRecording(): void;
  153471. /**
  153472. * Starts recording the canvas for a max duration specified in parameters.
  153473. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  153474. * If null no automatic download will start and you can rely on the promise to get the data back.
  153475. * @param maxDuration Defines the maximum recording time in seconds.
  153476. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  153477. * @return A promise callback at the end of the recording with the video data in Blob.
  153478. */
  153479. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  153480. /**
  153481. * Releases internal resources used during the recording.
  153482. */
  153483. dispose(): void;
  153484. private _handleDataAvailable;
  153485. private _handleError;
  153486. private _handleStop;
  153487. }
  153488. }
  153489. declare module BABYLON {
  153490. /**
  153491. * Class containing a set of static utilities functions for screenshots
  153492. */
  153493. export class ScreenshotTools {
  153494. /**
  153495. * Captures a screenshot of the current rendering
  153496. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153497. * @param engine defines the rendering engine
  153498. * @param camera defines the source camera
  153499. * @param size This parameter can be set to a single number or to an object with the
  153500. * following (optional) properties: precision, width, height. If a single number is passed,
  153501. * it will be used for both width and height. If an object is passed, the screenshot size
  153502. * will be derived from the parameters. The precision property is a multiplier allowing
  153503. * rendering at a higher or lower resolution
  153504. * @param successCallback defines the callback receives a single parameter which contains the
  153505. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  153506. * src parameter of an <img> to display it
  153507. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  153508. * Check your browser for supported MIME types
  153509. */
  153510. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  153511. /**
  153512. * Captures a screenshot of the current rendering
  153513. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153514. * @param engine defines the rendering engine
  153515. * @param camera defines the source camera
  153516. * @param size This parameter can be set to a single number or to an object with the
  153517. * following (optional) properties: precision, width, height. If a single number is passed,
  153518. * it will be used for both width and height. If an object is passed, the screenshot size
  153519. * will be derived from the parameters. The precision property is a multiplier allowing
  153520. * rendering at a higher or lower resolution
  153521. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  153522. * Check your browser for supported MIME types
  153523. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  153524. * to the src parameter of an <img> to display it
  153525. */
  153526. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  153527. /**
  153528. * Generates an image screenshot from the specified camera.
  153529. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153530. * @param engine The engine to use for rendering
  153531. * @param camera The camera to use for rendering
  153532. * @param size This parameter can be set to a single number or to an object with the
  153533. * following (optional) properties: precision, width, height. If a single number is passed,
  153534. * it will be used for both width and height. If an object is passed, the screenshot size
  153535. * will be derived from the parameters. The precision property is a multiplier allowing
  153536. * rendering at a higher or lower resolution
  153537. * @param successCallback The callback receives a single parameter which contains the
  153538. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  153539. * src parameter of an <img> to display it
  153540. * @param mimeType The MIME type of the screenshot image (default: image/png).
  153541. * Check your browser for supported MIME types
  153542. * @param samples Texture samples (default: 1)
  153543. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  153544. * @param fileName A name for for the downloaded file.
  153545. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  153546. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  153547. */
  153548. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  153549. /**
  153550. * Generates an image screenshot from the specified camera.
  153551. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153552. * @param engine The engine to use for rendering
  153553. * @param camera The camera to use for rendering
  153554. * @param size This parameter can be set to a single number or to an object with the
  153555. * following (optional) properties: precision, width, height. If a single number is passed,
  153556. * it will be used for both width and height. If an object is passed, the screenshot size
  153557. * will be derived from the parameters. The precision property is a multiplier allowing
  153558. * rendering at a higher or lower resolution
  153559. * @param mimeType The MIME type of the screenshot image (default: image/png).
  153560. * Check your browser for supported MIME types
  153561. * @param samples Texture samples (default: 1)
  153562. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  153563. * @param fileName A name for for the downloaded file.
  153564. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  153565. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  153566. * to the src parameter of an <img> to display it
  153567. */
  153568. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  153569. /**
  153570. * Gets height and width for screenshot size
  153571. * @private
  153572. */
  153573. private static _getScreenshotSize;
  153574. }
  153575. }
  153576. declare module BABYLON {
  153577. /**
  153578. * Interface for a data buffer
  153579. */
  153580. export interface IDataBuffer {
  153581. /**
  153582. * Reads bytes from the data buffer.
  153583. * @param byteOffset The byte offset to read
  153584. * @param byteLength The byte length to read
  153585. * @returns A promise that resolves when the bytes are read
  153586. */
  153587. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  153588. /**
  153589. * The byte length of the buffer.
  153590. */
  153591. readonly byteLength: number;
  153592. }
  153593. /**
  153594. * Utility class for reading from a data buffer
  153595. */
  153596. export class DataReader {
  153597. /**
  153598. * The data buffer associated with this data reader.
  153599. */
  153600. readonly buffer: IDataBuffer;
  153601. /**
  153602. * The current byte offset from the beginning of the data buffer.
  153603. */
  153604. byteOffset: number;
  153605. private _dataView;
  153606. private _dataByteOffset;
  153607. /**
  153608. * Constructor
  153609. * @param buffer The buffer to read
  153610. */
  153611. constructor(buffer: IDataBuffer);
  153612. /**
  153613. * Loads the given byte length.
  153614. * @param byteLength The byte length to load
  153615. * @returns A promise that resolves when the load is complete
  153616. */
  153617. loadAsync(byteLength: number): Promise<void>;
  153618. /**
  153619. * Read a unsigned 32-bit integer from the currently loaded data range.
  153620. * @returns The 32-bit integer read
  153621. */
  153622. readUint32(): number;
  153623. /**
  153624. * Read a byte array from the currently loaded data range.
  153625. * @param byteLength The byte length to read
  153626. * @returns The byte array read
  153627. */
  153628. readUint8Array(byteLength: number): Uint8Array;
  153629. /**
  153630. * Read a string from the currently loaded data range.
  153631. * @param byteLength The byte length to read
  153632. * @returns The string read
  153633. */
  153634. readString(byteLength: number): string;
  153635. /**
  153636. * Skips the given byte length the currently loaded data range.
  153637. * @param byteLength The byte length to skip
  153638. */
  153639. skipBytes(byteLength: number): void;
  153640. }
  153641. }
  153642. declare module BABYLON {
  153643. /**
  153644. * Class for storing data to local storage if available or in-memory storage otherwise
  153645. */
  153646. export class DataStorage {
  153647. private static _Storage;
  153648. private static _GetStorage;
  153649. /**
  153650. * Reads a string from the data storage
  153651. * @param key The key to read
  153652. * @param defaultValue The value if the key doesn't exist
  153653. * @returns The string value
  153654. */
  153655. static ReadString(key: string, defaultValue: string): string;
  153656. /**
  153657. * Writes a string to the data storage
  153658. * @param key The key to write
  153659. * @param value The value to write
  153660. */
  153661. static WriteString(key: string, value: string): void;
  153662. /**
  153663. * Reads a boolean from the data storage
  153664. * @param key The key to read
  153665. * @param defaultValue The value if the key doesn't exist
  153666. * @returns The boolean value
  153667. */
  153668. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  153669. /**
  153670. * Writes a boolean to the data storage
  153671. * @param key The key to write
  153672. * @param value The value to write
  153673. */
  153674. static WriteBoolean(key: string, value: boolean): void;
  153675. /**
  153676. * Reads a number from the data storage
  153677. * @param key The key to read
  153678. * @param defaultValue The value if the key doesn't exist
  153679. * @returns The number value
  153680. */
  153681. static ReadNumber(key: string, defaultValue: number): number;
  153682. /**
  153683. * Writes a number to the data storage
  153684. * @param key The key to write
  153685. * @param value The value to write
  153686. */
  153687. static WriteNumber(key: string, value: number): void;
  153688. }
  153689. }
  153690. declare module BABYLON {
  153691. /**
  153692. * Class used to record delta files between 2 scene states
  153693. */
  153694. export class SceneRecorder {
  153695. private _trackedScene;
  153696. private _savedJSON;
  153697. /**
  153698. * Track a given scene. This means the current scene state will be considered the original state
  153699. * @param scene defines the scene to track
  153700. */
  153701. track(scene: Scene): void;
  153702. /**
  153703. * Get the delta between current state and original state
  153704. * @returns a string containing the delta
  153705. */
  153706. getDelta(): any;
  153707. private _compareArray;
  153708. private _compareObjects;
  153709. private _compareCollections;
  153710. private static GetShadowGeneratorById;
  153711. /**
  153712. * Apply a given delta to a given scene
  153713. * @param deltaJSON defines the JSON containing the delta
  153714. * @param scene defines the scene to apply the delta to
  153715. */
  153716. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  153717. private static _ApplyPropertiesToEntity;
  153718. private static _ApplyDeltaForEntity;
  153719. }
  153720. }
  153721. declare module BABYLON {
  153722. /**
  153723. * An interface for all Hit test features
  153724. */
  153725. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  153726. /**
  153727. * Triggered when new babylon (transformed) hit test results are available
  153728. */
  153729. onHitTestResultObservable: Observable<T[]>;
  153730. }
  153731. /**
  153732. * Options used for hit testing
  153733. */
  153734. export interface IWebXRLegacyHitTestOptions {
  153735. /**
  153736. * Only test when user interacted with the scene. Default - hit test every frame
  153737. */
  153738. testOnPointerDownOnly?: boolean;
  153739. /**
  153740. * The node to use to transform the local results to world coordinates
  153741. */
  153742. worldParentNode?: TransformNode;
  153743. }
  153744. /**
  153745. * Interface defining the babylon result of raycasting/hit-test
  153746. */
  153747. export interface IWebXRLegacyHitResult {
  153748. /**
  153749. * Transformation matrix that can be applied to a node that will put it in the hit point location
  153750. */
  153751. transformationMatrix: Matrix;
  153752. /**
  153753. * The native hit test result
  153754. */
  153755. xrHitResult: XRHitResult | XRHitTestResult;
  153756. }
  153757. /**
  153758. * The currently-working hit-test module.
  153759. * Hit test (or Ray-casting) is used to interact with the real world.
  153760. * For further information read here - https://github.com/immersive-web/hit-test
  153761. */
  153762. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  153763. /**
  153764. * options to use when constructing this feature
  153765. */
  153766. readonly options: IWebXRLegacyHitTestOptions;
  153767. private _direction;
  153768. private _mat;
  153769. private _onSelectEnabled;
  153770. private _origin;
  153771. /**
  153772. * The module's name
  153773. */
  153774. static readonly Name: string;
  153775. /**
  153776. * The (Babylon) version of this module.
  153777. * This is an integer representing the implementation version.
  153778. * This number does not correspond to the WebXR specs version
  153779. */
  153780. static readonly Version: number;
  153781. /**
  153782. * Populated with the last native XR Hit Results
  153783. */
  153784. lastNativeXRHitResults: XRHitResult[];
  153785. /**
  153786. * Triggered when new babylon (transformed) hit test results are available
  153787. */
  153788. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  153789. /**
  153790. * Creates a new instance of the (legacy version) hit test feature
  153791. * @param _xrSessionManager an instance of WebXRSessionManager
  153792. * @param options options to use when constructing this feature
  153793. */
  153794. constructor(_xrSessionManager: WebXRSessionManager,
  153795. /**
  153796. * options to use when constructing this feature
  153797. */
  153798. options?: IWebXRLegacyHitTestOptions);
  153799. /**
  153800. * execute a hit test with an XR Ray
  153801. *
  153802. * @param xrSession a native xrSession that will execute this hit test
  153803. * @param xrRay the ray (position and direction) to use for ray-casting
  153804. * @param referenceSpace native XR reference space to use for the hit-test
  153805. * @param filter filter function that will filter the results
  153806. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  153807. */
  153808. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  153809. /**
  153810. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  153811. * @param event the (select) event to use to select with
  153812. * @param referenceSpace the reference space to use for this hit test
  153813. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  153814. */
  153815. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  153816. /**
  153817. * attach this feature
  153818. * Will usually be called by the features manager
  153819. *
  153820. * @returns true if successful.
  153821. */
  153822. attach(): boolean;
  153823. /**
  153824. * detach this feature.
  153825. * Will usually be called by the features manager
  153826. *
  153827. * @returns true if successful.
  153828. */
  153829. detach(): boolean;
  153830. /**
  153831. * Dispose this feature and all of the resources attached
  153832. */
  153833. dispose(): void;
  153834. protected _onXRFrame(frame: XRFrame): void;
  153835. private _onHitTestResults;
  153836. private _onSelect;
  153837. }
  153838. }
  153839. declare module BABYLON {
  153840. /**
  153841. * Options used for hit testing (version 2)
  153842. */
  153843. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  153844. /**
  153845. * Do not create a permanent hit test. Will usually be used when only
  153846. * transient inputs are needed.
  153847. */
  153848. disablePermanentHitTest?: boolean;
  153849. /**
  153850. * Enable transient (for example touch-based) hit test inspections
  153851. */
  153852. enableTransientHitTest?: boolean;
  153853. /**
  153854. * Offset ray for the permanent hit test
  153855. */
  153856. offsetRay?: Vector3;
  153857. /**
  153858. * Offset ray for the transient hit test
  153859. */
  153860. transientOffsetRay?: Vector3;
  153861. /**
  153862. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  153863. */
  153864. useReferenceSpace?: boolean;
  153865. /**
  153866. * Override the default entity type(s) of the hit-test result
  153867. */
  153868. entityTypes?: XRHitTestTrackableType[];
  153869. }
  153870. /**
  153871. * Interface defining the babylon result of hit-test
  153872. */
  153873. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  153874. /**
  153875. * The input source that generated this hit test (if transient)
  153876. */
  153877. inputSource?: XRInputSource;
  153878. /**
  153879. * Is this a transient hit test
  153880. */
  153881. isTransient?: boolean;
  153882. /**
  153883. * Position of the hit test result
  153884. */
  153885. position: Vector3;
  153886. /**
  153887. * Rotation of the hit test result
  153888. */
  153889. rotationQuaternion: Quaternion;
  153890. /**
  153891. * The native hit test result
  153892. */
  153893. xrHitResult: XRHitTestResult;
  153894. }
  153895. /**
  153896. * The currently-working hit-test module.
  153897. * Hit test (or Ray-casting) is used to interact with the real world.
  153898. * For further information read here - https://github.com/immersive-web/hit-test
  153899. *
  153900. * Tested on chrome (mobile) 80.
  153901. */
  153902. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  153903. /**
  153904. * options to use when constructing this feature
  153905. */
  153906. readonly options: IWebXRHitTestOptions;
  153907. private _tmpMat;
  153908. private _tmpPos;
  153909. private _tmpQuat;
  153910. private _transientXrHitTestSource;
  153911. private _xrHitTestSource;
  153912. private initHitTestSource;
  153913. /**
  153914. * The module's name
  153915. */
  153916. static readonly Name: string;
  153917. /**
  153918. * The (Babylon) version of this module.
  153919. * This is an integer representing the implementation version.
  153920. * This number does not correspond to the WebXR specs version
  153921. */
  153922. static readonly Version: number;
  153923. /**
  153924. * When set to true, each hit test will have its own position/rotation objects
  153925. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  153926. * the developers will clone them or copy them as they see fit.
  153927. */
  153928. autoCloneTransformation: boolean;
  153929. /**
  153930. * Triggered when new babylon (transformed) hit test results are available
  153931. */
  153932. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  153933. /**
  153934. * Use this to temporarily pause hit test checks.
  153935. */
  153936. paused: boolean;
  153937. /**
  153938. * Creates a new instance of the hit test feature
  153939. * @param _xrSessionManager an instance of WebXRSessionManager
  153940. * @param options options to use when constructing this feature
  153941. */
  153942. constructor(_xrSessionManager: WebXRSessionManager,
  153943. /**
  153944. * options to use when constructing this feature
  153945. */
  153946. options?: IWebXRHitTestOptions);
  153947. /**
  153948. * attach this feature
  153949. * Will usually be called by the features manager
  153950. *
  153951. * @returns true if successful.
  153952. */
  153953. attach(): boolean;
  153954. /**
  153955. * detach this feature.
  153956. * Will usually be called by the features manager
  153957. *
  153958. * @returns true if successful.
  153959. */
  153960. detach(): boolean;
  153961. /**
  153962. * Dispose this feature and all of the resources attached
  153963. */
  153964. dispose(): void;
  153965. protected _onXRFrame(frame: XRFrame): void;
  153966. private _processWebXRHitTestResult;
  153967. }
  153968. }
  153969. declare module BABYLON {
  153970. /**
  153971. * Configuration options of the anchor system
  153972. */
  153973. export interface IWebXRAnchorSystemOptions {
  153974. /**
  153975. * a node that will be used to convert local to world coordinates
  153976. */
  153977. worldParentNode?: TransformNode;
  153978. /**
  153979. * If set to true a reference of the created anchors will be kept until the next session starts
  153980. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  153981. */
  153982. doNotRemoveAnchorsOnSessionEnded?: boolean;
  153983. }
  153984. /**
  153985. * A babylon container for an XR Anchor
  153986. */
  153987. export interface IWebXRAnchor {
  153988. /**
  153989. * A babylon-assigned ID for this anchor
  153990. */
  153991. id: number;
  153992. /**
  153993. * Transformation matrix to apply to an object attached to this anchor
  153994. */
  153995. transformationMatrix: Matrix;
  153996. /**
  153997. * The native anchor object
  153998. */
  153999. xrAnchor: XRAnchor;
  154000. /**
  154001. * if defined, this object will be constantly updated by the anchor's position and rotation
  154002. */
  154003. attachedNode?: TransformNode;
  154004. }
  154005. /**
  154006. * An implementation of the anchor system for WebXR.
  154007. * For further information see https://github.com/immersive-web/anchors/
  154008. */
  154009. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  154010. private _options;
  154011. private _lastFrameDetected;
  154012. private _trackedAnchors;
  154013. private _referenceSpaceForFrameAnchors;
  154014. private _futureAnchors;
  154015. /**
  154016. * The module's name
  154017. */
  154018. static readonly Name: string;
  154019. /**
  154020. * The (Babylon) version of this module.
  154021. * This is an integer representing the implementation version.
  154022. * This number does not correspond to the WebXR specs version
  154023. */
  154024. static readonly Version: number;
  154025. /**
  154026. * Observers registered here will be executed when a new anchor was added to the session
  154027. */
  154028. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  154029. /**
  154030. * Observers registered here will be executed when an anchor was removed from the session
  154031. */
  154032. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  154033. /**
  154034. * Observers registered here will be executed when an existing anchor updates
  154035. * This can execute N times every frame
  154036. */
  154037. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  154038. /**
  154039. * Set the reference space to use for anchor creation, when not using a hit test.
  154040. * Will default to the session's reference space if not defined
  154041. */
  154042. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  154043. /**
  154044. * constructs a new anchor system
  154045. * @param _xrSessionManager an instance of WebXRSessionManager
  154046. * @param _options configuration object for this feature
  154047. */
  154048. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  154049. private _tmpVector;
  154050. private _tmpQuaternion;
  154051. private _populateTmpTransformation;
  154052. /**
  154053. * Create a new anchor point using a hit test result at a specific point in the scene
  154054. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  154055. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  154056. *
  154057. * @param hitTestResult The hit test result to use for this anchor creation
  154058. * @param position an optional position offset for this anchor
  154059. * @param rotationQuaternion an optional rotation offset for this anchor
  154060. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  154061. */
  154062. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  154063. /**
  154064. * Add a new anchor at a specific position and rotation
  154065. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  154066. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  154067. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  154068. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  154069. *
  154070. * @param position the position in which to add an anchor
  154071. * @param rotationQuaternion an optional rotation for the anchor transformation
  154072. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  154073. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  154074. */
  154075. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  154076. /**
  154077. * detach this feature.
  154078. * Will usually be called by the features manager
  154079. *
  154080. * @returns true if successful.
  154081. */
  154082. detach(): boolean;
  154083. /**
  154084. * Dispose this feature and all of the resources attached
  154085. */
  154086. dispose(): void;
  154087. protected _onXRFrame(frame: XRFrame): void;
  154088. /**
  154089. * avoiding using Array.find for global support.
  154090. * @param xrAnchor the plane to find in the array
  154091. */
  154092. private _findIndexInAnchorArray;
  154093. private _updateAnchorWithXRFrame;
  154094. private _createAnchorAtTransformation;
  154095. }
  154096. }
  154097. declare module BABYLON {
  154098. /**
  154099. * Options used in the plane detector module
  154100. */
  154101. export interface IWebXRPlaneDetectorOptions {
  154102. /**
  154103. * The node to use to transform the local results to world coordinates
  154104. */
  154105. worldParentNode?: TransformNode;
  154106. /**
  154107. * If set to true a reference of the created planes will be kept until the next session starts
  154108. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  154109. */
  154110. doNotRemovePlanesOnSessionEnded?: boolean;
  154111. }
  154112. /**
  154113. * A babylon interface for a WebXR plane.
  154114. * A Plane is actually a polygon, built from N points in space
  154115. *
  154116. * Supported in chrome 79, not supported in canary 81 ATM
  154117. */
  154118. export interface IWebXRPlane {
  154119. /**
  154120. * a babylon-assigned ID for this polygon
  154121. */
  154122. id: number;
  154123. /**
  154124. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  154125. */
  154126. polygonDefinition: Array<Vector3>;
  154127. /**
  154128. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  154129. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  154130. */
  154131. transformationMatrix: Matrix;
  154132. /**
  154133. * the native xr-plane object
  154134. */
  154135. xrPlane: XRPlane;
  154136. }
  154137. /**
  154138. * The plane detector is used to detect planes in the real world when in AR
  154139. * For more information see https://github.com/immersive-web/real-world-geometry/
  154140. */
  154141. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  154142. private _options;
  154143. private _detectedPlanes;
  154144. private _enabled;
  154145. private _lastFrameDetected;
  154146. /**
  154147. * The module's name
  154148. */
  154149. static readonly Name: string;
  154150. /**
  154151. * The (Babylon) version of this module.
  154152. * This is an integer representing the implementation version.
  154153. * This number does not correspond to the WebXR specs version
  154154. */
  154155. static readonly Version: number;
  154156. /**
  154157. * Observers registered here will be executed when a new plane was added to the session
  154158. */
  154159. onPlaneAddedObservable: Observable<IWebXRPlane>;
  154160. /**
  154161. * Observers registered here will be executed when a plane is no longer detected in the session
  154162. */
  154163. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  154164. /**
  154165. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  154166. * This can execute N times every frame
  154167. */
  154168. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  154169. /**
  154170. * construct a new Plane Detector
  154171. * @param _xrSessionManager an instance of xr Session manager
  154172. * @param _options configuration to use when constructing this feature
  154173. */
  154174. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  154175. /**
  154176. * detach this feature.
  154177. * Will usually be called by the features manager
  154178. *
  154179. * @returns true if successful.
  154180. */
  154181. detach(): boolean;
  154182. /**
  154183. * Dispose this feature and all of the resources attached
  154184. */
  154185. dispose(): void;
  154186. protected _onXRFrame(frame: XRFrame): void;
  154187. private _init;
  154188. private _updatePlaneWithXRPlane;
  154189. /**
  154190. * avoiding using Array.find for global support.
  154191. * @param xrPlane the plane to find in the array
  154192. */
  154193. private findIndexInPlaneArray;
  154194. }
  154195. }
  154196. declare module BABYLON {
  154197. /**
  154198. * Options interface for the background remover plugin
  154199. */
  154200. export interface IWebXRBackgroundRemoverOptions {
  154201. /**
  154202. * Further background meshes to disable when entering AR
  154203. */
  154204. backgroundMeshes?: AbstractMesh[];
  154205. /**
  154206. * flags to configure the removal of the environment helper.
  154207. * If not set, the entire background will be removed. If set, flags should be set as well.
  154208. */
  154209. environmentHelperRemovalFlags?: {
  154210. /**
  154211. * Should the skybox be removed (default false)
  154212. */
  154213. skyBox?: boolean;
  154214. /**
  154215. * Should the ground be removed (default false)
  154216. */
  154217. ground?: boolean;
  154218. };
  154219. /**
  154220. * don't disable the environment helper
  154221. */
  154222. ignoreEnvironmentHelper?: boolean;
  154223. }
  154224. /**
  154225. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  154226. */
  154227. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  154228. /**
  154229. * read-only options to be used in this module
  154230. */
  154231. readonly options: IWebXRBackgroundRemoverOptions;
  154232. /**
  154233. * The module's name
  154234. */
  154235. static readonly Name: string;
  154236. /**
  154237. * The (Babylon) version of this module.
  154238. * This is an integer representing the implementation version.
  154239. * This number does not correspond to the WebXR specs version
  154240. */
  154241. static readonly Version: number;
  154242. /**
  154243. * registered observers will be triggered when the background state changes
  154244. */
  154245. onBackgroundStateChangedObservable: Observable<boolean>;
  154246. /**
  154247. * constructs a new background remover module
  154248. * @param _xrSessionManager the session manager for this module
  154249. * @param options read-only options to be used in this module
  154250. */
  154251. constructor(_xrSessionManager: WebXRSessionManager,
  154252. /**
  154253. * read-only options to be used in this module
  154254. */
  154255. options?: IWebXRBackgroundRemoverOptions);
  154256. /**
  154257. * attach this feature
  154258. * Will usually be called by the features manager
  154259. *
  154260. * @returns true if successful.
  154261. */
  154262. attach(): boolean;
  154263. /**
  154264. * detach this feature.
  154265. * Will usually be called by the features manager
  154266. *
  154267. * @returns true if successful.
  154268. */
  154269. detach(): boolean;
  154270. /**
  154271. * Dispose this feature and all of the resources attached
  154272. */
  154273. dispose(): void;
  154274. protected _onXRFrame(_xrFrame: XRFrame): void;
  154275. private _setBackgroundState;
  154276. }
  154277. }
  154278. declare module BABYLON {
  154279. /**
  154280. * Options for the controller physics feature
  154281. */
  154282. export class IWebXRControllerPhysicsOptions {
  154283. /**
  154284. * Should the headset get its own impostor
  154285. */
  154286. enableHeadsetImpostor?: boolean;
  154287. /**
  154288. * Optional parameters for the headset impostor
  154289. */
  154290. headsetImpostorParams?: {
  154291. /**
  154292. * The type of impostor to create. Default is sphere
  154293. */
  154294. impostorType: number;
  154295. /**
  154296. * the size of the impostor. Defaults to 10cm
  154297. */
  154298. impostorSize?: number | {
  154299. width: number;
  154300. height: number;
  154301. depth: number;
  154302. };
  154303. /**
  154304. * Friction definitions
  154305. */
  154306. friction?: number;
  154307. /**
  154308. * Restitution
  154309. */
  154310. restitution?: number;
  154311. };
  154312. /**
  154313. * The physics properties of the future impostors
  154314. */
  154315. physicsProperties?: {
  154316. /**
  154317. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  154318. * Note that this requires a physics engine that supports mesh impostors!
  154319. */
  154320. useControllerMesh?: boolean;
  154321. /**
  154322. * The type of impostor to create. Default is sphere
  154323. */
  154324. impostorType?: number;
  154325. /**
  154326. * the size of the impostor. Defaults to 10cm
  154327. */
  154328. impostorSize?: number | {
  154329. width: number;
  154330. height: number;
  154331. depth: number;
  154332. };
  154333. /**
  154334. * Friction definitions
  154335. */
  154336. friction?: number;
  154337. /**
  154338. * Restitution
  154339. */
  154340. restitution?: number;
  154341. };
  154342. /**
  154343. * the xr input to use with this pointer selection
  154344. */
  154345. xrInput: WebXRInput;
  154346. }
  154347. /**
  154348. * Add physics impostor to your webxr controllers,
  154349. * including naive calculation of their linear and angular velocity
  154350. */
  154351. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  154352. private readonly _options;
  154353. private _attachController;
  154354. private _controllers;
  154355. private _debugMode;
  154356. private _delta;
  154357. private _headsetImpostor?;
  154358. private _headsetMesh?;
  154359. private _lastTimestamp;
  154360. private _tmpQuaternion;
  154361. private _tmpVector;
  154362. /**
  154363. * The module's name
  154364. */
  154365. static readonly Name: string;
  154366. /**
  154367. * The (Babylon) version of this module.
  154368. * This is an integer representing the implementation version.
  154369. * This number does not correspond to the webxr specs version
  154370. */
  154371. static readonly Version: number;
  154372. /**
  154373. * Construct a new Controller Physics Feature
  154374. * @param _xrSessionManager the corresponding xr session manager
  154375. * @param _options options to create this feature with
  154376. */
  154377. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  154378. /**
  154379. * @hidden
  154380. * enable debugging - will show console outputs and the impostor mesh
  154381. */
  154382. _enablePhysicsDebug(): void;
  154383. /**
  154384. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  154385. * @param xrController the controller to add
  154386. */
  154387. addController(xrController: WebXRInputSource): void;
  154388. /**
  154389. * attach this feature
  154390. * Will usually be called by the features manager
  154391. *
  154392. * @returns true if successful.
  154393. */
  154394. attach(): boolean;
  154395. /**
  154396. * detach this feature.
  154397. * Will usually be called by the features manager
  154398. *
  154399. * @returns true if successful.
  154400. */
  154401. detach(): boolean;
  154402. /**
  154403. * Get the headset impostor, if enabled
  154404. * @returns the impostor
  154405. */
  154406. getHeadsetImpostor(): PhysicsImpostor | undefined;
  154407. /**
  154408. * Get the physics impostor of a specific controller.
  154409. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  154410. * @param controller the controller or the controller id of which to get the impostor
  154411. * @returns the impostor or null
  154412. */
  154413. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  154414. /**
  154415. * Update the physics properties provided in the constructor
  154416. * @param newProperties the new properties object
  154417. */
  154418. setPhysicsProperties(newProperties: {
  154419. impostorType?: number;
  154420. impostorSize?: number | {
  154421. width: number;
  154422. height: number;
  154423. depth: number;
  154424. };
  154425. friction?: number;
  154426. restitution?: number;
  154427. }): void;
  154428. protected _onXRFrame(_xrFrame: any): void;
  154429. private _detachController;
  154430. }
  154431. }
  154432. declare module BABYLON {
  154433. /**
  154434. * A babylon interface for a "WebXR" feature point.
  154435. * Represents the position and confidence value of a given feature point.
  154436. */
  154437. export interface IWebXRFeaturePoint {
  154438. /**
  154439. * Represents the position of the feature point in world space.
  154440. */
  154441. position: Vector3;
  154442. /**
  154443. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  154444. */
  154445. confidenceValue: number;
  154446. }
  154447. /**
  154448. * The feature point system is used to detect feature points from real world geometry.
  154449. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  154450. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  154451. */
  154452. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  154453. private _enabled;
  154454. private _featurePointCloud;
  154455. /**
  154456. * The module's name
  154457. */
  154458. static readonly Name: string;
  154459. /**
  154460. * The (Babylon) version of this module.
  154461. * This is an integer representing the implementation version.
  154462. * This number does not correspond to the WebXR specs version
  154463. */
  154464. static readonly Version: number;
  154465. /**
  154466. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  154467. * Will notify the observers about which feature points have been added.
  154468. */
  154469. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  154470. /**
  154471. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  154472. * Will notify the observers about which feature points have been updated.
  154473. */
  154474. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  154475. /**
  154476. * The current feature point cloud maintained across frames.
  154477. */
  154478. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  154479. /**
  154480. * construct the feature point system
  154481. * @param _xrSessionManager an instance of xr Session manager
  154482. */
  154483. constructor(_xrSessionManager: WebXRSessionManager);
  154484. /**
  154485. * Detach this feature.
  154486. * Will usually be called by the features manager
  154487. *
  154488. * @returns true if successful.
  154489. */
  154490. detach(): boolean;
  154491. /**
  154492. * Dispose this feature and all of the resources attached
  154493. */
  154494. dispose(): void;
  154495. /**
  154496. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  154497. */
  154498. protected _onXRFrame(frame: XRFrame): void;
  154499. /**
  154500. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  154501. */
  154502. private _init;
  154503. }
  154504. }
  154505. declare module BABYLON {
  154506. /**
  154507. * Configuration interface for the hand tracking feature
  154508. */
  154509. export interface IWebXRHandTrackingOptions {
  154510. /**
  154511. * The xrInput that will be used as source for new hands
  154512. */
  154513. xrInput: WebXRInput;
  154514. /**
  154515. * Configuration object for the joint meshes
  154516. */
  154517. jointMeshes?: {
  154518. /**
  154519. * Should the meshes created be invisible (defaults to false)
  154520. */
  154521. invisible?: boolean;
  154522. /**
  154523. * A source mesh to be used to create instances. Defaults to a sphere.
  154524. * This mesh will be the source for all other (25) meshes.
  154525. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  154526. */
  154527. sourceMesh?: Mesh;
  154528. /**
  154529. * Should the source mesh stay visible. Defaults to false
  154530. */
  154531. keepOriginalVisible?: boolean;
  154532. /**
  154533. * Scale factor for all instances (defaults to 2)
  154534. */
  154535. scaleFactor?: number;
  154536. /**
  154537. * Should each instance have its own physics impostor
  154538. */
  154539. enablePhysics?: boolean;
  154540. /**
  154541. * If enabled, override default physics properties
  154542. */
  154543. physicsProps?: {
  154544. friction?: number;
  154545. restitution?: number;
  154546. impostorType?: number;
  154547. };
  154548. /**
  154549. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  154550. */
  154551. handMesh?: AbstractMesh;
  154552. };
  154553. }
  154554. /**
  154555. * Parts of the hands divided to writs and finger names
  154556. */
  154557. export const enum HandPart {
  154558. /**
  154559. * HandPart - Wrist
  154560. */
  154561. WRIST = "wrist",
  154562. /**
  154563. * HandPart - The THumb
  154564. */
  154565. THUMB = "thumb",
  154566. /**
  154567. * HandPart - Index finger
  154568. */
  154569. INDEX = "index",
  154570. /**
  154571. * HandPart - Middle finger
  154572. */
  154573. MIDDLE = "middle",
  154574. /**
  154575. * HandPart - Ring finger
  154576. */
  154577. RING = "ring",
  154578. /**
  154579. * HandPart - Little finger
  154580. */
  154581. LITTLE = "little"
  154582. }
  154583. /**
  154584. * Representing a single hand (with its corresponding native XRHand object)
  154585. */
  154586. export class WebXRHand implements IDisposable {
  154587. /** the controller to which the hand correlates */
  154588. readonly xrController: WebXRInputSource;
  154589. /** the meshes to be used to track the hand joints */
  154590. readonly trackedMeshes: AbstractMesh[];
  154591. /**
  154592. * Hand-parts definition (key is HandPart)
  154593. */
  154594. static HandPartsDefinition: {
  154595. [key: string]: number[];
  154596. };
  154597. /**
  154598. * Populate the HandPartsDefinition object.
  154599. * This is called as a side effect since certain browsers don't have XRHand defined.
  154600. */
  154601. static _PopulateHandPartsDefinition(): void;
  154602. /**
  154603. * Construct a new hand object
  154604. * @param xrController the controller to which the hand correlates
  154605. * @param trackedMeshes the meshes to be used to track the hand joints
  154606. */
  154607. constructor(
  154608. /** the controller to which the hand correlates */
  154609. xrController: WebXRInputSource,
  154610. /** the meshes to be used to track the hand joints */
  154611. trackedMeshes: AbstractMesh[]);
  154612. /**
  154613. * Update this hand from the latest xr frame
  154614. * @param xrFrame xrFrame to update from
  154615. * @param referenceSpace The current viewer reference space
  154616. * @param scaleFactor optional scale factor for the meshes
  154617. */
  154618. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  154619. /**
  154620. * Get meshes of part of the hand
  154621. * @param part the part of hand to get
  154622. * @returns An array of meshes that correlate to the hand part requested
  154623. */
  154624. getHandPartMeshes(part: HandPart): AbstractMesh[];
  154625. /**
  154626. * Dispose this Hand object
  154627. */
  154628. dispose(): void;
  154629. }
  154630. /**
  154631. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  154632. */
  154633. export class WebXRHandTracking extends WebXRAbstractFeature {
  154634. /**
  154635. * options to use when constructing this feature
  154636. */
  154637. readonly options: IWebXRHandTrackingOptions;
  154638. private static _idCounter;
  154639. /**
  154640. * The module's name
  154641. */
  154642. static readonly Name: string;
  154643. /**
  154644. * The (Babylon) version of this module.
  154645. * This is an integer representing the implementation version.
  154646. * This number does not correspond to the WebXR specs version
  154647. */
  154648. static readonly Version: number;
  154649. /**
  154650. * This observable will notify registered observers when a new hand object was added and initialized
  154651. */
  154652. onHandAddedObservable: Observable<WebXRHand>;
  154653. /**
  154654. * This observable will notify its observers right before the hand object is disposed
  154655. */
  154656. onHandRemovedObservable: Observable<WebXRHand>;
  154657. private _hands;
  154658. /**
  154659. * Creates a new instance of the hit test feature
  154660. * @param _xrSessionManager an instance of WebXRSessionManager
  154661. * @param options options to use when constructing this feature
  154662. */
  154663. constructor(_xrSessionManager: WebXRSessionManager,
  154664. /**
  154665. * options to use when constructing this feature
  154666. */
  154667. options: IWebXRHandTrackingOptions);
  154668. /**
  154669. * Check if the needed objects are defined.
  154670. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  154671. */
  154672. isCompatible(): boolean;
  154673. /**
  154674. * attach this feature
  154675. * Will usually be called by the features manager
  154676. *
  154677. * @returns true if successful.
  154678. */
  154679. attach(): boolean;
  154680. /**
  154681. * detach this feature.
  154682. * Will usually be called by the features manager
  154683. *
  154684. * @returns true if successful.
  154685. */
  154686. detach(): boolean;
  154687. /**
  154688. * Dispose this feature and all of the resources attached
  154689. */
  154690. dispose(): void;
  154691. /**
  154692. * Get the hand object according to the controller id
  154693. * @param controllerId the controller id to which we want to get the hand
  154694. * @returns null if not found or the WebXRHand object if found
  154695. */
  154696. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  154697. /**
  154698. * Get a hand object according to the requested handedness
  154699. * @param handedness the handedness to request
  154700. * @returns null if not found or the WebXRHand object if found
  154701. */
  154702. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  154703. protected _onXRFrame(_xrFrame: XRFrame): void;
  154704. private _attachHand;
  154705. private _detachHand;
  154706. }
  154707. }
  154708. declare module BABYLON {
  154709. /**
  154710. * The motion controller class for all microsoft mixed reality controllers
  154711. */
  154712. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  154713. protected readonly _mapping: {
  154714. defaultButton: {
  154715. valueNodeName: string;
  154716. unpressedNodeName: string;
  154717. pressedNodeName: string;
  154718. };
  154719. defaultAxis: {
  154720. valueNodeName: string;
  154721. minNodeName: string;
  154722. maxNodeName: string;
  154723. };
  154724. buttons: {
  154725. "xr-standard-trigger": {
  154726. rootNodeName: string;
  154727. componentProperty: string;
  154728. states: string[];
  154729. };
  154730. "xr-standard-squeeze": {
  154731. rootNodeName: string;
  154732. componentProperty: string;
  154733. states: string[];
  154734. };
  154735. "xr-standard-touchpad": {
  154736. rootNodeName: string;
  154737. labelAnchorNodeName: string;
  154738. touchPointNodeName: string;
  154739. };
  154740. "xr-standard-thumbstick": {
  154741. rootNodeName: string;
  154742. componentProperty: string;
  154743. states: string[];
  154744. };
  154745. };
  154746. axes: {
  154747. "xr-standard-touchpad": {
  154748. "x-axis": {
  154749. rootNodeName: string;
  154750. };
  154751. "y-axis": {
  154752. rootNodeName: string;
  154753. };
  154754. };
  154755. "xr-standard-thumbstick": {
  154756. "x-axis": {
  154757. rootNodeName: string;
  154758. };
  154759. "y-axis": {
  154760. rootNodeName: string;
  154761. };
  154762. };
  154763. };
  154764. };
  154765. /**
  154766. * The base url used to load the left and right controller models
  154767. */
  154768. static MODEL_BASE_URL: string;
  154769. /**
  154770. * The name of the left controller model file
  154771. */
  154772. static MODEL_LEFT_FILENAME: string;
  154773. /**
  154774. * The name of the right controller model file
  154775. */
  154776. static MODEL_RIGHT_FILENAME: string;
  154777. profileId: string;
  154778. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  154779. protected _getFilenameAndPath(): {
  154780. filename: string;
  154781. path: string;
  154782. };
  154783. protected _getModelLoadingConstraints(): boolean;
  154784. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  154785. protected _setRootMesh(meshes: AbstractMesh[]): void;
  154786. protected _updateModel(): void;
  154787. }
  154788. }
  154789. declare module BABYLON {
  154790. /**
  154791. * The motion controller class for oculus touch (quest, rift).
  154792. * This class supports legacy mapping as well the standard xr mapping
  154793. */
  154794. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  154795. private _forceLegacyControllers;
  154796. private _modelRootNode;
  154797. /**
  154798. * The base url used to load the left and right controller models
  154799. */
  154800. static MODEL_BASE_URL: string;
  154801. /**
  154802. * The name of the left controller model file
  154803. */
  154804. static MODEL_LEFT_FILENAME: string;
  154805. /**
  154806. * The name of the right controller model file
  154807. */
  154808. static MODEL_RIGHT_FILENAME: string;
  154809. /**
  154810. * Base Url for the Quest controller model.
  154811. */
  154812. static QUEST_MODEL_BASE_URL: string;
  154813. profileId: string;
  154814. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  154815. protected _getFilenameAndPath(): {
  154816. filename: string;
  154817. path: string;
  154818. };
  154819. protected _getModelLoadingConstraints(): boolean;
  154820. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  154821. protected _setRootMesh(meshes: AbstractMesh[]): void;
  154822. protected _updateModel(): void;
  154823. /**
  154824. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  154825. * between the touch and touch 2.
  154826. */
  154827. private _isQuest;
  154828. }
  154829. }
  154830. declare module BABYLON {
  154831. /**
  154832. * The motion controller class for the standard HTC-Vive controllers
  154833. */
  154834. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  154835. private _modelRootNode;
  154836. /**
  154837. * The base url used to load the left and right controller models
  154838. */
  154839. static MODEL_BASE_URL: string;
  154840. /**
  154841. * File name for the controller model.
  154842. */
  154843. static MODEL_FILENAME: string;
  154844. profileId: string;
  154845. /**
  154846. * Create a new Vive motion controller object
  154847. * @param scene the scene to use to create this controller
  154848. * @param gamepadObject the corresponding gamepad object
  154849. * @param handedness the handedness of the controller
  154850. */
  154851. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  154852. protected _getFilenameAndPath(): {
  154853. filename: string;
  154854. path: string;
  154855. };
  154856. protected _getModelLoadingConstraints(): boolean;
  154857. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  154858. protected _setRootMesh(meshes: AbstractMesh[]): void;
  154859. protected _updateModel(): void;
  154860. }
  154861. }
  154862. declare module BABYLON {
  154863. /**
  154864. * A cursor which tracks a point on a path
  154865. */
  154866. export class PathCursor {
  154867. private path;
  154868. /**
  154869. * Stores path cursor callbacks for when an onchange event is triggered
  154870. */
  154871. private _onchange;
  154872. /**
  154873. * The value of the path cursor
  154874. */
  154875. value: number;
  154876. /**
  154877. * The animation array of the path cursor
  154878. */
  154879. animations: Animation[];
  154880. /**
  154881. * Initializes the path cursor
  154882. * @param path The path to track
  154883. */
  154884. constructor(path: Path2);
  154885. /**
  154886. * Gets the cursor point on the path
  154887. * @returns A point on the path cursor at the cursor location
  154888. */
  154889. getPoint(): Vector3;
  154890. /**
  154891. * Moves the cursor ahead by the step amount
  154892. * @param step The amount to move the cursor forward
  154893. * @returns This path cursor
  154894. */
  154895. moveAhead(step?: number): PathCursor;
  154896. /**
  154897. * Moves the cursor behind by the step amount
  154898. * @param step The amount to move the cursor back
  154899. * @returns This path cursor
  154900. */
  154901. moveBack(step?: number): PathCursor;
  154902. /**
  154903. * Moves the cursor by the step amount
  154904. * If the step amount is greater than one, an exception is thrown
  154905. * @param step The amount to move the cursor
  154906. * @returns This path cursor
  154907. */
  154908. move(step: number): PathCursor;
  154909. /**
  154910. * Ensures that the value is limited between zero and one
  154911. * @returns This path cursor
  154912. */
  154913. private ensureLimits;
  154914. /**
  154915. * Runs onchange callbacks on change (used by the animation engine)
  154916. * @returns This path cursor
  154917. */
  154918. private raiseOnChange;
  154919. /**
  154920. * Executes a function on change
  154921. * @param f A path cursor onchange callback
  154922. * @returns This path cursor
  154923. */
  154924. onchange(f: (cursor: PathCursor) => void): PathCursor;
  154925. }
  154926. }
  154927. declare module BABYLON {
  154928. /** @hidden */
  154929. export var blurPixelShader: {
  154930. name: string;
  154931. shader: string;
  154932. };
  154933. }
  154934. declare module BABYLON {
  154935. /** @hidden */
  154936. export var pointCloudVertexDeclaration: {
  154937. name: string;
  154938. shader: string;
  154939. };
  154940. }
  154941. // Mixins
  154942. interface Window {
  154943. mozIndexedDB: IDBFactory;
  154944. webkitIndexedDB: IDBFactory;
  154945. msIndexedDB: IDBFactory;
  154946. webkitURL: typeof URL;
  154947. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  154948. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  154949. WebGLRenderingContext: WebGLRenderingContext;
  154950. MSGesture: MSGesture;
  154951. CANNON: any;
  154952. AudioContext: AudioContext;
  154953. webkitAudioContext: AudioContext;
  154954. PointerEvent: any;
  154955. Math: Math;
  154956. Uint8Array: Uint8ArrayConstructor;
  154957. Float32Array: Float32ArrayConstructor;
  154958. mozURL: typeof URL;
  154959. msURL: typeof URL;
  154960. VRFrameData: any; // WebVR, from specs 1.1
  154961. DracoDecoderModule: any;
  154962. setImmediate(handler: (...args: any[]) => void): number;
  154963. }
  154964. interface HTMLCanvasElement {
  154965. requestPointerLock(): void;
  154966. msRequestPointerLock?(): void;
  154967. mozRequestPointerLock?(): void;
  154968. webkitRequestPointerLock?(): void;
  154969. /** Track wether a record is in progress */
  154970. isRecording: boolean;
  154971. /** Capture Stream method defined by some browsers */
  154972. captureStream(fps?: number): MediaStream;
  154973. }
  154974. interface CanvasRenderingContext2D {
  154975. msImageSmoothingEnabled: boolean;
  154976. }
  154977. interface MouseEvent {
  154978. mozMovementX: number;
  154979. mozMovementY: number;
  154980. webkitMovementX: number;
  154981. webkitMovementY: number;
  154982. msMovementX: number;
  154983. msMovementY: number;
  154984. }
  154985. interface Navigator {
  154986. mozGetVRDevices: (any: any) => any;
  154987. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  154988. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  154989. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  154990. webkitGetGamepads(): Gamepad[];
  154991. msGetGamepads(): Gamepad[];
  154992. webkitGamepads(): Gamepad[];
  154993. }
  154994. interface HTMLVideoElement {
  154995. mozSrcObject: any;
  154996. }
  154997. interface Math {
  154998. fround(x: number): number;
  154999. imul(a: number, b: number): number;
  155000. }
  155001. interface WebGLRenderingContext {
  155002. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  155003. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  155004. vertexAttribDivisor(index: number, divisor: number): void;
  155005. createVertexArray(): any;
  155006. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  155007. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  155008. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  155009. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  155010. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  155011. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  155012. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  155013. // Queries
  155014. createQuery(): WebGLQuery;
  155015. deleteQuery(query: WebGLQuery): void;
  155016. beginQuery(target: number, query: WebGLQuery): void;
  155017. endQuery(target: number): void;
  155018. getQueryParameter(query: WebGLQuery, pname: number): any;
  155019. getQuery(target: number, pname: number): any;
  155020. MAX_SAMPLES: number;
  155021. RGBA8: number;
  155022. READ_FRAMEBUFFER: number;
  155023. DRAW_FRAMEBUFFER: number;
  155024. UNIFORM_BUFFER: number;
  155025. HALF_FLOAT_OES: number;
  155026. RGBA16F: number;
  155027. RGBA32F: number;
  155028. R32F: number;
  155029. RG32F: number;
  155030. RGB32F: number;
  155031. R16F: number;
  155032. RG16F: number;
  155033. RGB16F: number;
  155034. RED: number;
  155035. RG: number;
  155036. R8: number;
  155037. RG8: number;
  155038. UNSIGNED_INT_24_8: number;
  155039. DEPTH24_STENCIL8: number;
  155040. MIN: number;
  155041. MAX: number;
  155042. /* Multiple Render Targets */
  155043. drawBuffers(buffers: number[]): void;
  155044. readBuffer(src: number): void;
  155045. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  155046. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  155047. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  155048. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  155049. // Occlusion Query
  155050. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  155051. ANY_SAMPLES_PASSED: number;
  155052. QUERY_RESULT_AVAILABLE: number;
  155053. QUERY_RESULT: number;
  155054. }
  155055. interface WebGLProgram {
  155056. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  155057. }
  155058. interface EXT_disjoint_timer_query {
  155059. QUERY_COUNTER_BITS_EXT: number;
  155060. TIME_ELAPSED_EXT: number;
  155061. TIMESTAMP_EXT: number;
  155062. GPU_DISJOINT_EXT: number;
  155063. QUERY_RESULT_EXT: number;
  155064. QUERY_RESULT_AVAILABLE_EXT: number;
  155065. queryCounterEXT(query: WebGLQuery, target: number): void;
  155066. createQueryEXT(): WebGLQuery;
  155067. beginQueryEXT(target: number, query: WebGLQuery): void;
  155068. endQueryEXT(target: number): void;
  155069. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  155070. deleteQueryEXT(query: WebGLQuery): void;
  155071. }
  155072. interface WebGLUniformLocation {
  155073. _currentState: any;
  155074. }
  155075. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  155076. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  155077. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  155078. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  155079. interface WebGLRenderingContext {
  155080. readonly RASTERIZER_DISCARD: number;
  155081. readonly DEPTH_COMPONENT24: number;
  155082. readonly TEXTURE_3D: number;
  155083. readonly TEXTURE_2D_ARRAY: number;
  155084. readonly TEXTURE_COMPARE_FUNC: number;
  155085. readonly TEXTURE_COMPARE_MODE: number;
  155086. readonly COMPARE_REF_TO_TEXTURE: number;
  155087. readonly TEXTURE_WRAP_R: number;
  155088. readonly HALF_FLOAT: number;
  155089. readonly RGB8: number;
  155090. readonly RED_INTEGER: number;
  155091. readonly RG_INTEGER: number;
  155092. readonly RGB_INTEGER: number;
  155093. readonly RGBA_INTEGER: number;
  155094. readonly R8_SNORM: number;
  155095. readonly RG8_SNORM: number;
  155096. readonly RGB8_SNORM: number;
  155097. readonly RGBA8_SNORM: number;
  155098. readonly R8I: number;
  155099. readonly RG8I: number;
  155100. readonly RGB8I: number;
  155101. readonly RGBA8I: number;
  155102. readonly R8UI: number;
  155103. readonly RG8UI: number;
  155104. readonly RGB8UI: number;
  155105. readonly RGBA8UI: number;
  155106. readonly R16I: number;
  155107. readonly RG16I: number;
  155108. readonly RGB16I: number;
  155109. readonly RGBA16I: number;
  155110. readonly R16UI: number;
  155111. readonly RG16UI: number;
  155112. readonly RGB16UI: number;
  155113. readonly RGBA16UI: number;
  155114. readonly R32I: number;
  155115. readonly RG32I: number;
  155116. readonly RGB32I: number;
  155117. readonly RGBA32I: number;
  155118. readonly R32UI: number;
  155119. readonly RG32UI: number;
  155120. readonly RGB32UI: number;
  155121. readonly RGBA32UI: number;
  155122. readonly RGB10_A2UI: number;
  155123. readonly R11F_G11F_B10F: number;
  155124. readonly RGB9_E5: number;
  155125. readonly RGB10_A2: number;
  155126. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  155127. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  155128. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  155129. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  155130. readonly DEPTH_COMPONENT32F: number;
  155131. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  155132. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  155133. 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;
  155134. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  155135. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  155136. readonly TRANSFORM_FEEDBACK: number;
  155137. readonly INTERLEAVED_ATTRIBS: number;
  155138. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  155139. createTransformFeedback(): WebGLTransformFeedback;
  155140. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  155141. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  155142. beginTransformFeedback(primitiveMode: number): void;
  155143. endTransformFeedback(): void;
  155144. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  155145. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155146. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155147. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155148. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  155149. }
  155150. interface ImageBitmap {
  155151. readonly width: number;
  155152. readonly height: number;
  155153. close(): void;
  155154. }
  155155. interface WebGLQuery extends WebGLObject {
  155156. }
  155157. declare var WebGLQuery: {
  155158. prototype: WebGLQuery;
  155159. new(): WebGLQuery;
  155160. };
  155161. interface WebGLSampler extends WebGLObject {
  155162. }
  155163. declare var WebGLSampler: {
  155164. prototype: WebGLSampler;
  155165. new(): WebGLSampler;
  155166. };
  155167. interface WebGLSync extends WebGLObject {
  155168. }
  155169. declare var WebGLSync: {
  155170. prototype: WebGLSync;
  155171. new(): WebGLSync;
  155172. };
  155173. interface WebGLTransformFeedback extends WebGLObject {
  155174. }
  155175. declare var WebGLTransformFeedback: {
  155176. prototype: WebGLTransformFeedback;
  155177. new(): WebGLTransformFeedback;
  155178. };
  155179. interface WebGLVertexArrayObject extends WebGLObject {
  155180. }
  155181. declare var WebGLVertexArrayObject: {
  155182. prototype: WebGLVertexArrayObject;
  155183. new(): WebGLVertexArrayObject;
  155184. };
  155185. // Type definitions for WebVR API
  155186. // Project: https://w3c.github.io/webvr/
  155187. // Definitions by: six a <https://github.com/lostfictions>
  155188. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  155189. interface VRDisplay extends EventTarget {
  155190. /**
  155191. * Dictionary of capabilities describing the VRDisplay.
  155192. */
  155193. readonly capabilities: VRDisplayCapabilities;
  155194. /**
  155195. * z-depth defining the far plane of the eye view frustum
  155196. * enables mapping of values in the render target depth
  155197. * attachment to scene coordinates. Initially set to 10000.0.
  155198. */
  155199. depthFar: number;
  155200. /**
  155201. * z-depth defining the near plane of the eye view frustum
  155202. * enables mapping of values in the render target depth
  155203. * attachment to scene coordinates. Initially set to 0.01.
  155204. */
  155205. depthNear: number;
  155206. /**
  155207. * An identifier for this distinct VRDisplay. Used as an
  155208. * association point in the Gamepad API.
  155209. */
  155210. readonly displayId: number;
  155211. /**
  155212. * A display name, a user-readable name identifying it.
  155213. */
  155214. readonly displayName: string;
  155215. readonly isConnected: boolean;
  155216. readonly isPresenting: boolean;
  155217. /**
  155218. * If this VRDisplay supports room-scale experiences, the optional
  155219. * stage attribute contains details on the room-scale parameters.
  155220. */
  155221. readonly stageParameters: VRStageParameters | null;
  155222. /**
  155223. * Passing the value returned by `requestAnimationFrame` to
  155224. * `cancelAnimationFrame` will unregister the callback.
  155225. * @param handle Define the hanle of the request to cancel
  155226. */
  155227. cancelAnimationFrame(handle: number): void;
  155228. /**
  155229. * Stops presenting to the VRDisplay.
  155230. * @returns a promise to know when it stopped
  155231. */
  155232. exitPresent(): Promise<void>;
  155233. /**
  155234. * Return the current VREyeParameters for the given eye.
  155235. * @param whichEye Define the eye we want the parameter for
  155236. * @returns the eye parameters
  155237. */
  155238. getEyeParameters(whichEye: string): VREyeParameters;
  155239. /**
  155240. * Populates the passed VRFrameData with the information required to render
  155241. * the current frame.
  155242. * @param frameData Define the data structure to populate
  155243. * @returns true if ok otherwise false
  155244. */
  155245. getFrameData(frameData: VRFrameData): boolean;
  155246. /**
  155247. * Get the layers currently being presented.
  155248. * @returns the list of VR layers
  155249. */
  155250. getLayers(): VRLayer[];
  155251. /**
  155252. * Return a VRPose containing the future predicted pose of the VRDisplay
  155253. * when the current frame will be presented. The value returned will not
  155254. * change until JavaScript has returned control to the browser.
  155255. *
  155256. * The VRPose will contain the position, orientation, velocity,
  155257. * and acceleration of each of these properties.
  155258. * @returns the pose object
  155259. */
  155260. getPose(): VRPose;
  155261. /**
  155262. * Return the current instantaneous pose of the VRDisplay, with no
  155263. * prediction applied.
  155264. * @returns the current instantaneous pose
  155265. */
  155266. getImmediatePose(): VRPose;
  155267. /**
  155268. * The callback passed to `requestAnimationFrame` will be called
  155269. * any time a new frame should be rendered. When the VRDisplay is
  155270. * presenting the callback will be called at the native refresh
  155271. * rate of the HMD. When not presenting this function acts
  155272. * identically to how window.requestAnimationFrame acts. Content should
  155273. * make no assumptions of frame rate or vsync behavior as the HMD runs
  155274. * asynchronously from other displays and at differing refresh rates.
  155275. * @param callback Define the eaction to run next frame
  155276. * @returns the request handle it
  155277. */
  155278. requestAnimationFrame(callback: FrameRequestCallback): number;
  155279. /**
  155280. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  155281. * Repeat calls while already presenting will update the VRLayers being displayed.
  155282. * @param layers Define the list of layer to present
  155283. * @returns a promise to know when the request has been fulfilled
  155284. */
  155285. requestPresent(layers: VRLayer[]): Promise<void>;
  155286. /**
  155287. * Reset the pose for this display, treating its current position and
  155288. * orientation as the "origin/zero" values. VRPose.position,
  155289. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  155290. * updated when calling resetPose(). This should be called in only
  155291. * sitting-space experiences.
  155292. */
  155293. resetPose(): void;
  155294. /**
  155295. * The VRLayer provided to the VRDisplay will be captured and presented
  155296. * in the HMD. Calling this function has the same effect on the source
  155297. * canvas as any other operation that uses its source image, and canvases
  155298. * created without preserveDrawingBuffer set to true will be cleared.
  155299. * @param pose Define the pose to submit
  155300. */
  155301. submitFrame(pose?: VRPose): void;
  155302. }
  155303. declare var VRDisplay: {
  155304. prototype: VRDisplay;
  155305. new(): VRDisplay;
  155306. };
  155307. interface VRLayer {
  155308. leftBounds?: number[] | Float32Array | null;
  155309. rightBounds?: number[] | Float32Array | null;
  155310. source?: HTMLCanvasElement | null;
  155311. }
  155312. interface VRDisplayCapabilities {
  155313. readonly canPresent: boolean;
  155314. readonly hasExternalDisplay: boolean;
  155315. readonly hasOrientation: boolean;
  155316. readonly hasPosition: boolean;
  155317. readonly maxLayers: number;
  155318. }
  155319. interface VREyeParameters {
  155320. /** @deprecated */
  155321. readonly fieldOfView: VRFieldOfView;
  155322. readonly offset: Float32Array;
  155323. readonly renderHeight: number;
  155324. readonly renderWidth: number;
  155325. }
  155326. interface VRFieldOfView {
  155327. readonly downDegrees: number;
  155328. readonly leftDegrees: number;
  155329. readonly rightDegrees: number;
  155330. readonly upDegrees: number;
  155331. }
  155332. interface VRFrameData {
  155333. readonly leftProjectionMatrix: Float32Array;
  155334. readonly leftViewMatrix: Float32Array;
  155335. readonly pose: VRPose;
  155336. readonly rightProjectionMatrix: Float32Array;
  155337. readonly rightViewMatrix: Float32Array;
  155338. readonly timestamp: number;
  155339. }
  155340. interface VRPose {
  155341. readonly angularAcceleration: Float32Array | null;
  155342. readonly angularVelocity: Float32Array | null;
  155343. readonly linearAcceleration: Float32Array | null;
  155344. readonly linearVelocity: Float32Array | null;
  155345. readonly orientation: Float32Array | null;
  155346. readonly position: Float32Array | null;
  155347. readonly timestamp: number;
  155348. }
  155349. interface VRStageParameters {
  155350. sittingToStandingTransform?: Float32Array;
  155351. sizeX?: number;
  155352. sizeY?: number;
  155353. }
  155354. interface Navigator {
  155355. getVRDisplays(): Promise<VRDisplay[]>;
  155356. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  155357. }
  155358. interface Window {
  155359. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  155360. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  155361. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  155362. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  155363. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  155364. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  155365. }
  155366. interface Gamepad {
  155367. readonly displayId: number;
  155368. }
  155369. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  155370. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  155371. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  155372. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  155373. type XRHandedness = "none" | "left" | "right";
  155374. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  155375. type XREye = "none" | "left" | "right";
  155376. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  155377. interface XRSpace extends EventTarget {}
  155378. interface XRRenderState {
  155379. depthNear?: number;
  155380. depthFar?: number;
  155381. inlineVerticalFieldOfView?: number;
  155382. baseLayer?: XRWebGLLayer;
  155383. }
  155384. interface XRInputSource {
  155385. handedness: XRHandedness;
  155386. targetRayMode: XRTargetRayMode;
  155387. targetRaySpace: XRSpace;
  155388. gripSpace: XRSpace | undefined;
  155389. gamepad: Gamepad | undefined;
  155390. profiles: Array<string>;
  155391. hand: XRHand | undefined;
  155392. }
  155393. interface XRSessionInit {
  155394. optionalFeatures?: string[];
  155395. requiredFeatures?: string[];
  155396. }
  155397. interface XRSession {
  155398. addEventListener: Function;
  155399. removeEventListener: Function;
  155400. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  155401. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  155402. requestAnimationFrame: Function;
  155403. end(): Promise<void>;
  155404. renderState: XRRenderState;
  155405. inputSources: Array<XRInputSource>;
  155406. // hit test
  155407. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  155408. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  155409. // legacy AR hit test
  155410. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155411. // legacy plane detection
  155412. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  155413. }
  155414. interface XRReferenceSpace extends XRSpace {
  155415. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  155416. onreset: any;
  155417. }
  155418. type XRPlaneSet = Set<XRPlane>;
  155419. type XRAnchorSet = Set<XRAnchor>;
  155420. interface XRFrame {
  155421. session: XRSession;
  155422. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  155423. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  155424. // AR
  155425. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  155426. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  155427. // Anchors
  155428. trackedAnchors?: XRAnchorSet;
  155429. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  155430. // Planes
  155431. worldInformation: {
  155432. detectedPlanes?: XRPlaneSet;
  155433. };
  155434. // Hand tracking
  155435. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  155436. }
  155437. interface XRViewerPose extends XRPose {
  155438. views: Array<XRView>;
  155439. }
  155440. interface XRPose {
  155441. transform: XRRigidTransform;
  155442. emulatedPosition: boolean;
  155443. }
  155444. interface XRWebGLLayerOptions {
  155445. antialias?: boolean;
  155446. depth?: boolean;
  155447. stencil?: boolean;
  155448. alpha?: boolean;
  155449. multiview?: boolean;
  155450. framebufferScaleFactor?: number;
  155451. }
  155452. declare var XRWebGLLayer: {
  155453. prototype: XRWebGLLayer;
  155454. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  155455. };
  155456. interface XRWebGLLayer {
  155457. framebuffer: WebGLFramebuffer;
  155458. framebufferWidth: number;
  155459. framebufferHeight: number;
  155460. getViewport: Function;
  155461. }
  155462. declare class XRRigidTransform {
  155463. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  155464. position: DOMPointReadOnly;
  155465. orientation: DOMPointReadOnly;
  155466. matrix: Float32Array;
  155467. inverse: XRRigidTransform;
  155468. }
  155469. interface XRView {
  155470. eye: XREye;
  155471. projectionMatrix: Float32Array;
  155472. transform: XRRigidTransform;
  155473. }
  155474. interface XRInputSourceChangeEvent {
  155475. session: XRSession;
  155476. removed: Array<XRInputSource>;
  155477. added: Array<XRInputSource>;
  155478. }
  155479. interface XRInputSourceEvent extends Event {
  155480. readonly frame: XRFrame;
  155481. readonly inputSource: XRInputSource;
  155482. }
  155483. // Experimental(er) features
  155484. declare class XRRay {
  155485. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  155486. origin: DOMPointReadOnly;
  155487. direction: DOMPointReadOnly;
  155488. matrix: Float32Array;
  155489. }
  155490. declare enum XRHitTestTrackableType {
  155491. "point",
  155492. "plane",
  155493. "mesh",
  155494. }
  155495. interface XRHitResult {
  155496. hitMatrix: Float32Array;
  155497. }
  155498. interface XRTransientInputHitTestResult {
  155499. readonly inputSource: XRInputSource;
  155500. readonly results: Array<XRHitTestResult>;
  155501. }
  155502. interface XRHitTestResult {
  155503. getPose(baseSpace: XRSpace): XRPose | undefined;
  155504. // When anchor system is enabled
  155505. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  155506. }
  155507. interface XRHitTestSource {
  155508. cancel(): void;
  155509. }
  155510. interface XRTransientInputHitTestSource {
  155511. cancel(): void;
  155512. }
  155513. interface XRHitTestOptionsInit {
  155514. space: XRSpace;
  155515. entityTypes?: Array<XRHitTestTrackableType>;
  155516. offsetRay?: XRRay;
  155517. }
  155518. interface XRTransientInputHitTestOptionsInit {
  155519. profile: string;
  155520. entityTypes?: Array<XRHitTestTrackableType>;
  155521. offsetRay?: XRRay;
  155522. }
  155523. interface XRAnchor {
  155524. anchorSpace: XRSpace;
  155525. delete(): void;
  155526. }
  155527. interface XRPlane {
  155528. orientation: "Horizontal" | "Vertical";
  155529. planeSpace: XRSpace;
  155530. polygon: Array<DOMPointReadOnly>;
  155531. lastChangedTime: number;
  155532. }
  155533. interface XRJointSpace extends XRSpace {}
  155534. interface XRJointPose extends XRPose {
  155535. radius: number | undefined;
  155536. }
  155537. declare class XRHand extends Array<XRJointSpace> {
  155538. readonly length: number;
  155539. static readonly WRIST = 0;
  155540. static readonly THUMB_METACARPAL = 1;
  155541. static readonly THUMB_PHALANX_PROXIMAL = 2;
  155542. static readonly THUMB_PHALANX_DISTAL = 3;
  155543. static readonly THUMB_PHALANX_TIP = 4;
  155544. static readonly INDEX_METACARPAL = 5;
  155545. static readonly INDEX_PHALANX_PROXIMAL = 6;
  155546. static readonly INDEX_PHALANX_INTERMEDIATE = 7;
  155547. static readonly INDEX_PHALANX_DISTAL = 8;
  155548. static readonly INDEX_PHALANX_TIP = 9;
  155549. static readonly MIDDLE_METACARPAL = 10;
  155550. static readonly MIDDLE_PHALANX_PROXIMAL = 11;
  155551. static readonly MIDDLE_PHALANX_INTERMEDIATE = 12;
  155552. static readonly MIDDLE_PHALANX_DISTAL = 13;
  155553. static readonly MIDDLE_PHALANX_TIP = 14;
  155554. static readonly RING_METACARPAL = 15;
  155555. static readonly RING_PHALANX_PROXIMAL = 16;
  155556. static readonly RING_PHALANX_INTERMEDIATE = 17;
  155557. static readonly RING_PHALANX_DISTAL = 18;
  155558. static readonly RING_PHALANX_TIP = 19;
  155559. static readonly LITTLE_METACARPAL = 20;
  155560. static readonly LITTLE_PHALANX_PROXIMAL = 21;
  155561. static readonly LITTLE_PHALANX_INTERMEDIATE = 22;
  155562. static readonly LITTLE_PHALANX_DISTAL = 23;
  155563. static readonly LITTLE_PHALANX_TIP = 24;
  155564. }
  155565. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  155566. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  155567. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  155568. interface XRSession {
  155569. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  155570. }
  155571. interface XRFrame {
  155572. featurePointCloud? : Array<number>;
  155573. }